GroupsController.cs 697 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using Microsoft.AspNetCore.SignalR;
  6. using NPOI.HSSF.UserModel;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.OAMethodLib;
  11. using OASystem.API.OAMethodLib.File;
  12. using OASystem.API.OAMethodLib.Hub.HubClients;
  13. using OASystem.API.OAMethodLib.Hub.Hubs;
  14. using OASystem.API.OAMethodLib.JuHeAPI;
  15. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  16. using OASystem.Domain.Dtos.CRM;
  17. using OASystem.Domain.Dtos.FileDto;
  18. using OASystem.Domain.Dtos.Groups;
  19. using OASystem.Domain.Entities.Customer;
  20. using OASystem.Domain.Entities.Financial;
  21. using OASystem.Domain.Entities.Groups;
  22. using OASystem.Domain.ViewModels.Groups;
  23. using OASystem.Infrastructure.Repositories.Groups;
  24. using Quartz.Util;
  25. using SqlSugar.Extensions;
  26. using System.Collections;
  27. using System.Data;
  28. using System.Diagnostics;
  29. using System.Globalization;
  30. using System.IO;
  31. using System.Reflection.PortableExecutable;
  32. using Ubiety.Dns.Core;
  33. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  34. using Bookmark = Aspose.Words.Bookmark;
  35. using Cell = Aspose.Words.Tables.Cell;
  36. using Table = Aspose.Words.Tables.Table;
  37. namespace OASystem.API.Controllers
  38. {
  39. /// <summary>
  40. /// 团组相关
  41. /// </summary>
  42. //[Authorize]
  43. [Route("api/[controller]/[action]")]
  44. public class GroupsController : ControllerBase
  45. {
  46. private readonly ILogger<GroupsController> _logger;
  47. private readonly GrpScheduleRepository _grpScheduleRep;
  48. private readonly IMapper _mapper;
  49. private readonly DelegationInfoRepository _groupRepository;
  50. private readonly TaskAssignmentRepository _taskAssignmentRep;
  51. private readonly AirTicketResRepository _airTicketResRep;
  52. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  53. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  54. private readonly DelegationEnDataRepository _delegationEnDataRep;
  55. private readonly DelegationVisaRepository _delegationVisaRep;
  56. private readonly VisaPriceRepository _visaPriceRep;
  57. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  58. private readonly HotelPriceRepository _hotelPriceRep;
  59. private readonly CustomersRepository _customersRep;
  60. private readonly MessageRepository _message;
  61. private readonly SqlSugarClient _sqlSugar;
  62. private readonly TourClientListRepository _tourClientListRep;
  63. private readonly TeamRateRepository _teamRateRep;
  64. #region 成本相关
  65. private readonly CheckBoxsRepository _checkBoxs;
  66. private readonly GroupCostRepository _GroupCostRepository;
  67. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  68. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  69. #endregion
  70. private readonly SetDataRepository _setDataRep;
  71. private string url;
  72. private string path;
  73. private readonly EnterExitCostRepository _enterExitCostRep;
  74. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  75. private readonly UsersRepository _usersRep;
  76. private readonly IJuHeApiService _juHeApi;
  77. private readonly InvertedListRepository _invertedListRep;
  78. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  79. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  80. private readonly ThreeCodeRepository _threeCodeRepository;
  81. private readonly HotelInquiryRepository _hotelInquiryRep;
  82. private readonly FeeAuditRepository _feeAuditRep;
  83. private readonly VisaCommissionRepository _visaCommissionRep;
  84. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  85. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  86. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  87. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  88. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  89. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  90. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  91. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  92. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep)
  93. {
  94. _logger = logger;
  95. _mapper = mapper;
  96. _grpScheduleRep = grpScheduleRep;
  97. _groupRepository = groupRepository;
  98. _taskAssignmentRep = taskAssignmentRep;
  99. _airTicketResRep = airTicketResRep;
  100. _sqlSugar = sqlSugar;
  101. url = AppSettingsHelper.Get("ExcelBaseUrl");
  102. path = AppSettingsHelper.Get("ExcelBasePath");
  103. if (!System.IO.Directory.Exists(path))
  104. {
  105. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  106. }
  107. _decreasePaymentsRep = decreasePaymentsRep;
  108. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  109. _delegationEnDataRep = delegationEnDataRep;
  110. _enterExitCostRep = enterExitCostRep;
  111. _delegationVisaRep = delegationVisaRep;
  112. _message = message;
  113. _visaPriceRep = visaPriceRep;
  114. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  115. _checkBoxs = checkBoxs;
  116. _GroupCostRepository = GroupCostRepository;
  117. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  118. _GroupCostParameterRepository = GroupCostParameterRepository;
  119. _hotelPriceRep = hotelPriceRep;
  120. _customersRep = customersRep;
  121. _setDataRep = setDataRep;
  122. _tourClientListRep = tourClientListRep;
  123. _teamRateRep = teamRateRep;
  124. _hubContext = hubContext;
  125. _usersRep = usersRep;
  126. _juHeApi = juHeApi;
  127. _invertedListRep = invertedListRep;
  128. _visaFeeInfoRep = visaFeeInfoRep;
  129. _ticketBlackCodeRep = ticketBlackCodeRep;
  130. _hotelInquiryRep = hotelInquiryRep;
  131. _threeCodeRepository = threeCodeRepository;
  132. _feeAuditRep = feeAuditRep;
  133. _visaCommissionRep = visaCommissionRep;
  134. }
  135. #region 流程管控
  136. /// <summary>
  137. /// 获取团组流程管控信息
  138. /// </summary>
  139. /// <param name="paras">参数Json字符串</param>
  140. /// <returns></returns>
  141. [HttpPost]
  142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  143. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  144. {
  145. if (string.IsNullOrEmpty(_jsonDto.Paras))
  146. {
  147. return Ok(JsonView(false, "参数为空"));
  148. }
  149. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  150. if (_ScheduleDto != null)
  151. {
  152. if (_ScheduleDto.SearchType == 2)//获取列表
  153. {
  154. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  155. return Ok(JsonView(_grpScheduleViewList));
  156. }
  157. else//获取对象
  158. {
  159. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  160. if (_grpScheduleView != null)
  161. {
  162. return Ok(JsonView(_grpScheduleView));
  163. }
  164. }
  165. }
  166. else
  167. {
  168. return Ok(JsonView(false, "参数反序列化失败"));
  169. }
  170. return Ok(JsonView(false, "暂无数据!"));
  171. }
  172. /// <summary>
  173. /// 修改团组流程管控详细表数据
  174. /// </summary>
  175. /// <param name="paras"></param>
  176. /// <returns></returns>
  177. [HttpPost]
  178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  179. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  180. {
  181. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  182. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  183. .SetColumns(it => it.Duty == _detail.Duty)
  184. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  185. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  186. .SetColumns(it => it.JobContent == _detail.JobContent)
  187. .SetColumns(it => it.Remark == _detail.Remark)
  188. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  189. .Where(s => s.Id == dto.Id)
  190. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  191. .ExecuteCommandAsync();
  192. if (result > 0)
  193. {
  194. return Ok(JsonView(true, "保存成功!"));
  195. }
  196. return Ok(JsonView(false, "保存失败!"));
  197. }
  198. /// <summary>
  199. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  200. /// </summary>
  201. /// <param name="dto"></param>
  202. /// <returns></returns>
  203. [HttpPost]
  204. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  205. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  206. {
  207. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  208. _detail.IsDel = 1;
  209. _detail.DeleteUserId = dto.Duty;
  210. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  211. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  212. .SetColumns(it => it.IsDel == _detail.IsDel)
  213. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  214. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  215. .Where(it => it.Id == dto.Id)
  216. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  217. //.WhereColumns(s => s.Id == dto.Id)
  218. .ExecuteCommandAsync();
  219. if (result > 0)
  220. {
  221. return Ok(JsonView(true, "删除成功!"));
  222. }
  223. return Ok(JsonView(false, "删除失败!"));
  224. }
  225. /// <summary>
  226. /// 增加团组流程管控详细表数据
  227. /// </summary>
  228. /// <param name="dto"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  233. {
  234. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  235. if (DateTime.Now < _detail.ExpectBeginDt)
  236. {
  237. _detail.StepStatus = 0;
  238. }
  239. else
  240. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  241. _detail.StepStatus = 1;
  242. }
  243. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  244. if (result > 0)
  245. {
  246. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  247. return Ok(JsonView(true, "添加成功!", _result));
  248. }
  249. return Ok(JsonView(false, "添加失败!"));
  250. }
  251. #endregion
  252. #region 团组基本信息
  253. /// <summary>
  254. /// 接团信息列表
  255. /// </summary>
  256. /// <param name="dto">团组列表请求dto</param>
  257. /// <returns></returns>
  258. [HttpPost]
  259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  260. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  261. {
  262. var groupData = await _groupRepository.GetGroupList(dto);
  263. if (groupData.Code != 0)
  264. {
  265. return Ok(JsonView(false, groupData.Msg));
  266. }
  267. return Ok(JsonView(groupData.Data));
  268. }
  269. /// <summary>
  270. /// 分页查询团组列表
  271. /// </summary>
  272. /// <param name="dto"></param>
  273. /// <returns></returns>
  274. [HttpPost]
  275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  276. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  277. {
  278. var watch = new Stopwatch();
  279. watch.Start();
  280. RefAsync<int> total = 0;
  281. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  282. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  283. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  284. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  285. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  286. .Distinct()
  287. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  288. watch.Stop();
  289. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  290. }
  291. /// <summary>
  292. /// 接团信息列表 Page
  293. /// </summary>
  294. /// <param name="dto">团组列表请求dto</param>
  295. /// <returns></returns>
  296. [HttpPost]
  297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  298. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  299. {
  300. #region 参数验证
  301. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  302. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  303. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  304. #region 页面操作权限验证
  305. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  306. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  307. #endregion
  308. #endregion
  309. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  310. {
  311. string sqlWhere = string.Empty;
  312. if (dto.IsSure == 0) //未完成
  313. {
  314. sqlWhere += string.Format(@" And IsSure = 0");
  315. }
  316. else if (dto.IsSure == 1) //已完成
  317. {
  318. sqlWhere += string.Format(@" And IsSure = 1");
  319. }
  320. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  321. {
  322. string tj = dto.SearchCriteria;
  323. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  324. tj, tj, tj, tj, tj);
  325. }
  326. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  327. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  328. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  329. JietuanOperator,IsSure,CreateTime,IsBid
  330. From (
  331. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  332. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  333. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  334. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  335. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  336. From Grp_DelegationInfo gdi
  337. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  338. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  339. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  340. Where gdi.IsDel = 0 {0}
  341. ) temp", sqlWhere);
  342. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  343. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  344. #region 处理所属部门
  345. /*
  346. * 1.sq 和 gyy 等显示 市场部
  347. * 2.王鸽和主管及张总还有管理员号统一国交部
  348. * 2-1. 4 管理员 ,21 张海麟
  349. */
  350. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  351. List<int> userIds1 = new List<int>() { 4, 21 };
  352. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  353. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  354. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  355. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  356. .ToList();
  357. foreach (var item in _DelegationList)
  358. {
  359. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  360. }
  361. #endregion
  362. var _view = new
  363. {
  364. PageFuncAuth = pageFunAuthView,
  365. Data = _DelegationList
  366. };
  367. return Ok(JsonView(true, "查询成功!", _view, total));
  368. }
  369. else
  370. {
  371. return Ok(JsonView(false, "查询失败"));
  372. }
  373. }
  374. /// <summary>
  375. /// 团组列表
  376. /// </summary>
  377. /// <returns></returns>
  378. [HttpPost]
  379. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  380. {
  381. #region 参数验证
  382. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  383. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  384. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  385. #region 页面操作权限验证
  386. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  387. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  388. #endregion
  389. #endregion
  390. if (dto.PortType != 1 && dto.PortType != 2)
  391. {
  392. return Ok(JsonView(false, "查询失败!"));
  393. }
  394. string orderbyStr = "order by gdi.CreateTime Desc";
  395. string sqlWhere = string.Empty;
  396. if (dto.IsSure == 0) //未完成
  397. {
  398. sqlWhere += string.Format(@" And IsSure = 0");
  399. }
  400. else if (dto.IsSure == 1) //已完成
  401. {
  402. sqlWhere += string.Format(@" And IsSure = 1");
  403. }
  404. //团组类型
  405. if (dto.TeamDid > 0)
  406. {
  407. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  408. }
  409. //团组名称
  410. if (!string.IsNullOrEmpty(dto.TeamName))
  411. {
  412. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  413. }
  414. //客户名称
  415. if (!string.IsNullOrEmpty(dto.ClientName))
  416. {
  417. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  418. }
  419. //客户单位
  420. if (!string.IsNullOrEmpty(dto.ClientUnit))
  421. {
  422. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  423. }
  424. //出访时间
  425. if (!string.IsNullOrEmpty(dto.visitDataTime))
  426. {
  427. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  428. orderbyStr = "order by gdi.VisitDate";
  429. }
  430. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  431. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  432. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  433. JietuanOperator,IsSure,CreateTime
  434. From (
  435. Select row_number() over({0}) as Row_Number,
  436. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  437. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  438. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  439. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  440. From Grp_DelegationInfo gdi
  441. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  442. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  443. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  444. Where gdi.IsDel = 0 {1}
  445. ) temp ", orderbyStr, sqlWhere);
  446. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  447. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  448. #region 处理所属部门
  449. /*
  450. * 1.sq 和 gyy 等显示 市场部
  451. * 2.王鸽和主管及张总还有管理员号统一国交部
  452. * 2-1. 4 管理员 ,21 张海麟
  453. */
  454. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  455. List<int> userIds1 = new List<int>() { 4, 21 };
  456. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  457. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  458. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  459. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  460. .ToList();
  461. foreach (var item in _DelegationList)
  462. {
  463. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  464. }
  465. #endregion
  466. var _view = new
  467. {
  468. PageFuncAuth = pageFunAuthView,
  469. Data = _DelegationList
  470. };
  471. return Ok(JsonView(true, "查询成功!", _view, total));
  472. }
  473. /// <summary>
  474. /// 接团信息详情
  475. /// </summary>
  476. /// <param name="dto">团组info请求dto</param>
  477. /// <returns></returns>
  478. [HttpPost]
  479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  480. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  481. {
  482. var groupData = await _groupRepository.GetGroupInfo(dto);
  483. if (groupData.Code != 0)
  484. {
  485. return Ok(JsonView(false, groupData.Msg));
  486. }
  487. return Ok(JsonView(groupData.Data));
  488. }
  489. /// <summary>
  490. /// 接团信息 编辑添加
  491. /// 基础信息数据源
  492. /// </summary>
  493. /// <param name="dto"></param>
  494. /// <returns></returns>
  495. [HttpPost]
  496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  497. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  498. {
  499. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  500. if (groupData.Code != 0)
  501. {
  502. return Ok(JsonView(false, groupData.Msg));
  503. }
  504. return Ok(JsonView(groupData.Data));
  505. }
  506. /// <summary>
  507. /// 接团信息 操作(增改)
  508. /// </summary>
  509. /// <param name="dto"></param>
  510. /// <returns></returns>
  511. [HttpPost]
  512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  513. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  514. {
  515. try
  516. {
  517. var groupData = await _groupRepository.GroupOperation(dto);
  518. if (groupData.Code != 0)
  519. {
  520. return Ok(JsonView(false, groupData.Msg));
  521. }
  522. int diId = 0;
  523. //添加时 默认加入团组汇率
  524. if (dto.Status == 1) //添加
  525. {
  526. diId = groupData.Data;
  527. //添加默认币种
  528. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  529. //默认分配权限
  530. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  531. //消息提示 王鸽 主管号
  532. List<int> _managerIds = new List<int>() { 22, 32 };
  533. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  534. if (userIds.Count > 0)
  535. {
  536. userIds.Add(208);
  537. //创建团组管控
  538. GroupStepForDelegation.CreateWorkStep(diId);
  539. //发送消息
  540. string groupName = dto.TeamName;
  541. string createGroupUser = string.Empty;
  542. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  543. if (userInfo != null) createGroupUser = userInfo.CnName;
  544. string title = $"系统通知";
  545. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  546. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  547. }
  548. //默认创建倒推表
  549. await _invertedListRep._Create(dto.UserId, diId);
  550. }
  551. else if (dto.Status == 2)
  552. {
  553. diId = dto.Id;
  554. }
  555. return Ok(JsonView(true, "操作成功!", diId));
  556. }
  557. catch (Exception ex)
  558. {
  559. Logs("[response]" + JsonConvert.SerializeObject(dto));
  560. Logs(ex.Message);
  561. return Ok(JsonView(false, ex.Message));
  562. }
  563. }
  564. /// <summary>
  565. /// 接团流程操作(增改)
  566. /// 安卓端使用 建团时添加客户名单
  567. /// </summary>
  568. /// <param name="dto"></param>
  569. /// <returns></returns>
  570. [HttpPost]
  571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  572. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  573. {
  574. try
  575. {
  576. #region 参数验证
  577. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  578. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  579. #region 页面操作权限验证
  580. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  581. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  582. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  583. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  584. #endregion
  585. #endregion
  586. _sqlSugar.BeginTran();
  587. var _dto = new GroupOperationDto();
  588. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  589. var groupData = await _groupRepository.GroupOperation(_dto);
  590. if (groupData.Code != 0)
  591. {
  592. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  593. }
  594. int diId = 0;
  595. //添加时 默认加入团组汇率
  596. if (dto.Status == 1) //添加
  597. {
  598. diId = groupData.Data;
  599. //添加默认币种
  600. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  601. //默认分配权限
  602. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  603. //消息提示 王鸽 主管号
  604. List<int> _managerIds = new List<int>() { 22, 32 };
  605. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  606. if (userIds.Count > 0)
  607. {
  608. userIds.Add(208);
  609. //创建团组管控
  610. GroupStepForDelegation.CreateWorkStep(diId);
  611. //发送消息
  612. string groupName = dto.TeamName;
  613. string createGroupUser = string.Empty;
  614. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  615. if (userInfo != null) createGroupUser = userInfo.CnName;
  616. string title = $"系统通知";
  617. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  618. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  619. }
  620. }
  621. if (dto.Status == 2)
  622. {
  623. diId = dto.Id;
  624. if (diId == 0)
  625. {
  626. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  627. }
  628. }
  629. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  630. if (viewData.Code != 0)
  631. {
  632. _sqlSugar.RollbackTran();
  633. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  634. }
  635. _sqlSugar.CommitTran();
  636. return Ok(JsonView(true, "添加成功"));
  637. }
  638. catch (Exception ex)
  639. {
  640. _sqlSugar.RollbackTran();
  641. return Ok(JsonView(false, ex.Message));
  642. }
  643. }
  644. /// <summary>
  645. /// 接团信息 操作(删除)
  646. /// </summary>
  647. /// <param name="dto"></param>
  648. /// <returns></returns>
  649. [HttpPost]
  650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  651. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  652. {
  653. try
  654. {
  655. var groupData = await _groupRepository.GroupDel(dto);
  656. if (groupData.Code != 0)
  657. {
  658. return Ok(JsonView(false, groupData.Msg));
  659. }
  660. return Ok(JsonView(true));
  661. }
  662. catch (Exception ex)
  663. {
  664. Logs("[response]" + JsonConvert.SerializeObject(dto));
  665. Logs(ex.Message);
  666. return Ok(JsonView(false, ex.Message));
  667. }
  668. }
  669. /// <summary>
  670. /// 获取团组销售报价号
  671. /// 团组添加时 使用
  672. /// </summary>
  673. /// <returns></returns>
  674. [HttpPost]
  675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  676. public async Task<IActionResult> GetGroupSalesQuoteNo()
  677. {
  678. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  679. if (groupData.Code != 0)
  680. {
  681. return Ok(JsonView(false, groupData.Msg));
  682. }
  683. object salesQuoteNo = new
  684. {
  685. SalesQuoteNo = groupData.Data
  686. };
  687. return Ok(JsonView(salesQuoteNo));
  688. }
  689. /// <summary>
  690. /// 设置确认出团
  691. /// </summary>
  692. /// <param name="dto"></param>
  693. /// <returns></returns>
  694. [HttpPost]
  695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  696. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  697. {
  698. var groupData = await _groupRepository.ConfirmationGroup(dto);
  699. if (groupData.Code != 0)
  700. {
  701. return Ok(JsonView(false, groupData.Msg));
  702. }
  703. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  704. #region OA消息推送
  705. try
  706. {
  707. string groupName = groupInfo.TeamName;
  708. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  709. List<int> userIds = new List<int>();
  710. listUser.ForEach(s => userIds.Add(s.Id));
  711. string title = $"系统通知";
  712. string content = $"团组[{groupName}]已确认出团!";
  713. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  714. }
  715. catch (Exception ex)
  716. {
  717. }
  718. #endregion
  719. #region 应用推送
  720. try
  721. {
  722. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  723. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  724. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  725. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  726. {
  727. List<string> userList = new List<string>() { users.QiyeChatUserId };
  728. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  729. }
  730. }
  731. catch (Exception ex)
  732. {
  733. }
  734. #endregion
  735. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  736. return Ok(JsonView(true, "操作成功!", groupData.Data));
  737. }
  738. /// <summary>
  739. /// 获取团组名称data And 签证国别Data
  740. /// </summary>
  741. /// <param name="dto"></param>
  742. /// <returns></returns>
  743. [HttpPost]
  744. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  745. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  746. {
  747. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  748. if (groupData.Code != 0)
  749. {
  750. return Ok(JsonView(false, groupData.Msg));
  751. }
  752. return Ok(JsonView(groupData.Data));
  753. }
  754. /// <summary>
  755. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  756. /// </summary>
  757. /// <returns></returns>
  758. [HttpPost]
  759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  760. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  761. {
  762. try
  763. {
  764. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  765. if (groupData.Code != 0)
  766. {
  767. return Ok(JsonView(false, groupData.Msg));
  768. }
  769. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  770. }
  771. catch (Exception ex)
  772. {
  773. return Ok(JsonView(false, "程序错误!"));
  774. throw;
  775. }
  776. }
  777. #endregion
  778. #region 团组&签证
  779. /// <summary>
  780. /// 根据团组Id获取签证客户信息List
  781. /// </summary>
  782. /// <param name="dto">请求dto</param>
  783. /// <returns></returns>
  784. [HttpPost]
  785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  786. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  787. {
  788. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  789. if (groupData.Code != 0)
  790. {
  791. return Ok(JsonView(false, groupData.Msg));
  792. }
  793. return Ok(JsonView(groupData.Data));
  794. }
  795. /// <summary>
  796. /// IOS获取团组签证拍照上传进度01(团组列表)
  797. /// </summary>
  798. /// <param name="dto">请求dto</param>
  799. /// <returns></returns>
  800. [HttpPost]
  801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  802. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  803. {
  804. if (dto == null)
  805. {
  806. return Ok(JsonView(false, "参数为空"));
  807. }
  808. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  809. return Ok(JsonView(visaList));
  810. }
  811. /// <summary>
  812. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  813. /// </summary>
  814. /// <returns></returns>
  815. [HttpPost]
  816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  817. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  818. {
  819. if (dto == null)
  820. {
  821. return Ok(JsonView(false, "请求错误:"));
  822. }
  823. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  824. return Ok(JsonView(list));
  825. }
  826. /// <summary>
  827. /// IOS获取团组签证拍照上传进度03(相册)
  828. /// </summary>
  829. /// <returns></returns>
  830. [HttpPost]
  831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  832. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  833. {
  834. if (dto == null)
  835. {
  836. return Ok(JsonView(false, "请求错误:"));
  837. }
  838. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  839. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  840. list.ForEach(s => s.url = url);
  841. return Ok(JsonView(list));
  842. }
  843. /// <summary>
  844. /// IOS获取团组签证拍照上传进度04(图片上传)
  845. /// </summary>
  846. /// <param name="dto"></param>
  847. /// <returns></returns>
  848. [HttpPost]
  849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  850. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  851. {
  852. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  853. //if (!string.IsNullOrEmpty(result))
  854. //{
  855. //}
  856. //else {
  857. // return Ok(JsonView(false, "上传失败"));
  858. //}
  859. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  860. int sucNum = 0;
  861. try
  862. {
  863. foreach (var item in dto.base64DataList)
  864. {
  865. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  866. string result = decodeBase64ToImage(item, imageName);
  867. if (!string.IsNullOrEmpty(result))
  868. {
  869. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  870. pic.CreateUserId = dto.CreateUserId;
  871. pic.PicName = imageName;
  872. pic.PicPath = result;
  873. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  874. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  875. if (insertResult > 0)
  876. {
  877. sucNum++;
  878. }
  879. }
  880. }
  881. }
  882. catch (Exception ex)
  883. {
  884. return Ok(JsonView(false, ex.Message));
  885. }
  886. string msg = string.Format(@"成功上传{0}张", sucNum);
  887. return Ok(JsonView(true, msg));
  888. }
  889. private string decodeBase64ToImage(string base64DataURL, string imgName)
  890. {
  891. string filename = "";//声明一个string类型的相对路径
  892. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  893. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  894. try//会有异常抛出,try,catch一下
  895. {
  896. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  897. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  898. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  899. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  900. //文件名称
  901. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  902. //上传的文件的路径
  903. string filePath = "";
  904. if (!Directory.Exists(fileDir))
  905. {
  906. Directory.CreateDirectory(fileDir);
  907. }
  908. //上传的文件的路径
  909. filePath = fileDir + filename;
  910. //string url = HttpRuntime.AppDomainAppPath.ToString();
  911. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  912. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  913. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  914. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  915. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  916. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  917. ms.Close();//关闭当前流,并释放所有与之关联的资源
  918. bitmap.Dispose();
  919. }
  920. catch (Exception e)
  921. {
  922. string massage = e.Message;
  923. Logs("IOS图片上传Error:" + massage);
  924. //filename = e.Message;
  925. }
  926. return filename;//返回相对路径
  927. }
  928. /// <summary>
  929. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  930. /// </summary>
  931. /// <param name="dto"></param>
  932. /// <returns></returns>
  933. [HttpPost]
  934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  935. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  936. {
  937. if (dto == null)
  938. {
  939. return Ok(JsonView(false, "请求错误:"));
  940. }
  941. string msg = "参数错误";
  942. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  943. {
  944. try
  945. {
  946. //_delegationVisaRep.BeginTran();
  947. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  948. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  949. .Where(s => s.Id == dto.visaProgressCustomerId)
  950. .ExecuteCommandAsync();
  951. if (updCount > 0 && dto.publishCode == 1)
  952. {
  953. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  954. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  955. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  956. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  957. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  958. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  959. if (groupData == null)
  960. {
  961. _delegationVisaRep.RollbackTran();
  962. }
  963. string title = string.Format(@"[签证进度更新]");
  964. string content = string.Format(@"测试文本");
  965. bool rst = await _message.AddMsg(new MessageDto()
  966. {
  967. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  968. IssuerId = dto.publisher,
  969. Title = title,
  970. Content = content,
  971. ReleaseTime = DateTime.Now,
  972. UIdList = new List<int> {
  973. 234
  974. }
  975. });
  976. if (rst)
  977. {
  978. return Ok(JsonView(true, "发送通知成功"));
  979. }
  980. }
  981. //_delegationVisaRep.CommitTran();
  982. }
  983. catch (Exception)
  984. {
  985. //_delegationVisaRep.RollbackTran();
  986. }
  987. }
  988. return Ok(JsonView(true, msg));
  989. }
  990. #endregion
  991. #region 团组任务分配
  992. /// <summary>
  993. /// 团组任务分配初始化
  994. /// </summary>
  995. /// <param name="dto"></param>
  996. /// <returns></returns>
  997. [HttpPost]
  998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  999. public async Task<IActionResult> GetTaskAssignmen()
  1000. {
  1001. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1002. if (groupData.Code != 0)
  1003. {
  1004. return Ok(JsonView(false, groupData.Msg));
  1005. }
  1006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1007. }
  1008. /// <summary>
  1009. /// 团组任务分配查询
  1010. /// </summary>
  1011. /// <param name="dto"></param>
  1012. /// <returns></returns>
  1013. [HttpPost]
  1014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1015. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1016. {
  1017. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1018. if (groupData.Code != 0)
  1019. {
  1020. return Ok(JsonView(false, groupData.Msg));
  1021. }
  1022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1023. }
  1024. /// <summary>
  1025. /// 团组任务分配操作
  1026. /// </summary>
  1027. /// <param name="dto"></param>
  1028. /// <returns></returns>
  1029. [HttpPost]
  1030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1031. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1032. {
  1033. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1034. if (groupData.Code != 0)
  1035. {
  1036. return Ok(JsonView(false, groupData.Msg));
  1037. }
  1038. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1039. }
  1040. /// <summary>
  1041. /// 团组任务分配
  1042. /// 批量分配
  1043. /// 查询团组
  1044. /// </summary>
  1045. /// <param name="dto"></param>
  1046. /// <returns></returns>
  1047. [HttpPost]
  1048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1049. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1050. {
  1051. //参数验证
  1052. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1053. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1054. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1055. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1056. }
  1057. /// <summary>
  1058. /// 团组任务分配
  1059. /// 批量分配
  1060. /// </summary>
  1061. /// <param name="dto"></param>
  1062. /// <returns></returns>
  1063. [HttpPost]
  1064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1065. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1066. {
  1067. //参数验证
  1068. if (dto.UserIds.Length < 1 ) return Ok(JsonView(false, $"请选择分配人员!"));
  1069. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1070. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1071. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1072. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1073. }
  1074. #endregion
  1075. #region 团组费用审核
  1076. /// <summary>
  1077. /// 费用审核
  1078. /// 团组列表 Page
  1079. /// </summary>
  1080. /// <param name="_dto">团组列表请求dto</param>
  1081. /// <returns></returns>
  1082. [HttpPost]
  1083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1084. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1085. {
  1086. #region 参数验证
  1087. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1088. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1089. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1090. #region 页面操作权限验证
  1091. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1092. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1093. #endregion
  1094. #endregion
  1095. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1096. {
  1097. string sqlWhere = string.Empty;
  1098. if (_dto.IsSure == 0) //未完成
  1099. {
  1100. sqlWhere += string.Format(@" And IsSure = 0");
  1101. }
  1102. else if (_dto.IsSure == 1) //已完成
  1103. {
  1104. sqlWhere += string.Format(@" And IsSure = 1");
  1105. }
  1106. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1107. {
  1108. string tj = _dto.SearchCriteria;
  1109. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  1110. tj, tj, tj, tj, tj);
  1111. }
  1112. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1113. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1114. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1115. From (
  1116. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1117. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1118. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1119. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1120. From Grp_DelegationInfo gdi
  1121. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1122. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1123. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1124. Where gdi.IsDel = 0 {0}
  1125. ) temp ", sqlWhere);
  1126. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1127. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1128. var _view = new
  1129. {
  1130. PageFuncAuth = pageFunAuthView,
  1131. Data = _DelegationList
  1132. };
  1133. return Ok(JsonView(true, "查询成功!", _view, total));
  1134. }
  1135. else
  1136. {
  1137. return Ok(JsonView(false, "查询失败"));
  1138. }
  1139. }
  1140. /// <summary>
  1141. /// 获取团组费用审核
  1142. /// </summary>
  1143. /// <param name="paras">参数Json字符串</param>
  1144. /// <returns></returns>
  1145. [HttpPost]
  1146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1147. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1148. {
  1149. try
  1150. {
  1151. #region 参数验证
  1152. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1153. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1154. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1155. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1156. #region 页面操作权限验证
  1157. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1158. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1159. #endregion
  1160. #endregion
  1161. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1162. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1163. #region 费用清单
  1164. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1165. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1166. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1167. List<Grp_CreditCardPayment> entityList = _groupRepository
  1168. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1169. .Where(exp.ToExpression())
  1170. .ToList();
  1171. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1172. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1173. /*
  1174. * 76://酒店预订
  1175. */
  1176. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1177. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1178. .ToListAsync();
  1179. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1180. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1181. .ToListAsync();
  1182. /*
  1183. * 79://车/导游地接
  1184. */
  1185. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1186. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1187. .ToListAsync();
  1188. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1189. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1190. .ToListAsync();
  1191. /*
  1192. * 80: //签证
  1193. */
  1194. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1195. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1196. .ToListAsync();
  1197. /*
  1198. *81: //邀请/公务活动
  1199. */
  1200. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1201. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1202. .ToListAsync();
  1203. /*
  1204. * 82: //团组客户保险
  1205. */
  1206. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1207. /*
  1208. * Lable = 85 机票预订
  1209. */
  1210. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1211. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1212. .ToListAsync();
  1213. /*
  1214. * 85 机票预定
  1215. */
  1216. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1217. /*
  1218. * 98 其他款项
  1219. */
  1220. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1221. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1222. .ToListAsync();
  1223. /*
  1224. * 285:收款退还
  1225. */
  1226. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1227. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1228. .ToListAsync();
  1229. /*
  1230. * 1015: //超支费用
  1231. */
  1232. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1233. /*
  1234. * 币种信息
  1235. */
  1236. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1237. /*
  1238. * 车/导游地接 费用类型
  1239. */
  1240. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1241. /*
  1242. * 车/导游地接 费用类型
  1243. */
  1244. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1245. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1246. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1247. /*
  1248. * 用户信息
  1249. */
  1250. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1251. /*
  1252. * 费用模块
  1253. */
  1254. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1255. string priceModule = string.Empty;
  1256. if (sdPriceName != null)
  1257. {
  1258. priceModule = sdPriceName.Name;
  1259. }
  1260. /*
  1261. * 成本信息
  1262. */
  1263. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1264. decimal _groupRate = 0.0000M;
  1265. string _groupCurrencyCode = "-";
  1266. if (groupCost != null)
  1267. {
  1268. _groupRate = groupCost.Rate;
  1269. if (int.TryParse(groupCost.Currency, out int _currency))
  1270. {
  1271. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1272. }
  1273. else _groupCurrencyCode = groupCost.Currency;
  1274. }
  1275. string costContentSql = $"Select * From Grp_GroupCost";
  1276. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1277. //处理日期为空的天数
  1278. for (int i = 0; i < groupCostDetails.Count; i++)
  1279. if (i != 0)
  1280. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1281. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1282. /*
  1283. * 处理详情数据
  1284. */
  1285. foreach (var entity in entityList)
  1286. {
  1287. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1288. _detail.Id = entity.Id;
  1289. _detail.PriceName = priceModule;
  1290. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1291. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1292. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1293. /*
  1294. * 应付款金额
  1295. */
  1296. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1297. string PaymentCurrency_WaitPay = "Unknown";
  1298. string hotelCurrncyCode = "Unknown";
  1299. string hotelCurrncyName = "Unknown";
  1300. if (sdPaymentCurrency_WaitPay != null)
  1301. {
  1302. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1303. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1304. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1305. if (hotelCurrncyCode.Equals("CNY"))
  1306. {
  1307. entity.DayRate = 1.0000M;
  1308. }
  1309. }
  1310. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1311. /*
  1312. * 此次付款金额
  1313. */
  1314. decimal CurrPayStr = 0;
  1315. if (entity.PayPercentage == 0)
  1316. {
  1317. if (entity.PayThenMoney != 0)
  1318. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1319. }
  1320. else
  1321. {
  1322. if (entity.PayMoney != 0)
  1323. {
  1324. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1325. }
  1326. }
  1327. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1328. /*
  1329. * 剩余尾款
  1330. */
  1331. decimal BalanceStr = 0;
  1332. if (CurrPayStr != 0)
  1333. {
  1334. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1335. BalanceStr = 0;
  1336. else
  1337. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1338. }
  1339. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1340. /*
  1341. * Bus名称
  1342. */
  1343. _detail.BusName = "待增加";
  1344. /*
  1345. *费用所属
  1346. */
  1347. switch (entity.CTable)
  1348. {
  1349. case 76://酒店预订
  1350. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1351. if (hotelReservations != null)
  1352. {
  1353. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1354. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1355. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1356. string roomFeeStr = "", roomFeestr1 = "";
  1357. //是否比较房型价格
  1358. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1359. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1360. roomFeeStr += $"<br/>";
  1361. if (hotelReservations.SingleRoomPrice > 0)
  1362. {
  1363. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1364. __isSingle = true;
  1365. }
  1366. if (hotelReservations.DoubleRoomPrice > 0)
  1367. {
  1368. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1369. __isDouble = true;
  1370. }
  1371. if (hotelReservations.SuiteRoomPrice > 0)
  1372. {
  1373. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1374. __isSuite = true;
  1375. }
  1376. if (hotelReservations.OtherRoomPrice > 0)
  1377. {
  1378. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1379. __isOther = true;
  1380. }
  1381. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1382. else roomFeeStr += " 0.00 * 0";
  1383. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1384. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1385. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1386. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1387. /*
  1388. * 费用类型
  1389. * 1:房费
  1390. * 2:早餐
  1391. * 3:地税
  1392. * 4:城市税
  1393. * </summary>
  1394. */
  1395. //地税
  1396. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1397. if (governmentRentData != null)
  1398. {
  1399. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1400. governmentRentFee = governmentRentData.Price;
  1401. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1402. if (governmentRentCurrData != null)
  1403. {
  1404. governmentRentCode = governmentRentCurrData.Name;
  1405. governmentRentName = $"({governmentRentCurrData.Remark})";
  1406. }
  1407. }
  1408. //城市税
  1409. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1410. if (cityTaxData != null)
  1411. {
  1412. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1413. cityTaxFee = cityTaxData.Price;
  1414. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1415. if (cityTaxCurrData != null)
  1416. {
  1417. cityTaxCode = cityTaxCurrData.Name;
  1418. cityTaxName = $"({cityTaxCurrData.Remark})";
  1419. }
  1420. }
  1421. //酒店早餐
  1422. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1423. if (breakfastData != null)
  1424. {
  1425. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1426. breakfastFee = breakfastData.Price;
  1427. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1428. if (breakfastCurrData != null)
  1429. {
  1430. breakfastCode = breakfastCurrData.Name;
  1431. breakfastName = $"({breakfastCurrData.Remark})";
  1432. }
  1433. }
  1434. //房间费用
  1435. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1436. if (roomData != null)
  1437. {
  1438. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1439. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1440. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1441. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1442. roomFee = roomData.Price;
  1443. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1444. if (roomCurrData != null)
  1445. {
  1446. roomCode = roomCurrData.Name;
  1447. roomName = $"({roomCurrData.Remark})";
  1448. }
  1449. }
  1450. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1451. string hotelCostStr = "";
  1452. decimal hotelCsotTotal = 0.00M;
  1453. if (groupCost != null)
  1454. {
  1455. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1456. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1457. }
  1458. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1459. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1460. string hotelCost_day = "";
  1461. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1462. foreach (var item in hotelCostDetails1)
  1463. {
  1464. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1465. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1466. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1467. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1468. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1469. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1470. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1471. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1472. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1473. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1474. hotelCost_day += @$"</br>";
  1475. }
  1476. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1477. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1478. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1479. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1480. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1481. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1482. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1483. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1484. $"房间说明: {hotelReservations.Remark} <br/>" +
  1485. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1486. $"{hotelBreakfastStr}" +
  1487. $"{hotelGovernmentRentStr}" +
  1488. $"{hotelCityTaxStr}";
  1489. _detail.PriceNameContent = hotelReservations.HotelName;
  1490. }
  1491. break;
  1492. case 79://车/导游地接
  1493. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1494. if (touristGuideGroundReservations != null)
  1495. {
  1496. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1497. {
  1498. _detail.BusName = touristGuideGroundReservations.BusName;
  1499. }
  1500. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1501. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1502. //if (isInt)
  1503. //{
  1504. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1505. // if (cityInfo != null)
  1506. // {
  1507. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1508. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1509. // if (carFeeItem != null)
  1510. // {
  1511. // nameContent += $@"({carFeeItem.Name})";
  1512. // }
  1513. // _detail.PriceNameContent = nameContent;
  1514. // }
  1515. //}
  1516. //else
  1517. //{
  1518. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1519. //}
  1520. var touristGuideGroundReservationsContents =
  1521. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1522. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1523. foreach (var item in touristGuideGroundReservationsContents)
  1524. {
  1525. string typeName = "Unknown";
  1526. string carCurrencyCode = "Unknown";
  1527. string carCurrencyName = "Unknown";
  1528. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1529. if (carTypeData != null) typeName = carTypeData.Name;
  1530. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1531. if (currencyData != null)
  1532. {
  1533. carCurrencyCode = currencyData.Name;
  1534. carCurrencyName = currencyData.Remark;
  1535. }
  1536. //op、成本 币种是否一致
  1537. bool IsCurrencyAgreement = false;
  1538. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1539. string opCostStr = string.Empty;
  1540. decimal opCostTypePrice = 0.00M;
  1541. #region 处理成本各项费用
  1542. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1543. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1544. if (opCost.Count > 0)
  1545. {
  1546. switch (item.SId)
  1547. {
  1548. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1549. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1550. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1551. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1552. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1553. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1554. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1555. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1556. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1557. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1558. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1559. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1560. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1561. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1562. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1563. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1564. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1565. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1566. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1567. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1568. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1569. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1570. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1571. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1572. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1573. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1574. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1575. }
  1576. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1577. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1578. }
  1579. #endregion
  1580. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1581. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1582. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1583. $"{opTypeStr} {opCostStr}<br/>" +
  1584. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1585. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1586. }
  1587. _detail.PriceMsgContent = priceMsg;
  1588. }
  1589. break;
  1590. case 80: //签证
  1591. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1592. if (visaInfo != null)
  1593. {
  1594. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1595. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1596. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1597. }
  1598. break;
  1599. case 81: //邀请/公务活动
  1600. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1601. if (_ioa != null)
  1602. {
  1603. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1604. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1605. sendCurrName = "Unknown", //快递费用币种 Name
  1606. sendCurrCode = "Unknown", //快递费用币种 Code
  1607. eventsCurrName = "Unknown", //公务活动费币种 Name
  1608. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1609. translateCurrName = "Unknown", //公务翻译费 Name
  1610. translateCurrCode = "Unknown"; //公务翻译费 Code
  1611. #region 处理费用币种
  1612. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1613. if (inviteCurrData != null)
  1614. {
  1615. inviteCurrName = inviteCurrData.Remark;
  1616. inviteCurrCode = inviteCurrData.Name;
  1617. }
  1618. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1619. if (sendCurrData != null)
  1620. {
  1621. sendCurrName = sendCurrData.Remark;
  1622. sendCurrCode = sendCurrData.Name;
  1623. }
  1624. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1625. if (eventsCurrData != null)
  1626. {
  1627. eventsCurrName = eventsCurrData.Remark;
  1628. eventsCurrCode = eventsCurrData.Name;
  1629. }
  1630. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1631. if (translateCurrData != null)
  1632. {
  1633. translateCurrName = translateCurrData.Remark;
  1634. translateCurrCode = translateCurrData.Name;
  1635. }
  1636. #endregion
  1637. _detail.PriceNameContent = _ioa.InviterArea;
  1638. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1639. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1640. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1641. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1642. $@"备注:" + _ioa.Remark + "<br/>";
  1643. }
  1644. break;
  1645. case 82: //团组客户保险
  1646. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1647. if (customers != null)
  1648. {
  1649. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1650. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1651. }
  1652. break;
  1653. case 85: //机票预订
  1654. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1655. if (jpRes != null)
  1656. {
  1657. string FlightsDescription = jpRes.FlightsDescription;
  1658. string PriceDescription = jpRes.PriceDescription;
  1659. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1660. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1661. }
  1662. break;
  1663. case 98://其他款项
  1664. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1665. if (gdpRes != null)
  1666. {
  1667. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1668. _detail.PriceNameContent = gdpRes.PriceName;
  1669. }
  1670. break;
  1671. case 285://收款退还
  1672. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1673. if (refundAndOtherMoney != null)
  1674. {
  1675. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1676. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1677. }
  1678. break;
  1679. case 751://酒店早餐
  1680. break;
  1681. case 1015://超支费用
  1682. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1683. if (groupExtraCost != null)
  1684. {
  1685. _detail.PriceNameContent = groupExtraCost.PriceName;
  1686. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1687. }
  1688. break;
  1689. default:
  1690. break;
  1691. }
  1692. /*
  1693. * 申请人
  1694. */
  1695. string operatorName = " - ";
  1696. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1697. if (_opUser != null)
  1698. {
  1699. operatorName = _opUser.CnName;
  1700. }
  1701. _detail.OperatorName = operatorName;
  1702. /*
  1703. * 审核人
  1704. */
  1705. string auditOperatorName = "Unknown";
  1706. if (entity.AuditGMOperate == 0)
  1707. auditOperatorName = " - ";
  1708. else if (entity.AuditGMOperate == 4)
  1709. auditOperatorName = "自动审核";
  1710. else
  1711. {
  1712. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1713. if (_adUser != null)
  1714. {
  1715. auditOperatorName = _adUser.CnName;
  1716. }
  1717. }
  1718. _detail.AuditOperatorName = auditOperatorName;
  1719. /*
  1720. * 超预算比例
  1721. */
  1722. string overBudgetStr = "";
  1723. if (entity.ExceedBudget == -1)
  1724. overBudgetStr = sdPriceName.Name + "尚无预算";
  1725. else if (entity.ExceedBudget == 0)
  1726. {
  1727. if (entity.CTable == 76 || entity.CTable == 79)
  1728. {
  1729. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1730. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1731. }
  1732. else
  1733. {
  1734. overBudgetStr = "未超预算";
  1735. }
  1736. }
  1737. else
  1738. overBudgetStr = entity.ExceedBudget.ToString("P");
  1739. _detail.OverBudget = overBudgetStr;
  1740. /*
  1741. * 已审核金额
  1742. */
  1743. decimal auditFee = 0.00M;
  1744. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3) auditFee = CurrPayStr;
  1745. /*
  1746. * 费用总计
  1747. */
  1748. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1749. {
  1750. CurrencyId = entity.PaymentCurrency,
  1751. CurrencyName = PaymentCurrency_WaitPay,
  1752. AmountPayable = entity.PayMoney,
  1753. ThisPayment = CurrPayStr,
  1754. BalancePayment = BalanceStr,
  1755. AuditedFunds = auditFee
  1756. });
  1757. _detail.IsAuditGM = entity.IsAuditGM;
  1758. detailList.Add(_detail);
  1759. }
  1760. #endregion
  1761. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1762. /*
  1763. * 下方描述处理
  1764. */
  1765. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1766. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1767. if (ccpCurrencyPrice != null)
  1768. {
  1769. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1770. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1771. }
  1772. else
  1773. {
  1774. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1775. }
  1776. string amountPayableStr = string.Format(@"应付款总金额: ");
  1777. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1778. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1779. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1780. foreach (var item in nonDuplicat)
  1781. {
  1782. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1783. if (strs.Count > 0)
  1784. {
  1785. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1786. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1787. amountPayableStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", amountPayable.ToString("#0.00"), item.CurrencyName);
  1788. //单独处理此次付款金额
  1789. if (item.CurrencyId == 836) //人民币
  1790. {
  1791. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1792. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", thisPayment.ToString("#0.00"), item.CurrencyName);
  1793. }
  1794. else
  1795. {
  1796. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", "0.00", item.CurrencyName);
  1797. }
  1798. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|&nbsp;", balancePayment.ToString("#0.00"), item.CurrencyName);
  1799. //单独处理已审核费用
  1800. if (item.CurrencyId == 836) //人民币
  1801. {
  1802. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1803. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1804. }
  1805. else
  1806. {
  1807. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1808. }
  1809. }
  1810. }
  1811. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1812. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1813. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1814. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1815. var _view1 = new
  1816. {
  1817. PageFuncAuth = pageFunAuthView,
  1818. Data = _view
  1819. };
  1820. return Ok(JsonView(_view1));
  1821. }
  1822. catch (Exception ex)
  1823. {
  1824. return Ok(JsonView(false, ex.Message));
  1825. }
  1826. }
  1827. /// <summary>
  1828. /// 费用审核
  1829. /// 修改团组费用审核状态
  1830. /// </summary>
  1831. /// <param name="_dto">参数Json字符串</param>
  1832. /// <returns></returns>
  1833. [HttpPost]
  1834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1835. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1836. {
  1837. #region 参数验证
  1838. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1839. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1840. #endregion
  1841. #region 页面操作权限验证
  1842. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1843. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1844. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1845. #endregion
  1846. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1847. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1848. DateTime dtNow = DateTime.Now;
  1849. _groupRepository.BeginTran();
  1850. int rst = 0;
  1851. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1852. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1853. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1854. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1855. List<dynamic> msgDatas = new List<dynamic>();
  1856. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1857. foreach (var item in idList)
  1858. {
  1859. int CreditId = int.Parse(item);
  1860. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1861. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1862. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1863. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1864. .Where(s => s.Id == CreditId)
  1865. .ExecuteCommandAsync();
  1866. if (result < 1)
  1867. {
  1868. rst = -1;
  1869. _groupRepository.RollbackTran();
  1870. return Ok(JsonView(false, "操作失败并回滚!"));
  1871. }
  1872. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1873. if (creditData != null)
  1874. {
  1875. #region 应用通知配置
  1876. try
  1877. {
  1878. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1879. }
  1880. catch (Exception ex)
  1881. {
  1882. }
  1883. #endregion
  1884. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1885. string groupNameStr = string.Empty;
  1886. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1887. if (groupData != null) groupNameStr = groupData.TeamName;
  1888. string creditTypeStr = string.Empty;
  1889. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1890. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1891. string creditCurrency = string.Empty;
  1892. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1893. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1894. if (creditCurrency.Equals("CNY"))
  1895. {
  1896. creditData.DayRate = 1.0000M;
  1897. }
  1898. if (creditData.PayPercentage == 0.00M)
  1899. {
  1900. creditData.PayPercentage = 100M;
  1901. }
  1902. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1903. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1904. string msgContent = "";
  1905. if (creditCurrency.Equals("CNY"))
  1906. {
  1907. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1908. }
  1909. else
  1910. {
  1911. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1912. }
  1913. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1914. }
  1915. }
  1916. if (rst == 0)
  1917. {
  1918. _groupRepository.CommitTran();
  1919. foreach (var item in msgDatas)
  1920. {
  1921. //发送消息
  1922. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1923. }
  1924. #region 应用推送
  1925. try
  1926. {
  1927. foreach (var ccpId in dic_ccp_user.Keys)
  1928. {
  1929. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1930. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1931. }
  1932. }
  1933. catch (Exception)
  1934. {
  1935. }
  1936. #endregion
  1937. return Ok(JsonView(true, "操作成功!"));
  1938. }
  1939. return Ok(JsonView(false, "操作失败!"));
  1940. }
  1941. #endregion
  1942. #region 机票费用录入
  1943. /// <summary>
  1944. /// 机票录入当前登录人可操作团组
  1945. /// </summary>
  1946. /// <param name="dto"></param>
  1947. /// <returns></returns>
  1948. [HttpPost]
  1949. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1950. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1951. {
  1952. try
  1953. {
  1954. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1955. if (groupData.Code != 0)
  1956. {
  1957. return Ok(JsonView(false, groupData.Msg));
  1958. }
  1959. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1960. }
  1961. catch (Exception ex)
  1962. {
  1963. return Ok(JsonView(false, "程序错误!"));
  1964. throw;
  1965. }
  1966. }
  1967. /// <summary>
  1968. /// 机票费用录入列表
  1969. /// </summary>
  1970. /// <param name="dto"></param>
  1971. /// <returns></returns>
  1972. [HttpPost]
  1973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1974. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1975. {
  1976. try
  1977. {
  1978. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1979. if (groupData.Code != 0)
  1980. {
  1981. return Ok(JsonView(false, groupData.Msg));
  1982. }
  1983. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1984. }
  1985. catch (Exception ex)
  1986. {
  1987. return Ok(JsonView(false, ex.Message));
  1988. throw;
  1989. }
  1990. }
  1991. /// <summary>
  1992. /// 根据id查询费用录入信息
  1993. /// </summary>
  1994. /// <param name="dto"></param>
  1995. /// <returns></returns>
  1996. [HttpPost]
  1997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1998. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1999. {
  2000. try
  2001. {
  2002. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2003. if (groupData.Code != 0)
  2004. {
  2005. return Ok(JsonView(false, groupData.Msg));
  2006. }
  2007. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2008. }
  2009. catch (Exception ex)
  2010. {
  2011. return Ok(JsonView(false, "程序错误!"));
  2012. throw;
  2013. }
  2014. }
  2015. /// <summary>
  2016. /// 机票费用录入操作(Status:1.新增,2.修改)
  2017. /// </summary>
  2018. /// <param name="dto"></param>
  2019. /// <returns></returns>
  2020. [HttpPost]
  2021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2022. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2023. {
  2024. try
  2025. {
  2026. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2027. if (groupData.Code != 0)
  2028. {
  2029. return Ok(JsonView(false, groupData.Msg));
  2030. }
  2031. #region 应用推送
  2032. try
  2033. {
  2034. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2035. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2036. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2037. }
  2038. catch (Exception ex)
  2039. {
  2040. }
  2041. #endregion
  2042. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2043. }
  2044. catch (Exception ex)
  2045. {
  2046. return Ok(JsonView(false, "程序错误!"));
  2047. throw;
  2048. }
  2049. }
  2050. /// <summary>
  2051. /// 根据舱位类型查询接团客户名单信息
  2052. /// </summary>
  2053. /// <param name="dto"></param>
  2054. /// <returns></returns>
  2055. [HttpPost]
  2056. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2057. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2058. {
  2059. try
  2060. {
  2061. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2062. if (crm_Groups.Count != 0)
  2063. {
  2064. List<dynamic> Customer = new List<dynamic>();
  2065. foreach (var item in crm_Groups)
  2066. {
  2067. var data = new
  2068. {
  2069. Id = item.Id,
  2070. Pinyin = item.Pinyin,
  2071. Name = item.LastName + item.FirstName
  2072. };
  2073. Customer.Add(data);
  2074. }
  2075. return Ok(JsonView(true, "查询成功!", Customer));
  2076. }
  2077. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2078. }
  2079. catch (Exception ex)
  2080. {
  2081. return Ok(JsonView(false, "程序错误!"));
  2082. throw;
  2083. }
  2084. }
  2085. /// <summary>
  2086. /// 根据团号获取客户信息
  2087. /// </summary>
  2088. /// <param name="dto"></param>
  2089. /// <returns></returns>
  2090. [HttpPost]
  2091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2092. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2093. {
  2094. var jw = JsonView(false);
  2095. if (dto.DIID < 1)
  2096. {
  2097. jw.Msg += "请输入正确的diid";
  2098. return Ok(jw);
  2099. }
  2100. var arr = getSimplClientList(dto.DIID);
  2101. jw = JsonView(true, "获取成功!", arr);
  2102. return Ok(jw);
  2103. }
  2104. private List<SimplClientInfo> getSimplClientList(int diId)
  2105. {
  2106. string sql = string.Format("select b.Id,b.Pinyin,b.lastName,b.firstName,b.phone from Grp_TourClientList a, Crm_DeleClient b where a.clientid = b.id and a.isdel = 0 and a.diid = {0}", diId);
  2107. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2108. return arr;
  2109. }
  2110. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2111. {
  2112. string result = origin;
  2113. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2114. {
  2115. string[] temparr = origin.Split(',');
  2116. string fistrStr = temparr[0];
  2117. int count = temparr.Count();
  2118. int tempId;
  2119. bool success = int.TryParse(fistrStr, out tempId);
  2120. if (success)
  2121. {
  2122. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2123. if (tempInfo != null)
  2124. {
  2125. if (count > 1)
  2126. {
  2127. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2128. }
  2129. else
  2130. {
  2131. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2132. }
  2133. }
  2134. }
  2135. }
  2136. return result;
  2137. }
  2138. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2139. {
  2140. string result = origin;
  2141. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2142. {
  2143. string[] temparr = origin.Split(',');
  2144. result = "";
  2145. foreach (var item in temparr)
  2146. {
  2147. int tempId;
  2148. bool success = int.TryParse(item, out tempId);
  2149. if (success)
  2150. {
  2151. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2152. if (tempInfo != null)
  2153. {
  2154. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2155. }
  2156. }
  2157. }
  2158. }
  2159. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2160. return result;
  2161. }
  2162. /// <summary>
  2163. /// 机票费用录入,删除
  2164. /// </summary>
  2165. /// <param name="dto"></param>
  2166. /// <returns></returns>
  2167. [HttpPost]
  2168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2169. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2170. {
  2171. try
  2172. {
  2173. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2174. if (res)
  2175. {
  2176. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2177. {
  2178. IsDel = 1,
  2179. DeleteUserId = dto.DeleteUserId,
  2180. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2181. }).ExecuteCommandAsync();
  2182. return Ok(JsonView(true, "删除成功!"));
  2183. }
  2184. return Ok(JsonView(false, "删除失败!"));
  2185. }
  2186. catch (Exception ex)
  2187. {
  2188. return Ok(JsonView(false, "程序错误!"));
  2189. throw;
  2190. }
  2191. }
  2192. /// <summary>
  2193. /// 导出机票录入报表
  2194. /// </summary>
  2195. /// <param name="dto"></param>
  2196. /// <returns></returns>
  2197. [HttpPost]
  2198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2199. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2200. {
  2201. try
  2202. {
  2203. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2204. if (groupData.Code != 0)
  2205. {
  2206. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2207. }
  2208. else
  2209. {
  2210. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2211. if (AirTicketReservations.Count != 0)
  2212. {
  2213. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2214. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2215. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2216. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2217. WorkbookDesigner designer = new WorkbookDesigner();
  2218. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2219. decimal countCost = 0;
  2220. foreach (var item in AirTicketReservations)
  2221. {
  2222. #region 处理客人姓名
  2223. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2224. item.ClientName = clientNames;
  2225. #endregion
  2226. if (item.BankType == "其他")
  2227. {
  2228. item.BankNo = "--";
  2229. }
  2230. else
  2231. {
  2232. if (!string.IsNullOrEmpty(item.BankType))
  2233. {
  2234. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2235. }
  2236. }
  2237. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2238. item.Price = System.Decimal.Round(item.Price, 2);
  2239. countCost += Convert.ToDecimal(item.Price);
  2240. }
  2241. designer.SetDataSource("Export", AirTicketReservations);
  2242. designer.SetDataSource("ExportDiCode", diCode);
  2243. designer.SetDataSource("ExportDiName", diName);
  2244. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2245. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2246. designer.Process();
  2247. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2248. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2249. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2250. return Ok(JsonView(true, "成功", url = rst));
  2251. }
  2252. else
  2253. {
  2254. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2255. }
  2256. }
  2257. }
  2258. catch (Exception ex)
  2259. {
  2260. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2261. throw;
  2262. }
  2263. }
  2264. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2265. /// <summary>
  2266. /// 行程单导出
  2267. /// </summary>
  2268. /// <param name="dto"></param>
  2269. /// <returns></returns>
  2270. [HttpPost]
  2271. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2272. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2273. {
  2274. try
  2275. {
  2276. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2277. if (groupData.Code != 0)
  2278. {
  2279. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2280. }
  2281. else
  2282. {
  2283. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2284. if (dto.Language == "CN")
  2285. {
  2286. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2287. DocumentBuilder builder = new DocumentBuilder(doc);
  2288. int tableIndex = 0;//表格索引
  2289. //得到文档中的第一个表格
  2290. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2291. foreach (var item in _AirTicketReservations)
  2292. {
  2293. #region 处理固定数据
  2294. string[] FlightsCode = item.FlightsCode.Split('/');
  2295. if (FlightsCode.Length != 0)
  2296. {
  2297. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2298. if (_AirCompany != null)
  2299. {
  2300. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2301. }
  2302. else
  2303. {
  2304. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2305. }
  2306. }
  2307. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2308. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2309. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2310. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2311. string name = "";
  2312. foreach (string clientName in nameArray)
  2313. {
  2314. if (!name.Contains(clientName))
  2315. {
  2316. name += clientName + ",";
  2317. }
  2318. }
  2319. if (!string.IsNullOrWhiteSpace(name))
  2320. {
  2321. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2322. }
  2323. else
  2324. {
  2325. table.Range.Bookmarks["ClientName"].Text = "--";
  2326. }
  2327. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2328. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2329. table.Range.Bookmarks["JointTicket"].Text = "--";
  2330. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2331. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2332. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2333. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2334. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2335. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2336. #endregion
  2337. #region 循环数据处理
  2338. List<AirInfo> airs = new List<AirInfo>();
  2339. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2340. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2341. for (int i = 0; i < FlightsCode.Length; i++)
  2342. {
  2343. AirInfo air = new AirInfo();
  2344. string[] tempstr = DayArray[i]
  2345. .Replace("\r\n", string.Empty)
  2346. .Replace("\\r\\n", string.Empty)
  2347. .TrimStart().TrimEnd()
  2348. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2349. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2350. string starCity = "";
  2351. if (star_Three != null)
  2352. {
  2353. starCity = star_Three.AirPort;
  2354. }
  2355. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2356. string EndCity = "";
  2357. if (End_Three != null)
  2358. {
  2359. EndCity = End_Three.AirPort;
  2360. }
  2361. air.Destination = starCity + "/" + EndCity;
  2362. air.Flight = FlightsCode[i];
  2363. air.SeatingClass = item.CTypeName;
  2364. string dateTime = tempstr[2];
  2365. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2366. air.FlightDate = DateTemp;
  2367. air.DepartureTime = tempstr[5];
  2368. air.LandingTime = tempstr[6];
  2369. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2370. air.TicketStatus = "--";
  2371. air.Luggage = "--";
  2372. air.DepartureTerminal = "--";
  2373. air.LandingTerminal = "--";
  2374. airs.Add(air);
  2375. }
  2376. int row = 13;
  2377. for (int i = 0; i < airs.Count; i++)
  2378. {
  2379. if (airs.Count > 2)
  2380. {
  2381. for (int j = 0; j < airs.Count - 2; j++)
  2382. {
  2383. var CopyRow = table.Rows[12].Clone(true);
  2384. table.Rows.Add(CopyRow);
  2385. }
  2386. }
  2387. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2388. int index = 0;
  2389. foreach (PropertyInfo property in properties)
  2390. {
  2391. string value = property.GetValue(airs[i]).ToString();
  2392. Cell ishcel0 = table.Rows[row].Cells[index];
  2393. Paragraph p = new Paragraph(doc);
  2394. string s = value;
  2395. p.AppendChild(new Run(doc, s));
  2396. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2397. ishcel0.AppendChild(p);
  2398. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2399. index++;
  2400. }
  2401. row++;
  2402. }
  2403. #endregion
  2404. Paragraph lastParagraph = new Paragraph(doc);
  2405. //第一个表格末尾加段落
  2406. table.ParentNode.InsertAfter(lastParagraph, table);
  2407. //复制第一个表格
  2408. Table cloneTable = (Table)table.Clone(true);
  2409. //在文档末尾段落后面加入复制的表格
  2410. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2411. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2412. {
  2413. int rownewsIndex = 13;
  2414. for (int i = 0; i < 2; i++)
  2415. {
  2416. var CopyRow = table.Rows[12].Clone(true);
  2417. table.Rows.RemoveAt(13);
  2418. table.Rows.Add(CopyRow);
  2419. rownewsIndex++;
  2420. }
  2421. }
  2422. else
  2423. {
  2424. table.Rows.RemoveAt(12);
  2425. }
  2426. cloneTable.Rows.RemoveAt(12);
  2427. }
  2428. if (_AirTicketReservations.Count != 0)
  2429. {
  2430. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2431. if (FlightsCode.Length != 0)
  2432. {
  2433. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2434. if (_AirCompany != null)
  2435. {
  2436. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2437. }
  2438. else
  2439. {
  2440. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2441. }
  2442. }
  2443. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2444. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2445. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2446. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2447. string name = "";
  2448. foreach (string clientName in nameArray)
  2449. {
  2450. if (!name.Contains(clientName))
  2451. {
  2452. name += clientName + ",";
  2453. }
  2454. }
  2455. if (!string.IsNullOrWhiteSpace(name))
  2456. {
  2457. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2458. }
  2459. else
  2460. {
  2461. table.Range.Bookmarks["ClientName"].Text = "--";
  2462. }
  2463. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2464. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2465. table.Range.Bookmarks["JointTicket"].Text = "--";
  2466. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2467. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2468. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2469. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2470. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2471. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2472. }
  2473. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2474. //保存合并后的文档
  2475. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2476. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2477. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2478. return Ok(JsonView(true, "成功!", rst));
  2479. }
  2480. else
  2481. {
  2482. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2483. DocumentBuilder builder = new DocumentBuilder(doc);
  2484. int tableIndex = 0;//表格索引
  2485. //得到文档中的第一个表格
  2486. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2487. List<string> texts = new List<string>();
  2488. foreach (var item in _AirTicketReservations)
  2489. {
  2490. string[] FlightsCode = item.FlightsCode.Split('/');
  2491. if (FlightsCode.Length != 0)
  2492. {
  2493. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2494. if (_AirCompany != null)
  2495. {
  2496. if (!transDic.ContainsKey(_AirCompany.CnName))
  2497. {
  2498. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2499. }
  2500. }
  2501. else
  2502. {
  2503. if (!transDic.ContainsKey("--"))
  2504. {
  2505. transDic.Add("--", "--");
  2506. }
  2507. }
  2508. }
  2509. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2510. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2511. string name = "";
  2512. foreach (string clientName in nameArray)
  2513. {
  2514. name += clientName + ",";
  2515. }
  2516. if (!texts.Contains(name))
  2517. {
  2518. texts.Add(name);
  2519. }
  2520. List<AirInfo> airs = new List<AirInfo>();
  2521. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2522. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2523. for (int i = 0; i < FlightsCode.Length; i++)
  2524. {
  2525. AirInfo air = new AirInfo();
  2526. string[] tempstr = DayArray[i]
  2527. .Replace("\r\n", string.Empty)
  2528. .Replace("\\r\\n", string.Empty)
  2529. .TrimStart().TrimEnd()
  2530. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2531. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2532. if (star_Three != null)
  2533. {
  2534. if (!transDic.ContainsKey(star_Three.AirPort))
  2535. {
  2536. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2537. }
  2538. }
  2539. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2540. if (End_Three != null)
  2541. {
  2542. if (!transDic.ContainsKey(End_Three.AirPort))
  2543. {
  2544. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2545. }
  2546. }
  2547. if (!texts.Contains(item.CTypeName))
  2548. {
  2549. texts.Add(item.CTypeName);
  2550. }
  2551. }
  2552. }
  2553. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2554. if (transData.Count > 0)
  2555. {
  2556. foreach (TranslateResult item in transData)
  2557. {
  2558. if (!transDic.ContainsKey(item.Query))
  2559. {
  2560. transDic.Add(item.Query, item.Translation);
  2561. }
  2562. }
  2563. }
  2564. foreach (var item in _AirTicketReservations)
  2565. {
  2566. #region 处理固定数据
  2567. string[] FlightsCode = item.FlightsCode.Split('/');
  2568. if (FlightsCode.Length != 0)
  2569. {
  2570. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2571. if (_AirCompany != null)
  2572. {
  2573. string str = "--";
  2574. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2575. if (!string.IsNullOrEmpty(translateResult))
  2576. {
  2577. str = translateResult;
  2578. str = _airTicketResRep.Processing(str);
  2579. }
  2580. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2581. }
  2582. else
  2583. {
  2584. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2585. }
  2586. }
  2587. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2588. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2589. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2590. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2591. string names = "";
  2592. foreach (string clientName in nameArray)
  2593. {
  2594. names += clientName + ",";
  2595. }
  2596. if (!string.IsNullOrWhiteSpace(names))
  2597. {
  2598. string str = "--";
  2599. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2600. if (!string.IsNullOrEmpty(translateResult))
  2601. {
  2602. str = translateResult;
  2603. str = _airTicketResRep.Processing(str);
  2604. }
  2605. table.Range.Bookmarks["ClientName"].Text = str;
  2606. }
  2607. else
  2608. {
  2609. table.Range.Bookmarks["ClientName"].Text = "--";
  2610. }
  2611. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2612. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2613. table.Range.Bookmarks["JointTicket"].Text = "--";
  2614. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2615. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2616. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2617. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2618. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2619. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2620. #endregion
  2621. #region 循环数据处理
  2622. List<AirInfo> airs = new List<AirInfo>();
  2623. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2624. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2625. for (int i = 0; i < FlightsCode.Length; i++)
  2626. {
  2627. AirInfo air = new AirInfo();
  2628. string[] tempstr = DayArray[i]
  2629. .Replace("\r\n", string.Empty)
  2630. .Replace("\\r\\n", string.Empty)
  2631. .TrimStart().TrimEnd()
  2632. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2633. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2634. string starCity = "";
  2635. if (star_Three != null)
  2636. {
  2637. string str2 = "--";
  2638. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2639. if (!string.IsNullOrEmpty(translateResult2))
  2640. {
  2641. str2 = translateResult2;
  2642. str2 = _airTicketResRep.Processing(str2);
  2643. }
  2644. starCity = str2;
  2645. }
  2646. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2647. string EndCity = "";
  2648. if (End_Three != null)
  2649. {
  2650. string str1 = "--";
  2651. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2652. if (!string.IsNullOrEmpty(translateResult1))
  2653. {
  2654. str1 = translateResult1;
  2655. str1 = _airTicketResRep.Processing(str1);
  2656. }
  2657. EndCity = str1;
  2658. }
  2659. air.Destination = starCity + "/" + EndCity;
  2660. air.Flight = FlightsCode[i];
  2661. string str = "--";
  2662. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2663. if (!string.IsNullOrEmpty(translateResult))
  2664. {
  2665. str = translateResult;
  2666. str = _airTicketResRep.Processing(str);
  2667. }
  2668. air.SeatingClass = str;
  2669. string dateTime = tempstr[2];
  2670. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2671. air.FlightDate = DateTemp;
  2672. air.DepartureTime = tempstr[5];
  2673. air.LandingTime = tempstr[6];
  2674. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2675. air.TicketStatus = "--";
  2676. air.Luggage = "--";
  2677. air.DepartureTerminal = "--";
  2678. air.LandingTerminal = "--";
  2679. airs.Add(air);
  2680. }
  2681. int row = 13;
  2682. for (int i = 0; i < airs.Count; i++)
  2683. {
  2684. if (airs.Count > 2)
  2685. {
  2686. for (int j = 0; j < airs.Count - 2; j++)
  2687. {
  2688. var CopyRow = table.Rows[12].Clone(true);
  2689. table.Rows.Add(CopyRow);
  2690. }
  2691. }
  2692. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2693. int index = 0;
  2694. foreach (PropertyInfo property in properties)
  2695. {
  2696. string value = property.GetValue(airs[i]).ToString();
  2697. Cell ishcel0 = table.Rows[row].Cells[index];
  2698. Paragraph p = new Paragraph(doc);
  2699. string s = value;
  2700. p.AppendChild(new Run(doc, s));
  2701. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2702. ishcel0.AppendChild(p);
  2703. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2704. //ishcel0.CellFormat.VerticalAlignment=
  2705. index++;
  2706. }
  2707. row++;
  2708. }
  2709. #endregion
  2710. Paragraph lastParagraph = new Paragraph(doc);
  2711. //第一个表格末尾加段落
  2712. table.ParentNode.InsertAfter(lastParagraph, table);
  2713. //复制第一个表格
  2714. Table cloneTable = (Table)table.Clone(true);
  2715. //在文档末尾段落后面加入复制的表格
  2716. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2717. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2718. {
  2719. int rownewsIndex = 13;
  2720. for (int i = 0; i < 2; i++)
  2721. {
  2722. var CopyRow = table.Rows[12].Clone(true);
  2723. table.Rows.RemoveAt(13);
  2724. table.Rows.Add(CopyRow);
  2725. rownewsIndex++;
  2726. }
  2727. }
  2728. else
  2729. {
  2730. table.Rows.RemoveAt(12);
  2731. }
  2732. cloneTable.Rows.RemoveAt(12);
  2733. }
  2734. if (_AirTicketReservations.Count != 0)
  2735. {
  2736. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2737. if (FlightsCode.Length != 0)
  2738. {
  2739. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2740. if (_AirCompany != null)
  2741. {
  2742. string str = "--";
  2743. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2744. if (!string.IsNullOrEmpty(translateResult))
  2745. {
  2746. str = translateResult;
  2747. str = _airTicketResRep.Processing(str);
  2748. }
  2749. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2750. }
  2751. else
  2752. {
  2753. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2754. }
  2755. }
  2756. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2757. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2758. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2759. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2760. string names = "";
  2761. foreach (string clientName in nameArray)
  2762. {
  2763. names += clientName + ",";
  2764. }
  2765. if (!string.IsNullOrWhiteSpace(names))
  2766. {
  2767. string str = "--";
  2768. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2769. if (!string.IsNullOrEmpty(translateResult))
  2770. {
  2771. str = translateResult;
  2772. str = _airTicketResRep.Processing(str);
  2773. }
  2774. table.Range.Bookmarks["ClientName"].Text = str;
  2775. }
  2776. else
  2777. {
  2778. table.Range.Bookmarks["ClientName"].Text = "--";
  2779. }
  2780. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2781. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2782. table.Range.Bookmarks["JointTicket"].Text = "--";
  2783. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2784. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2785. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2786. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2787. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2788. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2789. }
  2790. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2791. //保存合并后的文档
  2792. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2793. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2794. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2795. return Ok(JsonView(true, "成功!", rst));
  2796. }
  2797. }
  2798. }
  2799. catch (Exception ex)
  2800. {
  2801. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2802. throw;
  2803. }
  2804. }
  2805. #endregion
  2806. #region 团组增减款项 --> 其他款项
  2807. /// <summary>
  2808. /// 团组增减款项下拉框绑定
  2809. /// </summary>
  2810. /// <param name="dto"></param>
  2811. /// <returns></returns>
  2812. [HttpPost]
  2813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2814. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2815. {
  2816. #region 参数验证
  2817. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2818. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2819. #endregion
  2820. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2821. }
  2822. /// <summary>
  2823. /// 根据团组Id查询团组增减款项
  2824. /// </summary>
  2825. /// <param name="dto"></param>
  2826. /// <returns></returns>
  2827. [HttpPost]
  2828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2829. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2830. {
  2831. #region 参数验证
  2832. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2833. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2834. #endregion
  2835. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2836. }
  2837. /// <summary>
  2838. /// 团组增减款项操作(Status:1.新增,2.修改)
  2839. /// </summary>
  2840. /// <param name="dto"></param>
  2841. /// <returns></returns>
  2842. [HttpPost]
  2843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2844. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2845. {
  2846. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2847. if (groupData.Code != 200)
  2848. {
  2849. return Ok(JsonView(false, groupData.Msg));
  2850. }
  2851. #region 应用推送
  2852. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2853. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2854. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2855. #endregion
  2856. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2857. }
  2858. /// <summary>
  2859. /// 团组增减款项操作 删除
  2860. /// </summary>
  2861. /// <param name="dto"></param>
  2862. /// <returns></returns>
  2863. [HttpPost]
  2864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2865. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2866. {
  2867. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2868. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2869. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2870. if (res.Code == 0)
  2871. {
  2872. return Ok(JsonView(true, "删除成功!"));
  2873. }
  2874. return Ok(JsonView(false, "删除失败!"));
  2875. }
  2876. /// <summary>
  2877. /// 根据团组增减款项Id查询
  2878. /// </summary>
  2879. /// <param name="dto"></param>
  2880. /// <returns></returns>
  2881. [HttpPost]
  2882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2883. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2884. {
  2885. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2886. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2887. }
  2888. /// <summary>
  2889. /// 查询供应商名称
  2890. /// </summary>
  2891. /// <param name="dto"></param>
  2892. /// <returns></returns>
  2893. [HttpPost]
  2894. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2895. {
  2896. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2897. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2898. ?? new List<Grp_DecreasePayments>();
  2899. dbResult = dbResult.Distinct(new
  2900. ProductComparer()).ToList();
  2901. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2902. {
  2903. x.Id,
  2904. x.SupplierAddress,
  2905. x.SupplierArea,
  2906. x.SupplierContact,
  2907. x.SupplierContactNumber,
  2908. x.SupplierEmail,
  2909. x.SupplierName,
  2910. x.SupplierSocialAccount,
  2911. x.SupplierTypeId,
  2912. }).ToList());
  2913. return Ok(jw);
  2914. }
  2915. #endregion
  2916. #region 文件上传、删除
  2917. /// <summary>
  2918. /// region 文件上传 可以带参数
  2919. /// </summary>
  2920. /// <param name="file"></param>
  2921. /// <returns></returns>
  2922. [HttpPost]
  2923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2924. public async Task<IActionResult> UploadProject(IFormFile file)
  2925. {
  2926. try
  2927. {
  2928. var TypeName = Request.Headers["TypeName"].ToString();
  2929. if (file != null)
  2930. {
  2931. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2932. //文件名称
  2933. string projectFileName = file.FileName;
  2934. //上传的文件的路径
  2935. string filePath = "";
  2936. if (TypeName == "A")//A代表团组增减款项
  2937. {
  2938. if (!Directory.Exists(fileDir))
  2939. {
  2940. Directory.CreateDirectory(fileDir);
  2941. }
  2942. //上传的文件的路径
  2943. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2944. }
  2945. else if (TypeName == "B")//B代表商邀相关文件
  2946. {
  2947. if (!Directory.Exists(fileDir))
  2948. {
  2949. Directory.CreateDirectory(fileDir);
  2950. }
  2951. //上传的文件的路径
  2952. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2953. }
  2954. using (FileStream fs = System.IO.File.Create(filePath))
  2955. {
  2956. file.CopyTo(fs);
  2957. fs.Flush();
  2958. }
  2959. return Ok(JsonView(true, "上传成功!", projectFileName));
  2960. }
  2961. else
  2962. {
  2963. return Ok(JsonView(false, "上传失败!"));
  2964. }
  2965. }
  2966. catch (Exception ex)
  2967. {
  2968. return Ok(JsonView(false, "程序错误!"));
  2969. throw;
  2970. }
  2971. }
  2972. /// <summary>
  2973. /// 删除指定文件
  2974. /// </summary>
  2975. /// <param name="dto"></param>
  2976. /// <returns></returns>
  2977. [HttpPost]
  2978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2979. public async Task<IActionResult> DelFile(DelFileDto dto)
  2980. {
  2981. try
  2982. {
  2983. var TypeName = Request.Headers["TypeName"].ToString();
  2984. string filePath = "";
  2985. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2986. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2987. int id = 0;
  2988. if (TypeName == "A")
  2989. {
  2990. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2991. // 删除该文件
  2992. System.IO.File.Delete(filePath);
  2993. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2994. }
  2995. else if (TypeName == "B")
  2996. {
  2997. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2998. // 删除该文件
  2999. System.IO.File.Delete(filePath);
  3000. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  3001. }
  3002. if (id != 0)
  3003. {
  3004. return Ok(JsonView(true, "成功!"));
  3005. }
  3006. else
  3007. {
  3008. return Ok(JsonView(false, "失败!"));
  3009. }
  3010. }
  3011. catch (Exception ex)
  3012. {
  3013. return Ok(JsonView(false, "程序错误!"));
  3014. throw;
  3015. }
  3016. }
  3017. #endregion
  3018. #region 商邀费用录入
  3019. /// <summary>
  3020. /// 根据团组Id查询商邀费用列表
  3021. /// </summary>
  3022. /// <param name="dto"></param>
  3023. /// <returns></returns>
  3024. [HttpPost]
  3025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3026. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3027. {
  3028. try
  3029. {
  3030. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3031. if (groupData.Code != 0)
  3032. {
  3033. return Ok(JsonView(false, groupData.Msg));
  3034. }
  3035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3036. }
  3037. catch (Exception ex)
  3038. {
  3039. return Ok(JsonView(false, "程序错误!"));
  3040. throw;
  3041. }
  3042. }
  3043. //
  3044. /// <summary>
  3045. /// 商邀费用 Info Page 基础数据源
  3046. /// </summary>
  3047. /// <param name="dto"></param>
  3048. /// <returns></returns>
  3049. [HttpPost]
  3050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3051. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3052. {
  3053. try
  3054. {
  3055. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3056. if (groupData.Code != 0)
  3057. {
  3058. return Ok(JsonView(false, groupData.Msg));
  3059. }
  3060. return Ok(JsonView(true, "操作成功", groupData.Data));
  3061. }
  3062. catch (Exception ex)
  3063. {
  3064. return Ok(JsonView(false, ex.Message));
  3065. throw;
  3066. }
  3067. }
  3068. /// <summary>
  3069. /// 根据商邀费用ID查询C表和商邀费用数据
  3070. /// </summary>
  3071. /// <param name="dto"></param>
  3072. /// <returns></returns>
  3073. [HttpPost]
  3074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3075. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3076. {
  3077. try
  3078. {
  3079. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3080. if (groupData.Code != 0)
  3081. {
  3082. return Ok(JsonView(false, groupData.Msg));
  3083. }
  3084. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3085. }
  3086. catch (Exception ex)
  3087. {
  3088. return Ok(JsonView(false, ex.Message));
  3089. throw;
  3090. }
  3091. }
  3092. /// <summary>
  3093. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3094. /// </summary>
  3095. /// <param name="dto"></param>
  3096. /// <returns></returns>
  3097. [HttpPost]
  3098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3099. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3100. {
  3101. try
  3102. {
  3103. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3104. if (groupData.Code != 0)
  3105. {
  3106. return Ok(JsonView(false, groupData.Msg));
  3107. }
  3108. #region 应用推送
  3109. try
  3110. {
  3111. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3112. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3113. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3114. }
  3115. catch (Exception ex)
  3116. {
  3117. }
  3118. #endregion
  3119. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3120. }
  3121. catch (Exception ex)
  3122. {
  3123. return Ok(JsonView(false, "程序错误!"));
  3124. throw;
  3125. }
  3126. }
  3127. /// <summary>
  3128. /// 商邀删除
  3129. /// </summary>
  3130. /// <param name="dto"></param>
  3131. /// <returns></returns>
  3132. [HttpPost]
  3133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3134. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3135. {
  3136. try
  3137. {
  3138. _sqlSugar.BeginTran();
  3139. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3140. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3141. {
  3142. IsDel = 1,
  3143. DeleteUserId = dto.DeleteUserId,
  3144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3145. })
  3146. .Where(it => it.Id == dto.Id)
  3147. .ExecuteCommand();
  3148. if (res1 > 0)
  3149. {
  3150. int _diId = 0;
  3151. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3152. if (_ioaInfo != null)
  3153. {
  3154. _diId = _ioaInfo.DiId;
  3155. }
  3156. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3157. .SetColumns(a => new Grp_CreditCardPayment()
  3158. {
  3159. IsDel = 1,
  3160. DeleteUserId = dto.DeleteUserId,
  3161. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3162. })
  3163. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3164. .ExecuteCommand();
  3165. if (res2 > 0)
  3166. {
  3167. _sqlSugar.CommitTran();
  3168. return Ok(JsonView(true, "删除成功!"));
  3169. }
  3170. }
  3171. _sqlSugar.RollbackTran();
  3172. return Ok(JsonView(false, "删除失败"));
  3173. }
  3174. catch (Exception ex)
  3175. {
  3176. _sqlSugar.RollbackTran();
  3177. return Ok(JsonView(false, ex.Message));
  3178. }
  3179. }
  3180. /// <summary>
  3181. /// 团组模块文件上传
  3182. /// </summary>
  3183. /// <param name="dto"></param>
  3184. /// <returns></returns>
  3185. [HttpPost]
  3186. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3187. {
  3188. var jw = JsonView(false);
  3189. long M = 1024 * 1024;
  3190. if (dto.Files == null || dto.Files.Count == 0)
  3191. {
  3192. jw.Msg = "无文件信息!";
  3193. return Ok(jw);
  3194. }
  3195. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3196. {
  3197. jw.Msg = "文件大小超过20M!";
  3198. return Ok(jw);
  3199. }
  3200. //var nameSp = dto.File.FileName.Split(".");
  3201. //if (nameSp.Length < 2)
  3202. //{
  3203. // jw.Msg = "拓展名称有误!";
  3204. // return Ok(jw);
  3205. //}
  3206. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3207. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3208. //{
  3209. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3210. // return Ok(jw);
  3211. //}
  3212. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3213. if (Ctable == null)
  3214. {
  3215. jw.Msg = "Ctable指向有误!";
  3216. return Ok(jw);
  3217. }
  3218. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3219. if (groupInfo == null)
  3220. {
  3221. jw.Msg = "团组信息不存在!";
  3222. return Ok(jw);
  3223. }
  3224. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3225. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3226. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3227. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3228. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3229. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3230. try
  3231. {
  3232. if (!Directory.Exists(fileBase))
  3233. {
  3234. Directory.CreateDirectory(fileBase);
  3235. }
  3236. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3237. foreach (var fileStream in dto.Files)
  3238. {
  3239. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3240. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3241. {
  3242. Cid = dto.Cid,
  3243. CreateTime = DateTime.Now,
  3244. CreateUserId = dto.Userid,
  3245. Ctable = dto.Ctable,
  3246. Diid = dto.Diid,
  3247. IsDel = 0,
  3248. FilePath = saveFilePath,
  3249. FileName = fileStream.FileName
  3250. };
  3251. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3252. {
  3253. fileStream.CopyTo(fs);
  3254. fs.Flush();
  3255. }
  3256. saveArr.Add(file);
  3257. }
  3258. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3259. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3260. jw = JsonView(true, "保存成功!", new
  3261. {
  3262. count = addResult,
  3263. filesName = saveArr.Select(x => x.FileName)
  3264. }) ;
  3265. }
  3266. catch (Exception ex)
  3267. {
  3268. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3269. {
  3270. count = 0,
  3271. filesName = new string[0],
  3272. }) ;
  3273. }
  3274. return Ok(jw);
  3275. }
  3276. /// <summary>
  3277. /// 查询各模块已保存文件
  3278. /// </summary>
  3279. /// <param name="dto"></param>
  3280. /// <returns></returns>
  3281. [HttpPost]
  3282. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3283. {
  3284. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3285. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3286. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3287. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3288. {
  3289. expression = Expressionable.Create<Grp_GroupModelFile>()
  3290. .And(x=>visaIds.Contains(x.CreateUserId));
  3291. }
  3292. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3293. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3294. .Where(expression.ToExpression())
  3295. .ToList();
  3296. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3297. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3298. {
  3299. x.FileName,
  3300. x.Id,
  3301. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3302. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3303. })));
  3304. }
  3305. /// <summary>
  3306. /// 下载该团组下的所有文件
  3307. /// </summary>
  3308. /// <param name="dto"></param>
  3309. /// <returns></returns>
  3310. [HttpPost]
  3311. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3312. {
  3313. var jw = JsonView(false);
  3314. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3315. if (groupInfo == null)
  3316. {
  3317. jw.Msg = "团组信息不存在!";
  3318. return Ok(jw);
  3319. }
  3320. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3321. var isModule = Convert.ToBoolean(dto.isModule);
  3322. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3323. IOOperatorHelper io = new IOOperatorHelper();
  3324. if (isModule)
  3325. {
  3326. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3327. foreach (var moduleArr in moduleGroup)
  3328. {
  3329. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3330. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3331. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3332. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3333. foreach (var item in moduleArr)
  3334. {
  3335. if (System.IO.File.Exists(item.FilePath))
  3336. {
  3337. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3338. {
  3339. byte[] bytes = new byte[fileStream.Length];
  3340. fileStream.Read(bytes, 0, bytes.Length);
  3341. fileStream.Close();
  3342. Stream stream = new MemoryStream(bytes);
  3343. chiZips.Add(item.FileName, stream);
  3344. }
  3345. }
  3346. }
  3347. if (chiZips.Count > 0)
  3348. {
  3349. var byts = io.ConvertZipStream(chiZips);
  3350. Stream stream = new MemoryStream(byts);
  3351. Zips.Add(key.Name+"_.zip", stream);
  3352. }
  3353. }
  3354. }
  3355. else
  3356. {
  3357. foreach (var item in dbQuery)
  3358. {
  3359. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3360. {
  3361. byte[] bytes = new byte[fileStream.Length];
  3362. fileStream.Read(bytes, 0, bytes.Length);
  3363. fileStream.Close();
  3364. Stream stream = new MemoryStream(bytes);
  3365. while (Zips.Keys.Contains(item.FileName))
  3366. {
  3367. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3368. }
  3369. Zips.Add(item.FileName, stream);
  3370. }
  3371. }
  3372. }
  3373. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3374. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3375. if (Zips.Count > 0)
  3376. {
  3377. var byts = io.ConvertZipStream(Zips);
  3378. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3379. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3380. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3381. }
  3382. else
  3383. {
  3384. jw.Msg = "暂无生成文件!";
  3385. }
  3386. return Ok(jw);
  3387. }
  3388. /// <summary>
  3389. /// 下载该团组下此模块的所有文件
  3390. /// </summary>
  3391. /// <param name="dto"></param>
  3392. /// <returns></returns>
  3393. [HttpPost]
  3394. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3395. {
  3396. var jw = JsonView(false);
  3397. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3398. if (groupInfo == null)
  3399. {
  3400. jw.Msg = "团组信息不存在!";
  3401. return Ok(jw);
  3402. }
  3403. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3404. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3405. && x.IsDel == 0);
  3406. if (key == null)
  3407. {
  3408. jw.Msg = "Ctable指向错误!";
  3409. return Ok(jw);
  3410. }
  3411. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3412. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3413. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3414. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3415. IOOperatorHelper io = new IOOperatorHelper();
  3416. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3417. foreach (var item in dbQuery)
  3418. {
  3419. if (System.IO.File.Exists(item.FilePath))
  3420. {
  3421. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3422. {
  3423. byte[] bytes = new byte[fileStream.Length];
  3424. fileStream.Read(bytes, 0, bytes.Length);
  3425. fileStream.Close();
  3426. Stream stream = new MemoryStream(bytes);
  3427. while (Zips.Keys.Contains(item.FileName))
  3428. {
  3429. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3430. }
  3431. Zips.Add(item.FileName, stream);
  3432. }
  3433. }
  3434. }
  3435. if (Zips.Count > 0)
  3436. {
  3437. var byts = io.ConvertZipStream(Zips);
  3438. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3439. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3440. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3441. }
  3442. else
  3443. {
  3444. jw.Msg = "暂无生成文件!";
  3445. }
  3446. return Ok(jw);
  3447. }
  3448. /// <summary>
  3449. /// 删除该团组下的指定文件
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3455. {
  3456. var jw = JsonView(false);
  3457. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3458. if (sing == null)
  3459. {
  3460. jw.Msg = "暂无";
  3461. return Ok(jw);
  3462. }
  3463. if (System.IO.File.Exists(sing.FilePath))
  3464. {
  3465. try
  3466. {
  3467. System.IO.File.Delete(sing.FilePath);
  3468. }
  3469. catch (Exception ex)
  3470. {
  3471. jw.Msg = "删除失败!" + ex.Message;
  3472. return Ok(jw);
  3473. }
  3474. }
  3475. sing.IsDel = 1;
  3476. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3477. sing.DeleteUserId = dto.UserId;
  3478. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3479. jw = JsonView(true, "删除成功!");
  3480. return Ok(jw);
  3481. }
  3482. #endregion
  3483. #region 团组英文资料
  3484. /// <summary>
  3485. /// 查询团组英文所有资料
  3486. /// </summary>
  3487. /// <param name="dto"></param>
  3488. /// <returns></returns>
  3489. [HttpPost]
  3490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3491. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3492. {
  3493. try
  3494. {
  3495. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3496. if (groupData.Code != 0)
  3497. {
  3498. return Ok(JsonView(false, groupData.Msg));
  3499. }
  3500. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3501. }
  3502. catch (Exception ex)
  3503. {
  3504. return Ok(JsonView(false, "程序错误!"));
  3505. throw;
  3506. }
  3507. }
  3508. /// <summary>
  3509. /// 团组英文资料操作(Status:1.新增,2.修改)
  3510. /// </summary>
  3511. /// <param name="dto"></param>
  3512. /// <returns></returns>
  3513. [HttpPost]
  3514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3515. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3516. {
  3517. try
  3518. {
  3519. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3520. if (groupData.Code != 0)
  3521. {
  3522. return Ok(JsonView(false, groupData.Msg));
  3523. }
  3524. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3525. }
  3526. catch (Exception ex)
  3527. {
  3528. return Ok(JsonView(false, "程序错误!"));
  3529. throw;
  3530. }
  3531. }
  3532. /// <summary>
  3533. /// 团组英文资料Id查询数据
  3534. /// </summary>
  3535. /// <param name="dto"></param>
  3536. /// <returns></returns>
  3537. [HttpPost]
  3538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3539. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3540. {
  3541. try
  3542. {
  3543. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3544. if (_DelegationEnData != null)
  3545. {
  3546. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3547. }
  3548. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3549. }
  3550. catch (Exception ex)
  3551. {
  3552. return Ok(JsonView(false, "程序错误!"));
  3553. throw;
  3554. }
  3555. }
  3556. /// <summary>
  3557. /// 团组英文资料删除
  3558. /// </summary>
  3559. /// <param name="dto"></param>
  3560. /// <returns></returns>
  3561. [HttpPost]
  3562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3563. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3564. {
  3565. try
  3566. {
  3567. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3568. if (!res)
  3569. {
  3570. return Ok(JsonView(false, "删除失败"));
  3571. }
  3572. return Ok(JsonView(true, "删除成功!"));
  3573. }
  3574. catch (Exception ex)
  3575. {
  3576. return Ok(JsonView(false, "程序错误!"));
  3577. throw;
  3578. }
  3579. }
  3580. #endregion
  3581. #region 导出邀请函
  3582. /// <summary>
  3583. /// 导出邀请函页面初始化
  3584. /// </summary>
  3585. /// <param name="dto"></param>
  3586. /// <returns></returns>
  3587. [HttpPost]
  3588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3589. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3590. {
  3591. try
  3592. {
  3593. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3594. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3595. if (dto.DiId == 0)
  3596. {
  3597. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3598. }
  3599. else
  3600. {
  3601. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3602. }
  3603. return Ok(JsonView(true, "查询成功!", new
  3604. {
  3605. deleClient = crm_Deles,
  3606. delegations = grp_Delegations
  3607. }));
  3608. }
  3609. catch (Exception ex)
  3610. {
  3611. return Ok(JsonView(false, "程序错误!"));
  3612. throw;
  3613. }
  3614. }
  3615. /// <summary>
  3616. /// 导出邀请函
  3617. /// </summary>
  3618. /// <param name="dto"></param>
  3619. /// <returns></returns>
  3620. [HttpPost]
  3621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3622. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3623. {
  3624. #region 参数验证
  3625. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3626. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3627. #endregion
  3628. try
  3629. {
  3630. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3631. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3632. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3633. From Grp_TourClientList tcl
  3634. Left Join
  3635. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3636. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3637. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3638. From Crm_DeleClient dc
  3639. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3640. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3641. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3642. Where dc.IsDel = 0) temp
  3643. On temp.DcId =tcl.ClientId
  3644. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3645. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3646. List<string> texts = new List<string>();
  3647. if (datas.Count != 0)
  3648. {
  3649. foreach (TourClientListDetailsView item in datas)
  3650. {
  3651. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3652. {
  3653. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3654. }
  3655. else
  3656. {
  3657. string name = item.LastName + item.FirstName;
  3658. texts.Add(name);
  3659. }
  3660. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3661. {
  3662. if (!transDic.ContainsKey(item.Job))
  3663. {
  3664. texts.Add(item.Job);
  3665. }
  3666. }
  3667. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3668. {
  3669. texts.Add(item.CompanyFullName);
  3670. }
  3671. }
  3672. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3673. if (transData.Count > 0)
  3674. {
  3675. foreach (TranslateResult item in transData)
  3676. {
  3677. if (!transDic.ContainsKey(item.Query))
  3678. {
  3679. transDic.Add(item.Query, item.Translation);
  3680. }
  3681. }
  3682. }
  3683. List<GuestList> list = new List<GuestList>();
  3684. foreach (TourClientListDetailsView dele in datas)
  3685. {
  3686. GuestList guestList = new GuestList();
  3687. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3688. {
  3689. guestList.Name = dele.Pinyin;
  3690. }
  3691. else
  3692. {
  3693. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3694. guestList.Name = Name;
  3695. }
  3696. if (dele.Sex == 0)
  3697. {
  3698. guestList.Sex = "Male";
  3699. }
  3700. else if (dele.Sex == 1)
  3701. {
  3702. guestList.Sex = "Female";
  3703. }
  3704. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3705. if (!string.IsNullOrEmpty(dele.Job))
  3706. {
  3707. guestList.Job = dele.Job;
  3708. }
  3709. list.Add(guestList);
  3710. }
  3711. //载入模板
  3712. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3713. DocumentBuilder builder = new DocumentBuilder(doc);
  3714. //获取word里所有表格
  3715. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3716. //获取所填表格的序数
  3717. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3718. var rowStart = tableOne.Rows[0]; //获取第1行
  3719. //循环赋值
  3720. for (int i = 0; i < list.Count; i++)
  3721. {
  3722. builder.MoveToCell(0, i + 1, 0, 0);
  3723. builder.Write(list[i].Name.ToString());
  3724. builder.MoveToCell(0, i + 1, 1, 0);
  3725. builder.Write(list[i].Sex.ToString());
  3726. builder.MoveToCell(0, i + 1, 2, 0);
  3727. builder.Write(list[i].DOB.ToString());
  3728. builder.MoveToCell(0, i + 1, 3, 0);
  3729. builder.Write(list[i].Job.ToString());
  3730. }
  3731. //删除多余行
  3732. while (tableOne.Rows.Count > list.Count + 1)
  3733. {
  3734. tableOne.Rows.RemoveAt(list.Count + 1);
  3735. }
  3736. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3737. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3738. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3739. doc.Save(filePath);
  3740. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3741. return Ok(JsonView(true, "操作成功!", Url));
  3742. }
  3743. else
  3744. {
  3745. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3746. }
  3747. }
  3748. catch (Exception ex)
  3749. {
  3750. return Ok(JsonView(false, ex.Message));
  3751. throw;
  3752. }
  3753. }
  3754. #endregion
  3755. #region 团组经理模块 出入境费用
  3756. ///// <summary>
  3757. ///// 团组模块 - 出入境费用
  3758. ///// </summary>
  3759. ///// <returns></returns>
  3760. //[HttpPost]
  3761. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3762. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3763. //{
  3764. // try
  3765. // {
  3766. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3767. // if (data.Code != 0)
  3768. // {
  3769. // return Ok(JsonView(false, data.Msg));
  3770. // }
  3771. // return Ok(JsonView(true, "查询成功!"));
  3772. // }
  3773. // catch (Exception ex)
  3774. // {
  3775. // return Ok(JsonView(false, ex.Message));
  3776. // throw;
  3777. // }
  3778. //}
  3779. /// <summary>
  3780. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3781. /// </summary>
  3782. /// <returns></returns>
  3783. [HttpPost]
  3784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3785. public async Task<IActionResult> SetDayAndCostAreaChange()
  3786. {
  3787. try
  3788. {
  3789. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3790. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3791. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3792. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3793. foreach (var item in unite) //处理交集数据
  3794. {
  3795. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3796. }
  3797. foreach (var item in merge) //处理差集数据
  3798. {
  3799. int nationalTravelFeeId = 0;
  3800. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3801. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3802. else
  3803. {
  3804. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3805. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3806. }
  3807. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3808. }
  3809. //只更新dayAndCost 的 nationalTravelFeeId;
  3810. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3811. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3812. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3813. }
  3814. catch (Exception ex)
  3815. {
  3816. return Ok(JsonView(false, ex.Message));
  3817. throw;
  3818. }
  3819. }
  3820. /// <summary>
  3821. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3822. /// </summary>
  3823. /// <returns></returns>
  3824. [HttpPost]
  3825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3826. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3827. {
  3828. try
  3829. {
  3830. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3831. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3832. //SetDataInfoView
  3833. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3834. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3835. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3836. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3837. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3838. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3839. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3840. //默认币种显示
  3841. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3842. {
  3843. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3844. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3845. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3846. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3847. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3848. };
  3849. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3850. if (_currencyRate.Count > 0)
  3851. {
  3852. foreach (var item in _currencyInfos)
  3853. {
  3854. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3855. if (rateInfo != null)
  3856. {
  3857. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3858. rate1 *= 1.035M;
  3859. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3860. }
  3861. }
  3862. }
  3863. return Ok(JsonView(true, "查询成功!", new
  3864. {
  3865. GroupNameData = groupNameData.Data,
  3866. CurrencyData = _CurrencyData,
  3867. WordTypeData = _WordTypeData,
  3868. ExcelTypeData = _ExcelTypeData,
  3869. CurrencyInit = _currencyInfos
  3870. }));
  3871. }
  3872. catch (Exception ex)
  3873. {
  3874. return Ok(JsonView(false, ex.Message));
  3875. throw;
  3876. }
  3877. }
  3878. /// <summary>
  3879. /// 团组模块 - 出入境费用
  3880. /// 实时汇率 tips
  3881. /// 签证费用 tips
  3882. /// </summary>
  3883. /// <returns></returns>
  3884. [HttpPost]
  3885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3886. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3887. {
  3888. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3889. //默认币种显示
  3890. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3891. {
  3892. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3893. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3894. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3895. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3896. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3897. };
  3898. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3899. List<dynamic> reteInfos = new List<dynamic>();
  3900. if (_currencyRate.Count > 0)
  3901. {
  3902. foreach (var item in _currencyInfos)
  3903. {
  3904. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3905. if (rateInfo != null)
  3906. {
  3907. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3908. decimal rate1 = item.Rate;
  3909. rate1 *= 1.03M;
  3910. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3911. reteInfos.Add(new
  3912. {
  3913. currCode = item.CurrencyCode,
  3914. currName = item.CurrencyName,
  3915. rate = rate2,
  3916. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3917. });
  3918. }
  3919. }
  3920. }
  3921. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3922. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3923. return Ok(JsonView(true, "查询成功!", new
  3924. {
  3925. //GroupNameData = groupNameData.Data,
  3926. visaData = visaData.Data,
  3927. airData = airData.Data,
  3928. reteInfos = reteInfos
  3929. }));
  3930. }
  3931. /// <summary>
  3932. /// 团组模块 - 出入境费用 - Info
  3933. /// </summary>
  3934. /// <returns></returns>
  3935. [HttpPost]
  3936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3937. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3938. {
  3939. try
  3940. {
  3941. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3942. if (data.Code != 0)
  3943. {
  3944. return Ok(JsonView(false, data.Msg));
  3945. }
  3946. return Ok(JsonView(true, "查询成功!", data.Data));
  3947. }
  3948. catch (Exception ex)
  3949. {
  3950. return Ok(JsonView(false, ex.Message));
  3951. }
  3952. }
  3953. /// <summary>
  3954. /// 团组模块 - 出入境费用 - Add And Update
  3955. /// </summary>
  3956. /// <returns></returns>
  3957. [HttpPost]
  3958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3959. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3960. {
  3961. try
  3962. {
  3963. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3964. if (data.Code != 0)
  3965. {
  3966. return Ok(JsonView(false, data.Msg));
  3967. }
  3968. //生成默认文件pdf并且通知人员
  3969. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3970. {
  3971. DiId = dto.DiId,
  3972. ExportType = 1,
  3973. SubTypeId = 1005
  3974. }, "pdf");
  3975. //发送通知
  3976. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3977. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3978. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3979. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3980. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3981. return Ok(JsonView(true, data.Msg, data.Data));
  3982. }
  3983. catch (Exception ex)
  3984. {
  3985. return Ok(JsonView(false, ex.Message));
  3986. }
  3987. }
  3988. /// <summary>
  3989. /// 团组模块 - 出入境费用 - Confirm 费用
  3990. /// </summary>
  3991. /// <returns></returns>
  3992. [HttpPost]
  3993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3994. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3995. {
  3996. //TODO:测试完毕需把对应的用户ID更改
  3997. //1、数据表添加字段
  3998. //2、更改字段接口()
  3999. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4000. //3、确认成功 给财务发送消息
  4001. if (_view.Code == 200)
  4002. {
  4003. if (dto.Type == 1)
  4004. {
  4005. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4006. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4007. }
  4008. }
  4009. return Ok(_view);
  4010. }
  4011. /// <summary>
  4012. /// 团组模块 - 出入境费用 - File downlaod
  4013. /// </summary>
  4014. /// <param name="dto"></param>
  4015. /// <returns></returns>
  4016. [HttpPost]
  4017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4018. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4019. {
  4020. try
  4021. {
  4022. if (dto.DiId < 1)
  4023. {
  4024. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4025. }
  4026. if (dto.ExportType < 1)
  4027. {
  4028. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4029. }
  4030. if (dto.SubTypeId < 1)
  4031. {
  4032. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4033. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4034. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4035. 3 团组成员名单 1 团组成员名单"));
  4036. }
  4037. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4038. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4039. if (_EnterExitCosts == null)
  4040. {
  4041. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4042. }
  4043. //数据源
  4044. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4045. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4046. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4047. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4048. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4049. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4050. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4051. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4052. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4053. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4054. .Select((tcl, dc, cc) => new
  4055. {
  4056. Name = dc.LastName + dc.FirstName,
  4057. Sex = dc.Sex,
  4058. Birthday = dc.BirthDay,
  4059. Company = cc.CompanyFullName,
  4060. Job = dc.Job
  4061. })
  4062. .ToList();
  4063. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4064. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4065. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4066. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4067. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4068. if (dto.ExportType == 1) //明细表
  4069. {
  4070. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4071. {
  4072. //获取模板
  4073. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4074. //载入模板
  4075. Document doc = new Document(tempPath);
  4076. DocumentBuilder builder = new DocumentBuilder(doc);
  4077. //利用键值对存放数据
  4078. Dictionary<string, string> dic = new Dictionary<string, string>();
  4079. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4080. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4081. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4082. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4083. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4084. //境内费用(其他费用)
  4085. if (_EnterExitCosts.ChoiceOne == 1)
  4086. {
  4087. string row1_1 = "";
  4088. if (_EnterExitCosts.Visa > 0)
  4089. {
  4090. //insidePayTotal += _EnterExitCosts.Visa;
  4091. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4092. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4093. {
  4094. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4095. }
  4096. }
  4097. string row1_2 = "";
  4098. if (_EnterExitCosts.YiMiao > 0)
  4099. {
  4100. //insidePayTotal += _EnterExitCosts.YiMiao;
  4101. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4102. }
  4103. if (_EnterExitCosts.HeSuan > 0)
  4104. {
  4105. //insidePayTotal += _EnterExitCosts.HeSuan;
  4106. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4107. }
  4108. if (_EnterExitCosts.Service > 0)
  4109. {
  4110. //insidePayTotal += _EnterExitCosts.Service;
  4111. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4112. }
  4113. string row1_3 = "";
  4114. if (_EnterExitCosts.Safe > 0)
  4115. {
  4116. //insidePayTotal += _EnterExitCosts.Safe;
  4117. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4118. }
  4119. if (_EnterExitCosts.Ticket > 0)
  4120. {
  4121. //insidePayTotal += _EnterExitCosts.Ticket;
  4122. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4123. }
  4124. string row1 = "";
  4125. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4126. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4127. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4128. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4129. dic.Add("Row1Str", row1);
  4130. }
  4131. string airTotalStr = string.Empty,
  4132. airPriceStr = string.Empty;
  4133. //经济舱
  4134. if (_EnterExitCosts.SumJJC == 1)
  4135. {
  4136. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4137. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4138. }
  4139. //公务舱
  4140. if (_EnterExitCosts.SumGWC == 1)
  4141. {
  4142. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4143. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4144. }
  4145. //头等舱
  4146. if (_EnterExitCosts.SumTDC == 1)
  4147. {
  4148. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4149. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4150. }
  4151. dic.Add("AirTotalStr", airTotalStr);
  4152. dic.Add("AirPriceStr", airPriceStr);
  4153. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4154. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4155. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4156. int table1Row = 0,
  4157. table2Row = 0,
  4158. table3Row = 0,
  4159. table4Row = 0;
  4160. //住宿费
  4161. if (_EnterExitCosts.ChoiceThree == 1)
  4162. {
  4163. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4164. table1Row = dac1.Count;
  4165. #region 填充word表格内容
  4166. for (int i = 0; i < dac1.Count; i++)
  4167. {
  4168. Grp_DayAndCost dac = dac1[i];
  4169. if (dac == null) continue;
  4170. builder.MoveToCell(0, i, 0, 0);
  4171. builder.Write("第" + dac.Days.ToString() + "晚:");
  4172. builder.MoveToCell(0, i, 1, 0);
  4173. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4174. //builder.Write(dac.Place == null ? "" : dac.Place);
  4175. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4176. builder.MoveToCell(0, i, 2, 0);
  4177. builder.Write("费用标准:");
  4178. string curr = "";
  4179. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4180. if (currData != null)
  4181. {
  4182. curr = currData.Name;
  4183. }
  4184. builder.MoveToCell(0, i, 3, 0);
  4185. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4186. builder.MoveToCell(0, i, 4, 0);
  4187. builder.Write("费用小计:");
  4188. builder.MoveToCell(0, i, 5, 0);
  4189. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4190. }
  4191. #endregion
  4192. }else dic.Add("SubZS","0.00");
  4193. //删除多余行
  4194. while (table1.Rows.Count > table1Row)
  4195. {
  4196. table1.Rows.RemoveAt(table1Row);
  4197. }
  4198. //伙食费
  4199. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4200. if (_EnterExitCosts.ChoiceFour == 1)
  4201. {
  4202. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4203. table2Row = dac2.Count;
  4204. #region 填充word表格内容
  4205. for (int i = 0; i < dac2.Count; i++)
  4206. {
  4207. Grp_DayAndCost dac = dac2[i];
  4208. if (dac == null) continue;
  4209. builder.MoveToCell(1, i, 0, 0);
  4210. builder.Write("第" + dac.Days.ToString() + "天:");
  4211. builder.MoveToCell(1, i, 1, 0);
  4212. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4213. builder.MoveToCell(1, i, 2, 0);
  4214. builder.Write("费用标准:");
  4215. string curr = "";
  4216. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4217. if (currData != null)
  4218. {
  4219. curr = currData.Name;
  4220. }
  4221. builder.MoveToCell(1, i, 3, 0);
  4222. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4223. builder.MoveToCell(1, i, 4, 0);
  4224. builder.Write("费用小计:");
  4225. builder.MoveToCell(1, i, 5, 0);
  4226. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4227. }
  4228. #endregion
  4229. }else dic.Add("SubHS","0.00");
  4230. //删除多余行
  4231. while (table2.Rows.Count > table2Row)
  4232. {
  4233. table2.Rows.RemoveAt(table2Row);
  4234. }
  4235. //公杂费
  4236. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4237. if (_EnterExitCosts.ChoiceFive == 1)
  4238. {
  4239. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4240. table3Row = dac3.Count;
  4241. #region 填充word表格内容
  4242. for (int i = 0; i < dac3.Count; i++)
  4243. {
  4244. Grp_DayAndCost dac = dac3[i];
  4245. if (dac == null) continue;
  4246. builder.MoveToCell(2, i, 0, 0);
  4247. builder.Write("第" + dac.Days.ToString() + "天:");
  4248. builder.MoveToCell(2, i, 1, 0);
  4249. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4250. builder.MoveToCell(2, i, 2, 0);
  4251. builder.Write("费用标准:");
  4252. string curr = "";
  4253. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4254. if (currData != null)
  4255. {
  4256. curr = currData.Name;
  4257. }
  4258. builder.MoveToCell(2, i, 3, 0);
  4259. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4260. builder.MoveToCell(2, i, 4, 0);
  4261. builder.Write("费用小计:");
  4262. builder.MoveToCell(2, i, 5, 0);
  4263. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4264. }
  4265. //删除多余行
  4266. while (table3.Rows.Count > table3Row)
  4267. {
  4268. table3.Rows.RemoveAt(table3Row);
  4269. }
  4270. #endregion
  4271. }else dic.Add("SubGZF", "0.00");
  4272. //删除多余行
  4273. while (table3.Rows.Count > table3Row)
  4274. {
  4275. table3.Rows.RemoveAt(table3Row);
  4276. }
  4277. //培训费
  4278. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4279. if (_EnterExitCosts.ChoiceSix == 1)
  4280. {
  4281. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4282. dic.Add("SubPX", pxStr);
  4283. table4Row = dac4.Count;
  4284. #region 填充word表格内容
  4285. for (int i = 0; i < dac4.Count; i++)
  4286. {
  4287. Grp_DayAndCost dac = dac4[i];
  4288. if (dac == null) continue;
  4289. builder.MoveToCell(3, i, 0, 0);
  4290. builder.Write("第" + dac.Days.ToString() + "天:");
  4291. builder.MoveToCell(3, i, 1, 0);
  4292. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4293. builder.MoveToCell(3, i, 2, 0);
  4294. builder.Write("费用标准:");
  4295. string curr = "";
  4296. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4297. if (currData != null)
  4298. {
  4299. curr = currData.Name;
  4300. }
  4301. builder.MoveToCell(3, i, 3, 0);
  4302. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4303. builder.MoveToCell(3, i, 4, 0);
  4304. builder.Write("费用小计:");
  4305. builder.MoveToCell(3, i, 5, 0);
  4306. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4307. }
  4308. #endregion
  4309. }
  4310. //else dic.Add("SubPX","0.00");
  4311. //删除多余行
  4312. while (table4.Rows.Count > table4Row)
  4313. {
  4314. table4.Rows.RemoveAt(table4Row);
  4315. }
  4316. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4317. decimal subJJC = 0.00M,
  4318. subGWC = 0.00M,
  4319. subTDC = 0.00M;
  4320. //经济舱
  4321. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4322. //公务舱
  4323. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4324. //头等舱
  4325. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4326. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4327. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4328. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4329. #region 填充word模板书签内容
  4330. foreach (var key in dic.Keys)
  4331. {
  4332. builder.MoveToBookmark(key);
  4333. builder.Write(dic[key]);
  4334. }
  4335. #endregion
  4336. //文件名
  4337. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4338. AsposeHelper.removewatermark_v2180();
  4339. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4340. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4341. return Ok(JsonView(true, "成功", new { Url = url }));
  4342. }
  4343. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4344. {
  4345. //获取模板
  4346. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4347. //载入模板
  4348. Document doc = new Document(tempPath);
  4349. DocumentBuilder builder = new DocumentBuilder(doc);
  4350. Dictionary<string, string> dic = new Dictionary<string, string>();
  4351. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4352. {
  4353. List<string> list = new List<string>();
  4354. try
  4355. {
  4356. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4357. foreach (var item in spilitArr)
  4358. {
  4359. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4360. var depCode = spDotandEmpty[2].Substring(0, 3);
  4361. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4362. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4363. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4364. list.Add(depName);
  4365. list.Add(arrName);
  4366. }
  4367. list = list.Distinct().ToList();
  4368. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4369. }
  4370. catch (Exception)
  4371. {
  4372. dic.Add("ReturnCode", "行程录入不正确!");
  4373. }
  4374. }
  4375. else
  4376. {
  4377. dic.Add("ReturnCode", "未录入行程!");
  4378. }
  4379. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4380. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4381. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4382. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4383. {
  4384. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4385. dic.Add("Day", sp.Days.ToString());
  4386. }
  4387. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4388. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4389. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4390. //dic.Add("Names", Names);
  4391. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4392. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4393. decimal dac1totalPrice = 0.00M;
  4394. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4395. foreach (var dac in dac1)
  4396. {
  4397. if (dac.SubTotal == 0.00M)
  4398. {
  4399. continue;
  4400. }
  4401. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4402. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4403. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4404. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4405. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4406. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4407. builder.Write(currency);//币种
  4408. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4409. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4410. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4411. builder.Write("");//人数
  4412. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4413. builder.Write("");//天数
  4414. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4415. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4416. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4417. decimal rate = 0.00M;
  4418. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4419. builder.Write(rate.ToString("#0.0000"));//汇率
  4420. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4421. decimal rbmPrice = dac.SubTotal;
  4422. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4423. accommodationStartIndex++;
  4424. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4425. }
  4426. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4427. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4428. {
  4429. table1.Rows.RemoveAt(i - 1);
  4430. foodandotherStartIndex--;
  4431. }
  4432. if (dac2.Count == dac3.Count)//国家 币种 金额
  4433. {
  4434. for (int i = 0; i < dac2.Count; i++)
  4435. {
  4436. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4437. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4438. }
  4439. }
  4440. decimal dac2totalPrice = 0.00M;
  4441. foreach (var dac in dac2)
  4442. {
  4443. if (dac.SubTotal == 0)
  4444. {
  4445. continue;
  4446. }
  4447. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4448. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4449. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4450. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4451. builder.Write(currency);//币种
  4452. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4453. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4454. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4455. builder.Write("");//人数
  4456. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4457. builder.Write("");//天数
  4458. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4459. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4460. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4461. decimal rate = 0.00M;
  4462. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4463. builder.Write(rate.ToString("#0.0000"));//汇率
  4464. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4465. decimal rbmPrice = dac.SubTotal;
  4466. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4467. foodandotherStartIndex++;
  4468. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4469. }
  4470. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4471. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4472. {
  4473. table1.Rows.RemoveAt(i - 1);
  4474. }
  4475. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4476. string otherFeeStr = "";
  4477. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4478. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4479. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4480. if (otherFeeStr.Length > 0)
  4481. {
  4482. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4483. otherFeeStr = $"({otherFeeStr})";
  4484. dic.Add("OtherFeeStr", otherFeeStr);
  4485. }
  4486. //总计
  4487. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4488. //国际旅费
  4489. string outsideAir = string.Empty;
  4490. string allPriceAir = string.Empty;
  4491. if (_EnterExitCosts.SumJJC == 1)
  4492. {
  4493. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4494. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4495. }
  4496. if (_EnterExitCosts.SumGWC == 1)
  4497. {
  4498. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4499. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4500. }
  4501. if (_EnterExitCosts.SumTDC == 1)
  4502. {
  4503. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4504. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4505. }
  4506. dic.Add("InTravelPrice", $"({outsideAir})");
  4507. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4508. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4509. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4510. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4511. foreach (var key in dic.Keys)
  4512. {
  4513. builder.MoveToBookmark(key);
  4514. builder.Write(dic[key]);
  4515. }
  4516. //模板文件名
  4517. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4518. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4519. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4520. return Ok(JsonView(true, "成功", new { Url = url }));
  4521. }
  4522. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4523. {
  4524. //获取模板
  4525. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4526. //载入模板
  4527. WorkbookDesigner designer = new WorkbookDesigner();
  4528. designer.Workbook = new Workbook(tempPath);
  4529. Dictionary<string, string> dic = new Dictionary<string, string>();
  4530. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4531. {
  4532. List<string> list = new List<string>();
  4533. try
  4534. {
  4535. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4536. foreach (var item in spilitArr)
  4537. {
  4538. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4539. var depCode = spDotandEmpty[2].Substring(0, 3);
  4540. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4541. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4542. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4543. list.Add(depName);
  4544. list.Add(arrName);
  4545. }
  4546. list = list.Distinct().ToList();
  4547. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4548. }
  4549. catch (Exception)
  4550. {
  4551. dic.Add("ReturnCode", "行程录入不正确!");
  4552. }
  4553. }
  4554. else
  4555. {
  4556. dic.Add("ReturnCode", "未录入行程!");
  4557. }
  4558. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4559. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4560. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4561. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4562. {
  4563. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4564. dic.Add("Day", sp.Days.ToString());
  4565. }
  4566. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4567. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4568. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4569. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4570. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4571. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4572. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4573. designer.SetDataSource("Name", Names);
  4574. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4575. designer.SetDataSource("Day", dic["Day"] + "天");
  4576. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4577. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4578. int startIndex = 10;
  4579. const int startIndexcopy = 10;
  4580. if (dac2.Count == dac3.Count)//国家 币种 金额
  4581. {
  4582. for (int i = 0; i < dac2.Count; i++)
  4583. {
  4584. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4585. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4586. }
  4587. }
  4588. DataTable dtdac1 = new DataTable();
  4589. List<string> place = new List<string>();
  4590. dtdac1.Columns.AddRange(new DataColumn[] {
  4591. new DataColumn(){ ColumnName = "city"},
  4592. new DataColumn(){ ColumnName = "curr"},
  4593. new DataColumn(){ ColumnName = "criterion"},
  4594. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4595. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4596. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4597. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4598. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4599. });
  4600. DataTable dtdac2 = new DataTable();
  4601. dtdac2.Columns.AddRange(new DataColumn[] {
  4602. new DataColumn(){ ColumnName = "city"},
  4603. new DataColumn(){ ColumnName = "curr"},
  4604. new DataColumn(){ ColumnName = "criterion"},
  4605. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4606. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4607. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4608. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4609. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4610. });
  4611. dtdac1.TableName = "tb1";
  4612. dtdac2.TableName = "tb2";
  4613. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4614. foreach (var item in dac1)
  4615. {
  4616. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4617. if (place.Contains(item.Place))
  4618. {
  4619. continue;
  4620. }
  4621. DataRow row = dtdac1.NewRow();
  4622. row["city"] = item.Place;
  4623. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4624. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4625. row["curr"] = currency;
  4626. row["rate"] = rate.ToString("#0.0000");
  4627. row["criterion"] = item.Cost.ToString("#0.00");
  4628. row["number"] = 1;
  4629. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4630. //row["costRMB"] = rbmPrice;
  4631. dtdac1.Rows.Add(row);
  4632. place.Add(item.Place);
  4633. }
  4634. place = new List<string>();
  4635. foreach (var item in dac2)
  4636. {
  4637. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4638. if (place.Contains(item.Place))
  4639. {
  4640. continue;
  4641. }
  4642. DataRow row = dtdac2.NewRow();
  4643. row["city"] = item.Place;
  4644. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4645. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4646. row["curr"] = currency;
  4647. row["rate"] = rate.ToString("#0.0000");
  4648. row["criterion"] = item.Cost.ToString("#0.00");
  4649. row["number"] = 1;
  4650. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4651. //row["cost"] = item.SubTotal;
  4652. //row["costRMB"] = rbmPrice;
  4653. dtdac2.Rows.Add(row);
  4654. place.Add(item.Place);
  4655. //dac2totalPrice += rbmPrice;
  4656. }
  4657. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4658. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4659. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4660. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4661. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4662. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4663. string cell4Str1 = string.Empty;
  4664. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4665. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4666. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4667. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4668. string cellStr = $" 5.其他费用(";
  4669. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4670. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4671. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4672. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4673. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4674. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4675. if (cellStr.Length > 8)
  4676. {
  4677. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4678. }
  4679. cellStr += ")";
  4680. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4681. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4682. decimal pxFee = dac4.Sum(it => it.Cost);
  4683. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4684. string celllastStr1 = "";
  4685. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4686. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4687. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4688. celllastStr1 += $",国际旅费 元";
  4689. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4690. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4691. designer.SetDataSource("cell4Str", cell4Str);
  4692. designer.SetDataSource("cellStr", cellStr);
  4693. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4694. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4695. designer.SetDataSource("celllastStr", celllastStr);
  4696. Workbook wb = designer.Workbook;
  4697. var sheet = wb.Worksheets[0];
  4698. //绑定datatable数据集
  4699. designer.SetDataSource(dtdac1);
  4700. designer.SetDataSource(dtdac2);
  4701. designer.Process();
  4702. var rowStart = dtdac1.Rows.Count;
  4703. while (rowStart > 0)
  4704. {
  4705. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4706. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4707. startIndex++;
  4708. rowStart--;
  4709. }
  4710. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4711. startIndex += 1; //总计行
  4712. rowStart = dtdac2.Rows.Count;
  4713. while (rowStart > 0)
  4714. {
  4715. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4716. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4717. startIndex++;
  4718. rowStart--;
  4719. }
  4720. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4721. wb.CalculateFormula(true);
  4722. //模板文件名
  4723. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4724. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4725. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4726. return Ok(JsonView(true, "成功", new { Url = url }));
  4727. }
  4728. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4729. {
  4730. //获取模板
  4731. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4732. //载入模板
  4733. Document doc = new Document(tempPath);
  4734. DocumentBuilder builder = new DocumentBuilder(doc);
  4735. Dictionary<string, string> dic = new Dictionary<string, string>();
  4736. dic.Add("GroupName", _DelegationInfo.TeamName);
  4737. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4738. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4739. string missionLeaderJob = "";//负责人job
  4740. int groupNumber = 0; //团人数
  4741. if (DeleClientList.Count > 0)
  4742. {
  4743. missionLeader = DeleClientList[0]?.Name ?? "";
  4744. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4745. }
  4746. dic.Add("MissionLeader", missionLeader); //团负责人
  4747. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4748. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4749. #region MyRegion
  4750. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4751. //{
  4752. // List<string> list = new List<string>();
  4753. // try
  4754. // {
  4755. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4756. // foreach (var item in spilitArr)
  4757. // {
  4758. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4759. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4760. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4761. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4762. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4763. // list.Add(depName);
  4764. // list.Add(arrName);
  4765. // }
  4766. // list = list.Distinct().ToList();
  4767. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4768. // }
  4769. // catch (Exception)
  4770. // {
  4771. // dic.Add("ReturnCode", "行程录入不正确!");
  4772. // }
  4773. //}
  4774. //else
  4775. //{
  4776. // dic.Add("ReturnCode", "未录入行程!");
  4777. //}
  4778. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4779. dic.Add("ReturnCode", string.Join("、", countrys));
  4780. #endregion
  4781. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4782. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4783. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4784. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4785. //{
  4786. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4787. // dic.Add("Day", sp.Days.ToString());
  4788. //}
  4789. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4790. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4791. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4792. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4793. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4794. //培训人员名单
  4795. int cultivateRowIndex = 7;
  4796. foreach (var item in DeleClientList)
  4797. {
  4798. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4799. builder.Write(item.Name);
  4800. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4801. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4802. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4803. string birthDay = "";
  4804. if (item.Birthday != null)
  4805. {
  4806. DateTime dt = Convert.ToDateTime(item.Birthday);
  4807. birthDay = $"{dt.Year}.{dt.Month}";
  4808. }
  4809. builder.Write(birthDay);
  4810. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4811. builder.Write(item.Company);
  4812. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4813. builder.Write(item.Job);
  4814. cultivateRowIndex++;
  4815. }
  4816. //删除多余行
  4817. //cultivateRowIndex -= 2;
  4818. int delRows = 10 + 7 - cultivateRowIndex;
  4819. if (delRows > 0)
  4820. {
  4821. for (int i = 0; i < delRows; i++)
  4822. {
  4823. table1.Rows.RemoveAt(cultivateRowIndex);
  4824. //cultivateRowIndex++;
  4825. }
  4826. }
  4827. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4828. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4829. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4830. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4831. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4832. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4833. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4834. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4835. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4836. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4837. //其他费用
  4838. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4839. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4840. //其他费用合计
  4841. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4842. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4843. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4844. //公务舱合计
  4845. //国际旅费
  4846. string outsideJJ = "";
  4847. string allPriceJJ = "";
  4848. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4849. {
  4850. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4851. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4852. }
  4853. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4854. {
  4855. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4856. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4857. }
  4858. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4859. {
  4860. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4861. dic.Add("AirFeeTotal", airFeeTotalStr);
  4862. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4863. dic.Add("FeeTotal", feeTotalStr);
  4864. }
  4865. foreach (var key in dic.Keys)
  4866. {
  4867. builder.MoveToBookmark(key);
  4868. builder.Write(dic[key]);
  4869. }
  4870. //模板文件名
  4871. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4872. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4873. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4874. return Ok(JsonView(true, "成功", new { Url = url }));
  4875. }
  4876. }
  4877. else if (dto.ExportType == 2) //表格
  4878. {
  4879. //利用键值对存放数据
  4880. Dictionary<string, string> dic = new Dictionary<string, string>();
  4881. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4882. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4883. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4884. dic.Add("Day", sp.Days.ToString());
  4885. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4886. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4887. {
  4888. //获取模板
  4889. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4890. //载入模板
  4891. Document doc = new Document(tempPath);
  4892. DocumentBuilder builder = new DocumentBuilder(doc);
  4893. dic.Add("TeamName", _DelegationInfo.TeamName);
  4894. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4895. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4896. string missionLeaderName = "",
  4897. missionLeaderJob = "";
  4898. if (DeleClientList.Count > 0)
  4899. {
  4900. missionLeaderName = DeleClientList[0].Name;
  4901. missionLeaderJob = DeleClientList[0].Job;
  4902. }
  4903. dic.Add("MissionLeaderName", missionLeaderName);
  4904. dic.Add("MissionLeaderJob", missionLeaderJob);
  4905. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4906. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4907. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4908. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4909. int rowCount = 10;//总人数行
  4910. int startRowIndex = 7; //起始行
  4911. for (int i = 0; i < DeleClientList.Count; i++)
  4912. {
  4913. builder.MoveToCell(0, startRowIndex, 0, 0);
  4914. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4915. builder.MoveToCell(0, startRowIndex, 1, 0);
  4916. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4917. builder.Write(sex);//性别
  4918. builder.MoveToCell(0, startRowIndex, 2, 0);
  4919. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4920. builder.MoveToCell(0, startRowIndex, 3, 0);
  4921. builder.Write(DeleClientList[i].Company);//工作单位
  4922. builder.MoveToCell(0, startRowIndex, 4, 0);
  4923. builder.Write(DeleClientList[i].Job);//职务及级别
  4924. builder.MoveToCell(0, startRowIndex, 5, 0);
  4925. builder.Write("");//人员属性
  4926. builder.MoveToCell(0, startRowIndex, 6, 0);
  4927. builder.Write("");//上次出国时间
  4928. startRowIndex++;
  4929. }
  4930. int nullRow = rowCount - DeleClientList.Count;//空行
  4931. for (int i = 0; i < nullRow; i++)
  4932. {
  4933. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4934. }
  4935. foreach (var key in dic.Keys)
  4936. {
  4937. builder.MoveToBookmark(key);
  4938. builder.Write(dic[key]);
  4939. }
  4940. //模板文件名
  4941. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4942. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4943. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4944. return Ok(JsonView(true, "成功", new { Url = url }));
  4945. }
  4946. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4947. {
  4948. //获取模板
  4949. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4950. //载入模板
  4951. Document doc = new Document(tempPath);
  4952. DocumentBuilder builder = new DocumentBuilder(doc);
  4953. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4954. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4955. dic.Add("Names", Names);
  4956. int accommodationRows = 12, foodandotherRows = 12;
  4957. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4958. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4959. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4960. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4961. int accommodationStartIndex = 6;
  4962. decimal dac1totalPrice = 0.00M;
  4963. foreach (var dac in dac1)
  4964. {
  4965. if (dac.SubTotal == 0)
  4966. {
  4967. continue;
  4968. }
  4969. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4970. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4971. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4972. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4973. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4974. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4975. builder.Write(currency);//币种
  4976. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4977. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4978. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4979. builder.Write("");//人数
  4980. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4981. builder.Write("");//天数
  4982. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4983. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4984. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4985. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4986. builder.Write(rate.ToString("#0.0000"));//汇率
  4987. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4988. decimal rbmPrice = rate * dac.SubTotal;
  4989. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4990. accommodationStartIndex++;
  4991. dac1totalPrice += rbmPrice;
  4992. }
  4993. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4994. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4995. builder.Write("小计");
  4996. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4997. builder.Write(dac1totalPrice.ToString("#0.00"));
  4998. accommodationStartIndex++;
  4999. int nullRow = accommodationRows - dac1.Count;
  5000. //删除空行
  5001. //if (nullRow > 0)
  5002. //{
  5003. // int rowIndex = accommodationStartIndex;
  5004. // for (int i = 0; i < nullRow; i++)
  5005. // {
  5006. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5007. // row.Remove();
  5008. // rowIndex++;
  5009. // }
  5010. //}
  5011. if (dac2.Count == dac3.Count)//国家 币种 金额
  5012. {
  5013. for (int i = 0; i < dac2.Count; i++)
  5014. {
  5015. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5016. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5017. }
  5018. }
  5019. int foodandotherStartIndex = 19;//
  5020. decimal dac2totalPrice = 0.00M;
  5021. foreach (var dac in dac2)
  5022. {
  5023. if (dac.SubTotal == 0)
  5024. {
  5025. continue;
  5026. }
  5027. //foodandotherStartIndex = 12;
  5028. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5029. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5030. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5031. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5032. builder.Write(currency);//币种
  5033. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5034. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5035. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5036. builder.Write("");//人数
  5037. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5038. builder.Write("");//天数
  5039. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5040. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5041. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5042. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5043. builder.Write(rate.ToString("#0.0000"));//汇率
  5044. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5045. decimal rbmPrice = rate * dac.SubTotal;
  5046. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5047. foodandotherStartIndex++;
  5048. dac2totalPrice += rbmPrice;
  5049. }
  5050. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5051. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5052. //删除空行
  5053. //if (dac2.Count < foodandotherRows)
  5054. //{
  5055. // while (table2.Rows.Count > dac2.Count)
  5056. // {
  5057. // table2.Rows.RemoveAt(dac2.Count);
  5058. // }
  5059. //}
  5060. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5061. string otherFeeStr = "";
  5062. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5063. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5064. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5065. if (otherFeeStr.Length > 0)
  5066. {
  5067. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5068. otherFeeStr = $"({otherFeeStr})";
  5069. dic.Add("OtherFeeStr", otherFeeStr);
  5070. }
  5071. foreach (var key in dic.Keys)
  5072. {
  5073. builder.MoveToBookmark(key);
  5074. builder.Write(dic[key]);
  5075. }
  5076. //模板文件名
  5077. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5078. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5079. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5080. return Ok(JsonView(true, "成功", new { Url = url }));
  5081. }
  5082. }
  5083. else if (dto.ExportType == 3)
  5084. {
  5085. if (dto.SubTypeId == 1) //团组成员名单
  5086. {
  5087. if (DeleClientList.Count < 1)
  5088. {
  5089. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5090. }
  5091. //获取模板
  5092. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5093. //载入模板
  5094. Document doc = new Document(tempPath);
  5095. DocumentBuilder builder = new DocumentBuilder(doc);
  5096. //获取word里所有表格
  5097. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5098. //获取所填表格的序数
  5099. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5100. var rowStart = tableOne.Rows[0]; //获取第1行
  5101. //循环赋值
  5102. for (int i = 0; i < DeleClientList.Count; i++)
  5103. {
  5104. builder.MoveToCell(0, i + 1, 0, 0);
  5105. builder.Write(DeleClientList[i].Name);
  5106. builder.MoveToCell(0, i + 1, 1, 0);
  5107. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5108. builder.Write(sex);
  5109. builder.MoveToCell(0, i + 1, 2, 0);
  5110. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5111. builder.MoveToCell(0, i + 1, 3, 0);
  5112. builder.Write(DeleClientList[i].Company);
  5113. builder.MoveToCell(0, i + 1, 4, 0);
  5114. builder.Write(DeleClientList[i].Job);
  5115. }
  5116. //删除多余行
  5117. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5118. {
  5119. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5120. }
  5121. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5122. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5123. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5124. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5125. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5126. return Ok(JsonView(true, "成功", new { Url = url }));
  5127. }
  5128. }
  5129. return Ok(JsonView(false, "操作失败!"));
  5130. }
  5131. catch (Exception ex)
  5132. {
  5133. return Ok(JsonView(false, ex.Message));
  5134. }
  5135. }
  5136. /// <summary>
  5137. /// 获取三公费用标准city
  5138. /// </summary>
  5139. /// <param name="placeData"></param>
  5140. /// <param name="nationalTravelFeeId"></param>
  5141. /// <returns></returns>
  5142. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5143. {
  5144. string _city = string.Empty;
  5145. if (placeData.Count < 1) return _city;
  5146. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5147. if (data == null) return _city;
  5148. string country = data.Country;
  5149. string city = data.City;
  5150. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5151. else _city = city;
  5152. return _city;
  5153. }
  5154. /// <summary>
  5155. /// 团组模块 - 出入境费用 - 明细表导出
  5156. /// </summary>
  5157. /// <returns></returns>
  5158. [HttpPost]
  5159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5160. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5161. {
  5162. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5163. if (data.Code != 0)
  5164. {
  5165. return Ok(JsonView(false, data.Msg));
  5166. }
  5167. return Ok(JsonView(true, data.Msg, data.Data));
  5168. }
  5169. /// <summary>
  5170. /// 团组模块 - 出入境费用 - 一键清空
  5171. /// </summary>
  5172. /// <returns></returns>
  5173. [HttpPost]
  5174. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5175. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5176. {
  5177. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5178. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5179. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5180. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5181. if (_view.Code == 0)
  5182. {
  5183. return Ok(JsonView(true, "操作成功"));
  5184. }
  5185. return Ok(JsonView(false, "操作失败"));
  5186. }
  5187. /// <summary>
  5188. /// 团组模块 - 出入境费用 - 子项删除
  5189. /// </summary>
  5190. /// <returns></returns>
  5191. [HttpPost]
  5192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5193. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5194. {
  5195. try
  5196. {
  5197. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5198. if (data.Code != 0)
  5199. {
  5200. return Ok(JsonView(false, data.Msg));
  5201. }
  5202. return Ok(JsonView(true, "操作成功!", data.Data));
  5203. }
  5204. catch (Exception ex)
  5205. {
  5206. return Ok(JsonView(false, ex.Message));
  5207. }
  5208. }
  5209. /// <summary>
  5210. /// 团组模块 - 出入境国家费用标准 List
  5211. /// </summary>
  5212. /// <returns></returns>
  5213. [HttpPost]
  5214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5215. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5216. {
  5217. try
  5218. {
  5219. Stopwatch sw = new Stopwatch();
  5220. sw.Start();
  5221. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5222. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5223. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5224. Where gntf.Isdel = 0");
  5225. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5226. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5227. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5228. //foreach (var item in nationalTravel)
  5229. //{
  5230. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5231. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5232. // if (otherData != null)
  5233. // {
  5234. // cityData.Remove(otherData);
  5235. // cityData.Add(otherData);
  5236. // }
  5237. // nationalTravelFeeData1.Add(new
  5238. // {
  5239. // Country = item.Country,
  5240. // CityData = cityData
  5241. // });
  5242. //}
  5243. sw.Stop();
  5244. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5245. }
  5246. catch (Exception ex)
  5247. {
  5248. return Ok(JsonView(false, ex.Message));
  5249. throw;
  5250. }
  5251. }
  5252. /// <summary>
  5253. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5254. /// </summary>
  5255. /// <returns></returns>
  5256. [HttpPost]
  5257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5258. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5259. {
  5260. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5261. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5262. List<string> countryData = new List<string>();
  5263. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5264. countryData = countryData.Distinct().ToList();
  5265. List<dynamic> dataSource = new List<dynamic>();
  5266. foreach (var item in countryData)
  5267. {
  5268. List<string> cityData1 = new List<string>();
  5269. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5270. var countryData2 = new
  5271. {
  5272. CountryName = item,
  5273. CityData = cityData1
  5274. };
  5275. dataSource.Add(countryData2);
  5276. }
  5277. return Ok(JsonView(true, "查询成功!", dataSource));
  5278. }
  5279. /// <summary>
  5280. /// 团组模块 - 出入境国家费用标准 Page List
  5281. /// </summary>
  5282. /// <returns></returns>
  5283. [HttpPost]
  5284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5285. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5286. {
  5287. int portId = dto.PortType;
  5288. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5289. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5290. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5291. string whereSql = string.Empty;
  5292. if (!string.IsNullOrEmpty(dto.Country))
  5293. {
  5294. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5295. }
  5296. if (!string.IsNullOrEmpty(dto.City))
  5297. {
  5298. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5299. }
  5300. string pageSql = string.Format(@"Select * From (
  5301. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5302. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5303. From Grp_NationalTravelFee gntf
  5304. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5305. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5306. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5307. RefAsync<int> total = 0;
  5308. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5309. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5310. }
  5311. /// <summary>
  5312. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5313. /// </summary>
  5314. /// <returns></returns>
  5315. [HttpPost]
  5316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5317. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5318. {
  5319. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5320. int portId = dto.PortType;
  5321. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5322. string whereSql = string.Empty;
  5323. if (!string.IsNullOrEmpty(dto.Country))
  5324. {
  5325. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5326. }
  5327. if (!string.IsNullOrEmpty(dto.City))
  5328. {
  5329. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5330. }
  5331. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5332. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5333. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5334. From Grp_NationalTravelFee gntf
  5335. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5336. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5337. Where gntf.Isdel = 0 {0} ", whereSql);
  5338. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5339. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5340. }
  5341. /// <summary>
  5342. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5343. /// </summary>
  5344. /// <returns></returns>
  5345. [HttpPost]
  5346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5347. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5348. {
  5349. try
  5350. {
  5351. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5352. if (data.Code != 0)
  5353. {
  5354. return Ok(JsonView(false, data.Msg));
  5355. }
  5356. return Ok(JsonView(true, "操作成功!", data.Data));
  5357. }
  5358. catch (Exception ex)
  5359. {
  5360. return Ok(JsonView(false, ex.Message));
  5361. }
  5362. }
  5363. /// <summary>
  5364. /// 团组模块 - 出入境国家费用标准 - Del
  5365. /// </summary>
  5366. /// <returns></returns>
  5367. [HttpPost]
  5368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5369. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5370. {
  5371. try
  5372. {
  5373. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5374. {
  5375. Id = dto.Id,
  5376. DeleteUserId = dto.DeleteUserId,
  5377. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5378. IsDel = 1
  5379. };
  5380. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5381. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5382. .WhereColumns(it => new { it.Id })
  5383. .ExecuteCommandAsync();
  5384. if (delStatus <= 0)
  5385. {
  5386. return Ok(JsonView(false, "删除失败!"));
  5387. }
  5388. return Ok(JsonView(true, "操作成功!"));
  5389. }
  5390. catch (Exception ex)
  5391. {
  5392. return Ok(JsonView(false, ex.Message));
  5393. }
  5394. }
  5395. #endregion
  5396. #region 签证费用录入
  5397. /// <summary>
  5398. /// 根据diid查询签证费用列表
  5399. /// </summary>
  5400. /// <param name="dto"></param>
  5401. /// <returns></returns>
  5402. [HttpPost]
  5403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5404. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5405. {
  5406. try
  5407. {
  5408. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5409. if (groupData.Code != 0)
  5410. {
  5411. return Ok(JsonView(false, groupData.Msg));
  5412. }
  5413. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5414. }
  5415. catch (Exception ex)
  5416. {
  5417. return Ok(JsonView(false, ex.Message));
  5418. }
  5419. }
  5420. /// <summary>
  5421. /// 根据签证费用Id查询单条数据及c表数据
  5422. /// </summary>
  5423. /// <param name="dto"></param>
  5424. /// <returns></returns>
  5425. [HttpPost]
  5426. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5427. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5428. {
  5429. try
  5430. {
  5431. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5432. if (groupData.Code != 0)
  5433. {
  5434. return Ok(JsonView(false, groupData.Msg));
  5435. }
  5436. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5437. }
  5438. catch (Exception ex)
  5439. {
  5440. return Ok(JsonView(false, ex.Message));
  5441. }
  5442. }
  5443. /// <summary>
  5444. /// 签证费用删除
  5445. /// </summary>
  5446. /// <param name="dto"></param>
  5447. /// <returns></returns>
  5448. [HttpPost]
  5449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5450. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5451. {
  5452. _sqlSugar.BeginTran();
  5453. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5454. if (!res)
  5455. {
  5456. _sqlSugar.RollbackTran();
  5457. return Ok(JsonView(false, "删除失败"));
  5458. }
  5459. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5460. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5461. .SetColumns(a => new Grp_CreditCardPayment()
  5462. {
  5463. IsDel = 1,
  5464. DeleteUserId = dto.DeleteUserId,
  5465. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5466. }).ExecuteCommand();
  5467. if (resSub < 1)
  5468. {
  5469. _sqlSugar.RollbackTran();
  5470. return Ok(JsonView(false, "删除失败"));
  5471. }
  5472. _sqlSugar.CommitTran();
  5473. return Ok(JsonView(true, "删除成功!"));
  5474. }
  5475. /// <summary>
  5476. /// 签证费用录入下拉框初始化
  5477. /// </summary>
  5478. /// <returns></returns>
  5479. [HttpPost]
  5480. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5481. public async Task<IActionResult> VisaPriceAddSelect()
  5482. {
  5483. try
  5484. {
  5485. //支付方式
  5486. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5487. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5488. //币种
  5489. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5490. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5491. //乘客类型
  5492. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5493. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5494. //卡类型
  5495. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5496. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5497. var data = new
  5498. {
  5499. Payment = _Payment,
  5500. CurrencyList = _CurrencyList,
  5501. PassengerType = _PassengerType,
  5502. BankCard = _BankCard
  5503. };
  5504. return Ok(JsonView(true, "查询成功!", data));
  5505. }
  5506. catch (Exception ex)
  5507. {
  5508. return Ok(JsonView(false, "程序错误!"));
  5509. throw;
  5510. }
  5511. }
  5512. /// <summary>
  5513. /// 签证费用录入操作(Status:1.新增,2.修改)
  5514. /// </summary>
  5515. /// <param name="dto"></param>
  5516. /// <returns></returns>
  5517. [HttpPost]
  5518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5519. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5520. {
  5521. try
  5522. {
  5523. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5524. if (groupData.Code != 0)
  5525. {
  5526. return Ok(JsonView(false, groupData.Msg));
  5527. }
  5528. #region 应用推送
  5529. try
  5530. {
  5531. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5532. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5533. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5534. }
  5535. catch (Exception ex)
  5536. {
  5537. }
  5538. #endregion
  5539. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5540. }
  5541. catch (Exception ex)
  5542. {
  5543. return Ok(JsonView(false, ex.Message));
  5544. }
  5545. }
  5546. #endregion
  5547. #region 签证提成录入
  5548. /// <summary>
  5549. /// 签证提成录入
  5550. /// 基础数据
  5551. /// </summary>
  5552. /// <param name="_dto"></param>
  5553. /// <returns></returns>
  5554. [HttpGet]
  5555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5556. public async Task<IActionResult> VisaCommissionInit()
  5557. {
  5558. return Ok(await _visaCommissionRep.Init());
  5559. }
  5560. /// <summary>
  5561. /// 签证提成录入
  5562. /// Item
  5563. /// </summary>
  5564. /// <param name="_dto"></param>
  5565. /// <returns></returns>
  5566. [HttpPost]
  5567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5568. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  5569. {
  5570. var validator = new VisaCommissionItemDtoValidator();
  5571. var validatorRes = await validator.ValidateAsync(_dto);
  5572. if (!validatorRes.IsValid)
  5573. {
  5574. StringBuilder sb = new StringBuilder();
  5575. foreach (var item in validatorRes.Errors)
  5576. {
  5577. sb.AppendLine(item.ErrorMessage);
  5578. }
  5579. return Ok(JsonView(false, sb.ToString()));
  5580. }
  5581. return Ok(await _visaCommissionRep.Item(_dto));
  5582. }
  5583. /// <summary>
  5584. /// 签证提成录入
  5585. /// Create
  5586. /// </summary>
  5587. /// <param name="_dto"></param>
  5588. /// <returns></returns>
  5589. [HttpPost]
  5590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5591. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  5592. {
  5593. var validator = new VisaCommissionCreateDtoValidator();
  5594. var validatorRes = await validator.ValidateAsync(_dto);
  5595. if (!validatorRes.IsValid)
  5596. {
  5597. StringBuilder sb = new StringBuilder();
  5598. foreach (var item in validatorRes.Errors)
  5599. {
  5600. sb.AppendLine(item.ErrorMessage);
  5601. }
  5602. return Ok(JsonView(false, sb.ToString()));
  5603. }
  5604. return Ok(await _visaCommissionRep.Create(_dto));
  5605. }
  5606. /// <summary>
  5607. /// 签证提成录入
  5608. /// Put(编辑)
  5609. /// </summary>
  5610. /// <param name="id"></param>
  5611. /// <param name="_dto"></param>
  5612. /// <returns></returns>
  5613. [HttpPut]
  5614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5615. public async Task<IActionResult> VisaCommissionEdit(int id,VisaCommissionCreateDto _dto)
  5616. {
  5617. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5618. var validator = new VisaCommissionCreateDtoValidator();
  5619. var validatorRes = await validator.ValidateAsync(_dto);
  5620. if (!validatorRes.IsValid)
  5621. {
  5622. StringBuilder sb = new StringBuilder();
  5623. foreach (var item in validatorRes.Errors)
  5624. {
  5625. sb.AppendLine(item.ErrorMessage);
  5626. }
  5627. return Ok(JsonView(false, sb.ToString()));
  5628. }
  5629. return Ok(await _visaCommissionRep.Edit(id,_dto));
  5630. }
  5631. /// <summary>
  5632. /// 签证提成录入
  5633. /// Del
  5634. /// </summary>
  5635. /// <param name="id"></param>
  5636. /// <param name="currUserId"></param>
  5637. /// <returns></returns>
  5638. [HttpPost]
  5639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5640. public async Task<IActionResult> VisaCommissionDel(int id,int currUserId)
  5641. {
  5642. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  5643. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  5644. return Ok(await _visaCommissionRep.Del(id, currUserId));
  5645. }
  5646. #endregion
  5647. #region op费用录入
  5648. /// <summary>
  5649. /// 根据diid查询op费用列表
  5650. /// </summary>
  5651. /// <param name="dto"></param>
  5652. /// <returns></returns>
  5653. [HttpPost]
  5654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5655. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5656. {
  5657. try
  5658. {
  5659. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5660. if (groupData.Code != 0)
  5661. {
  5662. return Ok(JsonView(false, groupData.Msg));
  5663. }
  5664. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5665. }
  5666. catch (Exception ex)
  5667. {
  5668. return Ok(JsonView(false, ex.Message));
  5669. }
  5670. }
  5671. /// <summary>
  5672. /// 根据op费用Id查询单条数据及c表数据
  5673. /// </summary>
  5674. /// <param name="dto"></param>
  5675. /// <returns></returns>
  5676. [HttpPost]
  5677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5678. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5679. {
  5680. try
  5681. {
  5682. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5683. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5684. var data = new
  5685. {
  5686. CarTouristGuideGround = _groupData,
  5687. CreditCardPayment = _creditCardPayment
  5688. };
  5689. return Ok(JsonView(true, "查询成功!", data));
  5690. }
  5691. catch (Exception ex)
  5692. {
  5693. return Ok(JsonView(false, "程序错误!"));
  5694. }
  5695. }
  5696. /// <summary>
  5697. /// op费用删除
  5698. /// </summary>
  5699. /// <param name="dto"></param>
  5700. /// <returns></returns>
  5701. [HttpPost]
  5702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5703. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5704. {
  5705. try
  5706. {
  5707. _sqlSugar.BeginTran();
  5708. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5709. if (!res)
  5710. {
  5711. return Ok(JsonView(false, "删除失败"));
  5712. }
  5713. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5714. {
  5715. IsDel = 1,
  5716. DeleteUserId = dto.DeleteUserId,
  5717. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5718. }).ExecuteCommandAsync();
  5719. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5720. {
  5721. IsDel = 1,
  5722. DeleteUserId = dto.DeleteUserId,
  5723. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5724. }).ExecuteCommandAsync();
  5725. #region 删除超支相关数据
  5726. //删除导入的超支数据
  5727. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5728. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5729. {
  5730. IsDel = 1,
  5731. DeleteUserId = dto.DeleteUserId,
  5732. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5733. }).ExecuteCommand();
  5734. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5735. {
  5736. IsDel = 1,
  5737. DeleteUserId = dto.DeleteUserId,
  5738. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5739. }).ExecuteCommand() ;
  5740. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5741. {
  5742. IsDel = 1,
  5743. DeleteUserId = dto.DeleteUserId,
  5744. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5745. }).ExecuteCommand();
  5746. #endregion
  5747. _sqlSugar.CommitTran();
  5748. return Ok(JsonView(true, "删除成功!"));
  5749. }
  5750. catch (Exception ex)
  5751. {
  5752. _sqlSugar.RollbackTran();
  5753. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5754. }
  5755. }
  5756. /// <summary>
  5757. /// op费用录入操作(Status:1.新增,2.修改)
  5758. /// </summary>
  5759. /// <param name="dto"></param>
  5760. /// <returns></returns>
  5761. [HttpPost]
  5762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5763. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5764. {
  5765. try
  5766. {
  5767. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5768. if (groupData.Code != 0)
  5769. {
  5770. return Ok(JsonView(false, groupData.Msg));
  5771. }
  5772. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5773. }
  5774. catch (Exception ex)
  5775. {
  5776. return Ok(JsonView(false, ex.Message));
  5777. }
  5778. }
  5779. /// <summary>
  5780. /// 填写费用详细页面初始化绑定
  5781. /// </summary>
  5782. /// <param name="dto"></param>
  5783. /// <returns></returns>
  5784. [HttpPost]
  5785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5786. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5787. {
  5788. try
  5789. {
  5790. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5791. if (groupData.Code != 0)
  5792. {
  5793. return Ok(JsonView(false, groupData.Msg));
  5794. }
  5795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5796. }
  5797. catch (Exception ex)
  5798. {
  5799. return Ok(JsonView(false, ex.Message));
  5800. }
  5801. }
  5802. /// <summary>
  5803. /// 根据op费用Id查询详细数据
  5804. /// </summary>
  5805. /// <param name="dto"></param>
  5806. /// <returns></returns>
  5807. [HttpPost]
  5808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5809. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5810. {
  5811. try
  5812. {
  5813. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5814. if (groupData.Code != 0)
  5815. {
  5816. return Ok(JsonView(false, groupData.Msg));
  5817. }
  5818. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5819. }
  5820. catch (Exception ex)
  5821. {
  5822. return Ok(JsonView(false, ex.Message));
  5823. }
  5824. }
  5825. /// <summary>
  5826. /// OP费用录入填写详情
  5827. /// </summary>
  5828. /// <param name="dto"></param>
  5829. /// <returns></returns>
  5830. [HttpPost]
  5831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5832. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5833. {
  5834. try
  5835. {
  5836. #region 参数校验
  5837. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5838. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5839. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5840. #endregion
  5841. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5842. if (groupData.Code != 0)
  5843. {
  5844. return Ok(JsonView(false, groupData.Msg));
  5845. }
  5846. //自动审核
  5847. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5848. #region 应用推送
  5849. try
  5850. {
  5851. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5852. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5853. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5854. }
  5855. catch (Exception ex)
  5856. {
  5857. }
  5858. #endregion
  5859. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5860. }
  5861. catch (Exception ex)
  5862. {
  5863. return Ok(JsonView(false, ex.Message));
  5864. }
  5865. }
  5866. /// <summary>
  5867. /// 获取三公详细所有城市
  5868. /// </summary>
  5869. /// <returns></returns>
  5870. [HttpGet]
  5871. public IActionResult OpCarCityResult()
  5872. {
  5873. var jw = JsonView(false);
  5874. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5875. {
  5876. x.Id,
  5877. x.Country,
  5878. x.City,
  5879. }).ToList();
  5880. if (data.Count > 0)
  5881. {
  5882. jw = JsonView(true, "获取成功!", data);
  5883. }
  5884. else
  5885. {
  5886. jw.Msg = "城市数据为空!";
  5887. jw.Data = new string[0];
  5888. }
  5889. return Ok(jw);
  5890. }
  5891. /// <summary>
  5892. /// 导出地接费用明细
  5893. /// </summary>
  5894. /// <param name="dto"></param>
  5895. /// <returns></returns>
  5896. [HttpPost]
  5897. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5898. {
  5899. var jw = JsonView(false);
  5900. if (dto.Diid < 1)
  5901. {
  5902. jw.Msg = "请输入正确的diid!";
  5903. return Ok(jw);
  5904. }
  5905. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5906. if (group == null)
  5907. {
  5908. jw.Msg = "未找到团组信息!";
  5909. return Ok(jw);
  5910. }
  5911. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5912. if (localGuideArr.Count == 0)
  5913. {
  5914. jw.Msg = "该团组暂无地接信息!";
  5915. return Ok(jw);
  5916. }
  5917. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5918. var overspendSoure = new Dictionary<int, int>
  5919. {
  5920. { 91, 982 }, //车
  5921. { 92 , 1059} ,//导游
  5922. { 994 , 1073}, //翻译
  5923. { 988 , 1074 }, //早餐
  5924. { 93 , 1075 }, //午餐
  5925. { 989 , 1076 }, //晚餐
  5926. };
  5927. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5928. foreach (var groupArr in localGroup)
  5929. {
  5930. var keyValue = groupArr.Key;
  5931. if (int.TryParse(keyValue, out int cityid))
  5932. {
  5933. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5934. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5935. }
  5936. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5937. foreach (var item in groupArr)
  5938. {
  5939. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5940. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5941. new Grp_CarTouristGuideGroundReservationsContentExtend
  5942. {
  5943. Count = a.Count,
  5944. CreateTime = a.CreateTime,
  5945. CreateUserId = a.CreateUserId,
  5946. CTGGRId = a.CTGGRId,
  5947. Currency = a.Currency,
  5948. DatePrice = a.DatePrice,
  5949. DeleteTime = a.DeleteTime,
  5950. DeleteUserId = a.DeleteUserId,
  5951. DiId = a.DiId,
  5952. Id = a.Id,
  5953. IsDel = a.IsDel,
  5954. Price = a.Price,
  5955. PriceContent = a.PriceContent,
  5956. Remark = a.Remark,
  5957. SId = a.SId,
  5958. SidName = b.Name,
  5959. Units = a.Units,
  5960. }
  5961. ).ToList();
  5962. if (content.Count > 0)
  5963. {
  5964. contentArr.Add(content);
  5965. }
  5966. }
  5967. //open excel
  5968. //set excel
  5969. //save excel
  5970. try
  5971. {
  5972. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5973. IWorkbook workbook;
  5974. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5975. {
  5976. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5977. }
  5978. else
  5979. {
  5980. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5981. }
  5982. ISheet sheet = workbook.GetSheetAt(0);
  5983. var rowStartIndex = 2;
  5984. var clounmCount = 10;
  5985. var initStyleRow = sheet.GetRow(2);
  5986. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5987. //var overspendArrDetail =
  5988. var existsId = new List<CarCompare>();
  5989. var lastElem = arr.Last();
  5990. var thisSid = -1;
  5991. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5992. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5993. {
  5994. Name = "未知币种!",
  5995. Remark = "未知币种!",
  5996. };
  5997. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5998. Action cloneRowFn = () =>
  5999. {
  6000. rowStartIndex++;
  6001. var cloneRow = sheet.CreateRow(rowStartIndex);
  6002. // 复制样式
  6003. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  6004. {
  6005. ICell sourceCell = initStyleRow.GetCell(i);
  6006. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  6007. // 确保单元格存在样式
  6008. if (sourceCell.CellStyle != null)
  6009. {
  6010. targetCell.CellStyle = sourceCell.CellStyle;
  6011. }
  6012. }
  6013. };
  6014. var mergeRow = () =>
  6015. {
  6016. for (int i = 2; i < sheet.LastRowNum; i++)
  6017. {
  6018. var row = sheet.GetRow(i);
  6019. var cellFirst = row.GetCell(0);
  6020. var thisIndex = i + 1;
  6021. while (thisIndex < sheet.LastRowNum)
  6022. {
  6023. var nextRow = sheet.GetRow(thisIndex);
  6024. var nextCellFirst = nextRow.GetCell(0);
  6025. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  6026. {
  6027. thisIndex++;
  6028. }
  6029. else
  6030. {
  6031. break;
  6032. }
  6033. }
  6034. thisIndex--;
  6035. if (thisIndex != i)
  6036. {
  6037. //合并row
  6038. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6039. i, // 起始行索引(0-based)
  6040. thisIndex, // 结束行索引(0-based)
  6041. 0, // 起始列索引(0-based)
  6042. 0 // 结束列索引(0-based)
  6043. );
  6044. sheet.AddMergedRegion(cellRangeAddress);
  6045. i = thisIndex;
  6046. }
  6047. }
  6048. };
  6049. var chaoshiNumber = 0;
  6050. var totalNumber = 0.00M;
  6051. string lastStr = "";
  6052. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  6053. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  6054. {
  6055. b.IsAuditGM,
  6056. x.Id,
  6057. x.Area,
  6058. b.PayPercentage,
  6059. b.PayMoney,
  6060. }).ToList();
  6061. string yesPayment = "", noPayment = "";
  6062. foreach (var item in queryCarArrByCityAndDiid)
  6063. {
  6064. if (item.IsAuditGM == 1)
  6065. {
  6066. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6067. }
  6068. else
  6069. {
  6070. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6071. }
  6072. }
  6073. lastStr = yesPayment + noPayment;
  6074. foreach (var item in arr)
  6075. {
  6076. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6077. {
  6078. if (thisSid != item.SId)
  6079. {
  6080. if (thisSid == -1)
  6081. {
  6082. thisSid = item.SId;
  6083. }
  6084. else
  6085. {
  6086. //合并小计行
  6087. //创建合并区域的实例
  6088. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6089. rowStartIndex, // 起始行索引(0-based)
  6090. rowStartIndex, // 结束行索引(0-based)
  6091. 0, // 起始列索引(0-based)
  6092. 3 // 结束列索引(0-based)
  6093. );
  6094. sheet.AddMergedRegion(cellRangeAddress);
  6095. var CellStyle = workbook.CreateCellStyle();
  6096. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6097. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6098. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6099. for (int i = 0; i <= clounmCount; i++)
  6100. {
  6101. if (i > 6)
  6102. {
  6103. var CellStyle1 = workbook.CreateCellStyle();
  6104. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6105. IFont Font = workbook.CreateFont(); // 创建字体
  6106. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6107. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6108. CellStyle1.SetFont(Font);
  6109. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6110. }
  6111. else
  6112. {
  6113. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6114. }
  6115. }
  6116. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6117. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6118. //超时合计
  6119. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6120. //超时数
  6121. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6122. //超时合计费用
  6123. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6124. thisSid = item.SId;
  6125. cloneRowFn();
  6126. chaoshiNumber = 0;
  6127. totalNumber = 0;
  6128. }
  6129. }
  6130. IRow row = sheet.GetRow(rowStartIndex);
  6131. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6132. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6133. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6134. if (isOpenOverspendSoure)
  6135. {
  6136. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6137. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6138. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6139. }
  6140. for (int i = 0; i <= clounmCount; i++)
  6141. {
  6142. var cell = row.GetCell(i);
  6143. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6144. if (cell == null)
  6145. {
  6146. cell = row.CreateCell(i);
  6147. }
  6148. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6149. fontRed.CloneStyleFrom(cell.CellStyle);
  6150. IFont Font = workbook.CreateFont(); // 创建字体
  6151. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6152. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6153. fontRed.SetFont(Font);
  6154. byte[] rgb = new byte[3] { 255, 242, 204 };
  6155. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6156. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6157. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6158. if (workbook is XSSFWorkbook)
  6159. {
  6160. BackgroundColor255_242_204.FillForegroundColor = 0;
  6161. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6162. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6163. }
  6164. else
  6165. {
  6166. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6167. }
  6168. if (i == 1 || i > 6)
  6169. {
  6170. if (i > 6)
  6171. {
  6172. fontRed.FillForegroundColor = 0;
  6173. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6174. fontRed.FillPattern = FillPattern.SolidForeground;
  6175. }
  6176. cell.CellStyle = fontRed;
  6177. }
  6178. if (i > 2 && i < 7)
  6179. {
  6180. cell.CellStyle = BackgroundColor255_242_204;
  6181. }
  6182. cell.SetCellValue(setCellValue); //写入单元格
  6183. }
  6184. if (overspendSoure.ContainsKey(thisSid))
  6185. {
  6186. var overspendId = overspendSoure[thisSid];
  6187. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6188. }
  6189. cloneRowFn();
  6190. existsId.Add(new CarCompare
  6191. {
  6192. DataPrice = item.DatePrice.ObjToDate(),
  6193. Sid = item.SId
  6194. });
  6195. }
  6196. if (item.Equals(lastElem))
  6197. {
  6198. //合并小计行
  6199. //创建合并区域的实例
  6200. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6201. rowStartIndex, // 起始行索引(0-based)
  6202. rowStartIndex, // 结束行索引(0-based)
  6203. 0, // 起始列索引(0-based)
  6204. 3 // 结束列索引(0-based)
  6205. );
  6206. sheet.AddMergedRegion(cellRangeAddress);
  6207. var CellStyle = workbook.CreateCellStyle();
  6208. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6209. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6210. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6211. for (int i = 0; i <= clounmCount; i++)
  6212. {
  6213. if (i > 6)
  6214. {
  6215. var CellStyle1 = workbook.CreateCellStyle();
  6216. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6217. IFont Font = workbook.CreateFont(); // 创建字体
  6218. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6219. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6220. CellStyle1.SetFont(Font);
  6221. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6222. }
  6223. else
  6224. {
  6225. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6226. }
  6227. }
  6228. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6229. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6230. //超时合计
  6231. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6232. //超时数
  6233. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6234. //超时合计费用
  6235. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6236. cloneRowFn();
  6237. // 创建合并区域的实例
  6238. cellRangeAddress = new CellRangeAddress(
  6239. rowStartIndex, // 起始行索引(0-based)
  6240. rowStartIndex, // 结束行索引(0-based)
  6241. 0, // 起始列索引(0-based)
  6242. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6243. );
  6244. // 添加合并区域
  6245. sheet.AddMergedRegion(cellRangeAddress);
  6246. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6247. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6248. }
  6249. }
  6250. mergeRow();
  6251. // 保存修改后的Excel文件到新文件
  6252. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6253. // new FileStream(newFilePath, FileMode.CreateNew)
  6254. using (var stream = new MemoryStream())
  6255. {
  6256. workbook.Write(stream, true);
  6257. stream.Flush();
  6258. stream.Seek(0, SeekOrigin.Begin);
  6259. MemoryStream memoryStream = new MemoryStream();
  6260. stream.CopyTo(memoryStream);
  6261. memoryStream.Seek(0, SeekOrigin.Begin);
  6262. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6263. }
  6264. workbook.Close();
  6265. workbook.Dispose();
  6266. }
  6267. catch (Exception ex)
  6268. {
  6269. jw.Msg = "出现异常!" + ex.Message;
  6270. return Ok(jw);
  6271. }
  6272. }
  6273. if (Zips.Count > 0)
  6274. {
  6275. IOOperatorHelper io = new IOOperatorHelper();
  6276. var byts = io.ConvertZipStream(Zips);
  6277. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6278. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6279. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6280. }
  6281. else
  6282. {
  6283. jw.Msg = "暂无生成文件!";
  6284. }
  6285. return Ok(jw);
  6286. }
  6287. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6288. {
  6289. string outStr = string.Empty;
  6290. switch (i)
  6291. {
  6292. case 0:
  6293. outStr = arr[0].SidName;
  6294. break;
  6295. case 1:
  6296. outStr = arr[0].DataPriceStr;
  6297. break;
  6298. case 2:
  6299. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6300. break;
  6301. case 4:
  6302. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6303. break;
  6304. case 7:
  6305. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6306. {
  6307. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6308. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6309. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6310. }
  6311. break;
  6312. case 8:
  6313. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6314. {
  6315. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6316. }
  6317. break;
  6318. case 9:
  6319. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6320. {
  6321. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6322. }
  6323. break;
  6324. case 10:
  6325. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6326. {
  6327. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6328. }
  6329. break;
  6330. }
  6331. return outStr;
  6332. }
  6333. #region OP行程单
  6334. /// <summary>
  6335. /// OP行程单初始化
  6336. /// </summary>
  6337. /// <param name="dto"></param>
  6338. /// <returns></returns>
  6339. [HttpPost]
  6340. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6341. {
  6342. var jw = JsonView(false);
  6343. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6344. var group = groupList.First();
  6345. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6346. if (group == null)
  6347. {
  6348. jw.Msg = "暂无团组!";
  6349. return Ok(jw);
  6350. }
  6351. group = groupList.Find(x => x.Id == diid);
  6352. if (group == null)
  6353. {
  6354. jw.Msg = "请输入正确的团组ID!";
  6355. return Ok(jw);
  6356. }
  6357. string city = string.Empty;
  6358. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6359. if (blackCode.Count > 0)
  6360. {
  6361. var black = blackCode.First();
  6362. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6363. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6364. if (blackSp.Length > 0)
  6365. {
  6366. try
  6367. {
  6368. var cityArrCode = new List<string>(20);
  6369. foreach (var item in blackSp)
  6370. {
  6371. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6372. var IndexSelect = itemSp[2];
  6373. var cityArrCodeLength = cityArrCode.Count - 1;
  6374. var startCity = IndexSelect.Substring(0, 3);
  6375. if (cityArrCodeLength > 0)
  6376. {
  6377. var arrEndCity = cityArrCode[cityArrCodeLength];
  6378. if (arrEndCity != startCity)
  6379. {
  6380. cityArrCode.Add(startCity.ToUpper());
  6381. }
  6382. }
  6383. else
  6384. {
  6385. cityArrCode.Add(startCity.ToUpper());
  6386. }
  6387. var endCity = IndexSelect.Substring(3, 3);
  6388. cityArrCode.Add(endCity.ToUpper());
  6389. }
  6390. var cityThree = string.Empty;
  6391. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6392. cityThree = cityThree.TrimEnd(',');
  6393. if (string.IsNullOrWhiteSpace(cityThree))
  6394. {
  6395. throw new
  6396. Exception("error");
  6397. }
  6398. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6399. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6400. foreach (var item in cityArrCode)
  6401. {
  6402. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6403. if (find != null)
  6404. {
  6405. city += find.City + "/";
  6406. }
  6407. else
  6408. {
  6409. city += item + "三字码未收入/";
  6410. }
  6411. }
  6412. city = city.TrimEnd('/');
  6413. }
  6414. catch (Exception e)
  6415. {
  6416. city = "黑屏代码格式不正确!";
  6417. }
  6418. }
  6419. }
  6420. else
  6421. {
  6422. city = "未录入黑屏代码";
  6423. }
  6424. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6425. {
  6426. Date = x.Date,
  6427. Days = x.Days,
  6428. Diffgroup = x.Diffgroup,
  6429. Diid = x.Diid,
  6430. Traffic_First = x.Traffic_First,
  6431. Traffic_Second = x.Traffic_Second,
  6432. Trip = x.Trip,
  6433. WeekDay = x.WeekDay,
  6434. Id = x.Id
  6435. }).ToList();
  6436. jw.Data = new
  6437. {
  6438. groupList = groupList.Select(x => new
  6439. {
  6440. x.Id,
  6441. x.TeamName,
  6442. x.TourCode
  6443. }).ToList(),
  6444. groupInfo = new
  6445. {
  6446. group.VisitDays,
  6447. group.TourCode,
  6448. group.VisitPNumber,
  6449. group.TeamName,
  6450. city
  6451. },
  6452. OpTravelList
  6453. };
  6454. jw.Code = 200;
  6455. jw.Msg = "操作成功!";
  6456. return Ok(jw);
  6457. }
  6458. /// <summary>
  6459. /// 删除团组行程单
  6460. /// </summary>
  6461. /// <returns></returns>
  6462. [HttpPost]
  6463. public IActionResult DelTravel(DelOpTravelDto dto)
  6464. {
  6465. var jw = JsonView(false);
  6466. if (dto.UserId <= 0 || dto.Diid <= 0)
  6467. {
  6468. jw.Msg = "请输入正确的参数!";
  6469. return Ok(jw);
  6470. }
  6471. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6472. .SetColumns(x => new Grp_TravelList
  6473. {
  6474. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6475. DeleteUserId = dto.UserId,
  6476. IsDel = 1,
  6477. }).ExecuteCommand();
  6478. jw = JsonView(true);
  6479. return Ok(jw);
  6480. }
  6481. /// <summary>
  6482. /// 行程单保存
  6483. /// </summary>
  6484. /// <returns></returns>
  6485. [HttpPost]
  6486. public IActionResult TravelSave(TravelSaveDto dto)
  6487. {
  6488. var jw = JsonView(false);
  6489. if (dto.Arr.Count > 0)
  6490. {
  6491. try
  6492. {
  6493. _sqlSugar.BeginTran();
  6494. foreach (var item in dto.Arr)
  6495. {
  6496. if (item.Id == 0)
  6497. {
  6498. throw new Exception("请传入正确的Id");
  6499. }
  6500. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6501. .SetColumns(x => new Grp_TravelList
  6502. {
  6503. Trip = item.Trip
  6504. }).ExecuteCommand();
  6505. }
  6506. _sqlSugar.CommitTran();
  6507. jw = JsonView(true);
  6508. }
  6509. catch (Exception ex)
  6510. {
  6511. _sqlSugar.RollbackTran();
  6512. jw.Msg = "程序异常!" + ex.Message;
  6513. }
  6514. }
  6515. else
  6516. {
  6517. jw.Msg = "请传入正确的参数!";
  6518. }
  6519. return Ok(jw);
  6520. }
  6521. /// <summary>
  6522. /// 导出行程单
  6523. /// </summary>
  6524. /// <param name="dto"></param>
  6525. /// <returns></returns>
  6526. [HttpPost]
  6527. public IActionResult ExportTravel(ExportTravelDto dto)
  6528. {
  6529. var jw = JsonView(false);
  6530. jw.Data = "";
  6531. int diid = 0;
  6532. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6533. if (Find == null)
  6534. {
  6535. jw.Msg = "请选择正确的团组!";
  6536. return Ok(jw);
  6537. }
  6538. else
  6539. {
  6540. diid = Find.Id;
  6541. }
  6542. //数据源
  6543. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6544. DataTable dtBlack = null;
  6545. try
  6546. {
  6547. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6548. }
  6549. catch (Exception)
  6550. {
  6551. jw.Msg = "机票黑屏代码有误!";
  6552. return Ok(jw);
  6553. }
  6554. string CityStr = string.Empty;
  6555. if (dtBlack.Rows.Count == 0)
  6556. {
  6557. jw.Msg = "机票黑屏代码有误!";
  6558. return Ok(jw);
  6559. }
  6560. else
  6561. {
  6562. foreach (DataRow row in dtBlack.Rows)
  6563. {
  6564. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6565. {
  6566. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6567. return Ok(jw);
  6568. }
  6569. }
  6570. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6571. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6572. }
  6573. //创建数据源Table
  6574. DataTable dtSource = new DataTable();
  6575. dtSource.Columns.Add("Days", typeof(string));
  6576. dtSource.Columns.Add("Date", typeof(string));
  6577. dtSource.Columns.Add("Week", typeof(string));
  6578. dtSource.Columns.Add("Traffic", typeof(string));
  6579. dtSource.Columns.Add("Trip", typeof(string));
  6580. //获取数据,放到datatable
  6581. foreach (var item in _travelList)
  6582. {
  6583. DataRow dr = dtSource.NewRow();
  6584. dr["Days"] = item.Days;
  6585. dr["Date"] = item.Date;
  6586. dr["Week"] = item.WeekDay;
  6587. dr["Traffic"] = item.Traffic_First
  6588. + "\r\n"
  6589. + item.Traffic_Second;
  6590. dr["Trip"] = item.Trip;
  6591. dtSource.Rows.Add(dr);
  6592. }
  6593. Dictionary<string, string> dic = new Dictionary<string, string>();
  6594. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6595. dic.Add("City", CityStr);
  6596. dic.Add("Days", Find.VisitDays.ToString());
  6597. dic.Add("DeleCode", Find.TourCode);
  6598. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6599. //模板路径
  6600. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6601. //载入模板
  6602. Document doc = null;
  6603. DocumentBuilder builder = null;
  6604. try
  6605. {
  6606. //载入模板
  6607. doc = new Document(tempPath);
  6608. builder = new DocumentBuilder(doc);
  6609. }
  6610. catch (Exception)
  6611. {
  6612. jw.Msg = "模板位置不存在!";
  6613. return Ok(jw);
  6614. }
  6615. foreach (var key in dic.Keys)
  6616. {
  6617. Bookmark bookmark = doc.Range.Bookmarks[key];
  6618. if (bookmark != null)
  6619. {
  6620. builder.MoveToBookmark(key);
  6621. builder.Write(dic[key]);
  6622. }
  6623. }
  6624. //获取word里所有表格
  6625. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6626. //获取所填表格的序数
  6627. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6628. try
  6629. {
  6630. //循环赋值
  6631. for (int i = 0; i < dtSource.Rows.Count; i++)
  6632. {
  6633. builder.MoveToCell(0, i + 1, 0, 0);
  6634. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6635. builder.MoveToCell(0, i + 1, 1, 0);
  6636. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6637. builder.MoveToCell(0, i + 1, 2, 0);
  6638. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6639. var trip = dtSource.Rows[i]["Trip"].ToString();
  6640. builder.MoveToCell(0, i + 1, 3, 0);
  6641. builder.Write(trip);
  6642. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6643. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6644. // 获取特定索引的段落
  6645. Paragraph paragraph = (Paragraph)paragraphs[0];
  6646. Run run = paragraph.Runs[0];
  6647. Aspose.Words.Font font = run.Font;
  6648. font.Name = "黑体";
  6649. //设置双休红色
  6650. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6651. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6652. paragraph = (Paragraph)paragraphs[1];
  6653. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6654. {
  6655. run = paragraph.Runs[0];
  6656. font = run.Font;
  6657. font.Color = Color.Red;
  6658. }
  6659. }
  6660. }
  6661. catch (Exception ex)
  6662. {
  6663. }
  6664. //删除多余行
  6665. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6666. {
  6667. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6668. }
  6669. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6670. if (!Directory.Exists(savePath))
  6671. {
  6672. try
  6673. {
  6674. Directory.CreateDirectory(savePath);
  6675. }
  6676. catch
  6677. {
  6678. }
  6679. }
  6680. string path = savePath + Find.TeamName + "出访日程";
  6681. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6682. try
  6683. {
  6684. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6685. string postfix = ".docx";
  6686. if (dto.IsPDF == 1)
  6687. {
  6688. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6689. postfix = ".pdf";
  6690. }
  6691. doc.Save(path + postfix, saveFormat);
  6692. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6693. }
  6694. catch (Exception)
  6695. {
  6696. jw = JsonView(false);
  6697. }
  6698. return Ok(jw);
  6699. }
  6700. /// <summary>
  6701. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6702. /// </summary>
  6703. /// <param name="num"></param>
  6704. /// <returns></returns>
  6705. string GetNum(string num)
  6706. {
  6707. string str = "";
  6708. switch (num)
  6709. {
  6710. case "1":
  6711. str = "一";
  6712. break;
  6713. case "2":
  6714. str = "二";
  6715. break;
  6716. case "3":
  6717. str = "三";
  6718. break;
  6719. case "4":
  6720. str = "四";
  6721. break;
  6722. case "5":
  6723. str = "五";
  6724. break;
  6725. case "6":
  6726. str = "六";
  6727. break;
  6728. case "7":
  6729. str = "七";
  6730. break;
  6731. case "8":
  6732. str = "八";
  6733. break;
  6734. case "9":
  6735. str = "九";
  6736. break;
  6737. case "10":
  6738. str = "十";
  6739. break;
  6740. case "11":
  6741. str = "十一";
  6742. break;
  6743. case "12":
  6744. str = "十二";
  6745. break;
  6746. case "一":
  6747. str = "1";
  6748. break;
  6749. case "二":
  6750. str = "2";
  6751. break;
  6752. case "三":
  6753. str = "3";
  6754. break;
  6755. case "四":
  6756. str = "4";
  6757. break;
  6758. case "五":
  6759. str = "5";
  6760. break;
  6761. case "六":
  6762. str = "6";
  6763. break;
  6764. case "七":
  6765. str = "7";
  6766. break;
  6767. case "八":
  6768. str = "8";
  6769. break;
  6770. case "九":
  6771. str = "9";
  6772. break;
  6773. case "十":
  6774. str = "10";
  6775. break;
  6776. case "十一":
  6777. str = "11";
  6778. break;
  6779. case "十二":
  6780. str = "12";
  6781. break;
  6782. }
  6783. return str;
  6784. }
  6785. #endregion
  6786. #endregion
  6787. #region 团组成本
  6788. /// <summary>
  6789. /// 团组成本数据初始化
  6790. /// </summary>
  6791. /// <param name="dto"></param>
  6792. /// <returns></returns>
  6793. [HttpPost]
  6794. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6795. {
  6796. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6797. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6798. WHEN COUNT(*) >= 0 THEN 'True'
  6799. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6800. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6801. ").ToList(); //团组列表
  6802. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6803. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6804. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6805. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6806. if (groupinfoValue != null)
  6807. {
  6808. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6809. var spArr = new string[1] { countryArr };
  6810. if (countryArr.Contains("|"))
  6811. {
  6812. spArr = countryArr.Split("|");
  6813. }
  6814. else if (countryArr.Contains("、"))
  6815. {
  6816. spArr = countryArr.Split("、");
  6817. }
  6818. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6819. {
  6820. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6821. if (dbQueryCountry != null)
  6822. {
  6823. visaCountryInfoArr.Add(dbQueryCountry);
  6824. }
  6825. }
  6826. }
  6827. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6828. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6829. var create = _GroupCostRepository.
  6830. CreateGroupCostByBlackCode(dto.Diid);
  6831. if (groupCost.Count == 0 && create.Code == 0)
  6832. {
  6833. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6834. }
  6835. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6836. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6837. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6838. groupCostMap = groupCostMap.Select(x =>
  6839. {
  6840. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6841. {
  6842. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6843. }
  6844. return x;
  6845. }).ToList();
  6846. //GroupCostParameter.Add(new
  6847. // Grp_GroupCostParameter());
  6848. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6849. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6850. return Ok(JsonView(new
  6851. {
  6852. groupList,
  6853. groupInfo,
  6854. groupChecks,
  6855. groupCost = groupCostMap,
  6856. hotelNumber,
  6857. GroupCostParameter = GroupCostParameterMap,
  6858. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6859. {
  6860. x.VisaCountry,
  6861. x.VisaPrice,
  6862. x.Id,
  6863. }).ToList(),
  6864. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6865. blackCodeIsTrue = create.Code == 0 ? true : false,
  6866. hotelIsTrue = hotelIsTrue,
  6867. }));
  6868. }
  6869. /// <summary>
  6870. /// 团组成本信息保存
  6871. /// </summary>
  6872. /// <param name="dto"></param>
  6873. /// <returns></returns>
  6874. [HttpPost]
  6875. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6876. {
  6877. if (dto.Diid <= 0 || dto.Userid <= 0)
  6878. {
  6879. return Ok(JsonView(false));
  6880. }
  6881. JsonView jw = null;
  6882. bool isTrue = false;
  6883. #region 复制团组成本
  6884. //if (dto.Diid == 2581)
  6885. //{
  6886. // dto.Diid = 2599;
  6887. // dto.CheckBoxs.ForEach(x =>
  6888. // {
  6889. // x.Diid = 2599;
  6890. // });
  6891. // dto.GroupCosts.ForEach(x =>
  6892. // {
  6893. // x.Diid = 2599;
  6894. // });
  6895. // dto.CostTypeHotelNumbers.ForEach(x =>
  6896. // {
  6897. // x.Diid = 2599;
  6898. // });
  6899. // dto.GroupCostParameters.ForEach(x =>
  6900. // {
  6901. // x.DiId = 2599;
  6902. // });
  6903. //}
  6904. #endregion
  6905. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6906. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6907. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6908. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6909. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6910. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6911. try
  6912. {
  6913. _sqlSugar.BeginTran();
  6914. isTrue = await _GroupCostRepository.
  6915. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6916. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6917. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6918. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6919. _sqlSugar.CommitTran();
  6920. jw = JsonView(true, "保存成功!", isTrue);
  6921. }
  6922. catch (Exception)
  6923. {
  6924. _sqlSugar.RollbackTran();
  6925. jw = JsonView(false);
  6926. }
  6927. return Ok(jw);
  6928. }
  6929. /// <summary>
  6930. /// 司兼导数据
  6931. /// </summary>
  6932. /// <param name="dto"></param>
  6933. /// <returns></returns>
  6934. [HttpPost]
  6935. public IActionResult GetCarGuides(CarGuidesDto dto)
  6936. {
  6937. JsonView jw = null;
  6938. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6939. jw = JsonView(true, "获取成功!", Data);
  6940. return Ok(jw);
  6941. }
  6942. /// <summary>
  6943. /// 导游数据
  6944. /// </summary>
  6945. /// <param name="dto"></param>
  6946. /// <returns></returns>
  6947. [HttpPost]
  6948. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6949. {
  6950. JsonView jw = null;
  6951. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6952. // SELECT*,ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber FROM Grp_GuidesInfo where (city like '%{dto.City}%' or country like '%{dto.City}%' ) and isdel = 0 ) as b
  6953. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6954. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6955. jw = JsonView(true, "获取成功!", Data);
  6956. return Ok(jw);
  6957. }
  6958. /// <summary>
  6959. /// 成本车数据
  6960. /// </summary>
  6961. /// <param name="dto"></param>
  6962. /// <returns></returns>
  6963. [HttpPost]
  6964. public IActionResult GetCarInfo(CarGuidesDto dto)
  6965. {
  6966. JsonView jw = null;
  6967. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6968. jw = JsonView(true, "获取成功!", Data);
  6969. return Ok(jw);
  6970. }
  6971. /// <summary>
  6972. /// 景点数据
  6973. /// </summary>
  6974. /// <param name="dto"></param>
  6975. /// <returns></returns>
  6976. [HttpPost]
  6977. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6978. {
  6979. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6980. return Ok(JsonView(true, "获取成功!", Data));
  6981. }
  6982. /// <summary>
  6983. /// 成本通知
  6984. /// </summary>
  6985. /// <param name="dto"></param>
  6986. /// <returns></returns>
  6987. [HttpPost]
  6988. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6989. {
  6990. if (dto.Diid < 0)
  6991. {
  6992. return Ok(JsonView(false));
  6993. }
  6994. JsonView jw = null;
  6995. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6996. if (GroupCostParameter != null)
  6997. {
  6998. int IsShare = 0;
  6999. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  7000. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  7001. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  7002. string msg = string.Empty;
  7003. if (isTrue)
  7004. {
  7005. if (IsShare == 0)
  7006. {
  7007. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  7008. }
  7009. else
  7010. {
  7011. #region 企微通知对应岗位用户
  7012. try
  7013. {
  7014. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  7015. }
  7016. catch (Exception ex)
  7017. {
  7018. }
  7019. #endregion
  7020. msg = "通知成功,其他模块操作人员可见此成本信息!";
  7021. }
  7022. jw = JsonView(isTrue, msg, new { IsShare });
  7023. }
  7024. else
  7025. {
  7026. msg = "修改失败!";
  7027. jw = JsonView(isTrue, msg);
  7028. }
  7029. }
  7030. else
  7031. {
  7032. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  7033. }
  7034. return Ok(jw);
  7035. }
  7036. /// <summary>
  7037. /// 导出报价单
  7038. /// </summary>
  7039. /// <param name="dto"></param>
  7040. /// <returns></returns>
  7041. [HttpPost]
  7042. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  7043. {
  7044. if (dto.Diid == 0)
  7045. {
  7046. return Ok(JsonView(false, "请传递团组id"));
  7047. }
  7048. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7049. if (deleInfo.Code != 0)
  7050. {
  7051. return Ok(JsonView(false, "团组信息查询失败!"));
  7052. }
  7053. var di = deleInfo.Data as DelegationInfoWebView;
  7054. if (di != null)
  7055. {
  7056. di.TeamName = di.TeamName.Replace("|","、");
  7057. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  7058. //文件名
  7059. string strFileName = di.TeamName + "-收款账单.doc";
  7060. //获取模板
  7061. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  7062. //载入模板
  7063. Document doc = new Document(tmppath);
  7064. decimal TotalPrice = 0.00M;
  7065. string itemStr = string.Empty;
  7066. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7067. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7068. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7069. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7070. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7071. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7072. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7073. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7074. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7075. foreach (var cost in groupCostType)
  7076. {
  7077. var List = cost.ToList();
  7078. if (cost.Key == "A")
  7079. {
  7080. foreach (var ListItem in List)
  7081. {
  7082. if (ListItem.number > 0)
  7083. {
  7084. if (ListItem.code.Contains("TBR"))
  7085. {
  7086. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7087. }
  7088. else
  7089. {
  7090. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7091. }
  7092. TotalPrice += (ListItem.number * ListItem.price);
  7093. }
  7094. }
  7095. }
  7096. else
  7097. {
  7098. itemStr = itemStr.Insert(0, "A段\r\n");
  7099. itemStr += "B段\r\n";
  7100. foreach (var ListItem in List)
  7101. {
  7102. if (ListItem.number > 0)
  7103. {
  7104. if (ListItem.code.Contains("TBR"))
  7105. {
  7106. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7107. }
  7108. else
  7109. {
  7110. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7111. }
  7112. TotalPrice += (ListItem.number * ListItem.price);
  7113. }
  7114. }
  7115. }
  7116. }
  7117. #region 替换Word模板书签内容
  7118. Dictionary<string, string> marks = new Dictionary<string, string>();
  7119. marks.Add("To", di.ClientUnit);//付款方
  7120. marks.Add("ToTel", di.TellPhone);//付款方电话
  7121. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7122. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7123. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7124. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7125. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7126. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7127. marks.Add("PayItemContent", itemStr);//详细信息
  7128. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7129. #endregion
  7130. ////注
  7131. //if (doc.Range.Bookmarks["Attention"] != null)
  7132. //{
  7133. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7134. // mark.Text = frList[0].Attention;
  7135. //}
  7136. foreach (var item in marks.Keys)
  7137. {
  7138. if (doc.Range.Bookmarks[item] != null)
  7139. {
  7140. Bookmark mark = doc.Range.Bookmarks[item];
  7141. mark.Text = marks[item];
  7142. }
  7143. }
  7144. byte[] bytes = null;
  7145. using (MemoryStream stream = new MemoryStream())
  7146. {
  7147. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7148. bytes = stream.ToArray();
  7149. }
  7150. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7151. return Ok(JsonView(true, "", new
  7152. {
  7153. Data = bytes,
  7154. strFileName,
  7155. }));
  7156. }
  7157. else
  7158. {
  7159. return Ok(JsonView(false, "团组信息不存在!"));
  7160. }
  7161. }
  7162. /// <summary>
  7163. /// 导出团组成本
  7164. /// </summary>
  7165. /// <param name="dto"></param>
  7166. /// <returns></returns>
  7167. [HttpPost]
  7168. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7169. {
  7170. var jw = JsonView(false);
  7171. if (dto.Diid == 0)
  7172. {
  7173. return Ok(JsonView(false, "请传递团组id"));
  7174. }
  7175. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7176. if (deleInfo.Code != 0)
  7177. {
  7178. return Ok(JsonView(false, "团组信息查询失败!"));
  7179. }
  7180. var di = deleInfo.Data as DelegationInfoWebView;
  7181. if (di == null)
  7182. {
  7183. return Ok(JsonView(false, "团组信息查询失败!"));
  7184. }
  7185. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7186. WorkbookDesigner designer = new WorkbookDesigner();
  7187. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7188. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7189. for (int i = 0; i < List_GC.Count; i++)
  7190. {
  7191. GroupCost_Excel gc = new GroupCost_Excel();
  7192. gc.Id = List_GC[i].Id;
  7193. gc.Diid = List_GC[i].Diid.ToString();
  7194. gc.DAY = List_GC[i].DAY;
  7195. string week = "";
  7196. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7197. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7198. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7199. gc.ITIN = List_GC[i].ITIN;
  7200. gc.CarType = List_GC[i].CarType;
  7201. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7202. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7203. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7204. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7205. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7206. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7207. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7208. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7209. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7210. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7211. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7212. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7213. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7214. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7215. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7216. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7217. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7218. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7219. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7220. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7221. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7222. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7223. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7224. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7225. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7226. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7227. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7228. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7229. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7230. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7231. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7232. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7233. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7234. List_GC1.Add(gc);
  7235. }
  7236. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7237. dt.TableName = "TB";
  7238. //报表标题等不用dt的值
  7239. designer.SetDataSource("TeamName", dto.title.TeamName);
  7240. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7241. designer.SetDataSource("Tax", dto.title.Tax);
  7242. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7243. designer.SetDataSource("Currency", dto.title.Currency);
  7244. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7245. designer.SetDataSource("Rate", dto.title.Rate);
  7246. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7247. var Aparams = hotels.Find(x => x.Type == "Default");
  7248. if (Aparams == null)
  7249. {
  7250. return Ok(jw);
  7251. }
  7252. //酒店数量
  7253. var txtSGRNumber = Aparams.SGR.ToString();
  7254. var txtTBRNumber = Aparams.TBR.ToString();
  7255. var txtJSESNumber = Aparams.JSES.ToString();
  7256. var txtSUITENumbe = Aparams.SUITE.ToString();
  7257. if (dto.costType == "B")
  7258. {
  7259. Aparams = hotels.Find(x => x.Type == "A");
  7260. var Bparams = hotels.Find(x => x.Type == "B");
  7261. if (Aparams == null || Bparams == null)
  7262. {
  7263. return Ok(jw);
  7264. }
  7265. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7266. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7267. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7268. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7269. }
  7270. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7271. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7272. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7273. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7274. var ws = designer.Workbook.Worksheets[0];
  7275. int Row = List_GC.Count;
  7276. int startIndex = 11;
  7277. int HideRows = 0;
  7278. List<int> hideRowsList = new List<int>();
  7279. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7280. #region A段left数据
  7281. var left = dto.leftInfo.Find(x => x.Type == "A");
  7282. if (left == null)
  7283. {
  7284. return Ok(jw);
  7285. }
  7286. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7287. if (leftBindData != null)
  7288. {
  7289. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7290. designer.SetDataSource("VisaRS", leftBindData.rs);
  7291. designer.SetDataSource("VisaXS", leftBindData.xs);
  7292. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7293. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7294. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7295. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7296. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7297. }
  7298. else
  7299. {
  7300. hideRowsList.Add(Row + startIndex + HideRows);
  7301. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7302. }
  7303. HideRows += 2;
  7304. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7305. if (leftBindData != null)
  7306. {
  7307. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7308. designer.SetDataSource("BXRS", leftBindData.rs);
  7309. designer.SetDataSource("BXXS", leftBindData.xs);
  7310. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7311. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7312. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7313. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7314. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7315. }
  7316. else
  7317. {
  7318. hideRowsList.Add(Row + startIndex + HideRows);
  7319. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7320. }
  7321. HideRows += 2;
  7322. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7323. if (leftBindData != null)
  7324. {
  7325. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7326. designer.SetDataSource("HSRS", leftBindData.rs);
  7327. designer.SetDataSource("HSXS", leftBindData.xs);
  7328. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7329. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7330. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7331. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7332. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7333. }
  7334. else
  7335. {
  7336. hideRowsList.Add(Row + startIndex + HideRows);
  7337. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7338. }
  7339. HideRows += 2;
  7340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7341. if (leftBindData != null)
  7342. {
  7343. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7344. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7345. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7346. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7347. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7348. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7349. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7350. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7351. }
  7352. else
  7353. {
  7354. hideRowsList.Add(Row + startIndex + HideRows);
  7355. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7356. }
  7357. HideRows += 2;
  7358. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7359. if (leftBindData != null)
  7360. {
  7361. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7362. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7363. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7364. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7365. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7366. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7367. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7368. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7369. }
  7370. else
  7371. {
  7372. hideRowsList.Add(Row + startIndex + HideRows);
  7373. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7374. }
  7375. HideRows += 2;
  7376. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7377. if (leftBindData != null)
  7378. {
  7379. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7380. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7381. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7382. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7383. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7384. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7385. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7386. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7387. }
  7388. else
  7389. {
  7390. hideRowsList.Add(Row + startIndex + HideRows);
  7391. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7392. }
  7393. HideRows += 2;
  7394. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7395. if (leftBindData != null)
  7396. {
  7397. ////TBR
  7398. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7399. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7400. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7401. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7402. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7403. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7404. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7405. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7406. }
  7407. else
  7408. {
  7409. hideRowsList.Add(Row + startIndex + HideRows);
  7410. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7411. }
  7412. HideRows += 2;
  7413. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7414. if (leftBindData != null)
  7415. {
  7416. ////SGR
  7417. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7418. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7419. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7420. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7421. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7422. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7423. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7424. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7425. }
  7426. else
  7427. {
  7428. hideRowsList.Add(Row + startIndex + HideRows);
  7429. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7430. }
  7431. HideRows += 2;
  7432. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7433. if (leftBindData != null)
  7434. {
  7435. ////JS/ES
  7436. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7437. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7438. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7439. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7440. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7441. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7442. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7443. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7444. }
  7445. else
  7446. {
  7447. hideRowsList.Add(Row + startIndex + HideRows);
  7448. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7449. }
  7450. HideRows += 2;
  7451. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7452. if (leftBindData != null)
  7453. {
  7454. ////SUITE
  7455. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7456. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7457. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7458. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7459. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7460. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7461. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7462. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7463. }
  7464. else
  7465. {
  7466. hideRowsList.Add(Row + startIndex + HideRows);
  7467. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7468. }
  7469. HideRows += 2;
  7470. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7471. if (leftBindData != null)
  7472. {
  7473. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7474. designer.SetDataSource("DJRS", leftBindData.rs);
  7475. designer.SetDataSource("DJXS", leftBindData.xs);
  7476. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7477. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7478. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7479. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7480. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7481. }
  7482. else
  7483. {
  7484. hideRowsList.Add(Row + startIndex + HideRows);
  7485. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7486. }
  7487. HideRows += 2;
  7488. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7489. if (leftBindData != null)
  7490. {
  7491. designer.SetDataSource("HCPCB", leftBindData.cb);
  7492. designer.SetDataSource("HCPRS", leftBindData.rs);
  7493. designer.SetDataSource("HCPXS", leftBindData.xs);
  7494. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7495. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7496. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7497. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7498. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7499. }
  7500. else
  7501. {
  7502. hideRowsList.Add(Row + startIndex + HideRows);
  7503. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7504. }
  7505. HideRows += 2;
  7506. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7507. if (leftBindData != null)
  7508. {
  7509. designer.SetDataSource("CPCB", leftBindData.cb);
  7510. designer.SetDataSource("CPRS", leftBindData.rs);
  7511. designer.SetDataSource("CPXS", leftBindData.xs);
  7512. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7513. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7514. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7515. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7516. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7517. }
  7518. else
  7519. {
  7520. hideRowsList.Add(Row + startIndex + HideRows);
  7521. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7522. }
  7523. HideRows += 2;
  7524. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7525. if (leftBindData != null)
  7526. {
  7527. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7528. designer.SetDataSource("GWRS", leftBindData.rs);
  7529. designer.SetDataSource("GWXS", leftBindData.xs);
  7530. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7531. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7532. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7533. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7534. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7535. }
  7536. else
  7537. {
  7538. hideRowsList.Add(Row + startIndex + HideRows);
  7539. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7540. }
  7541. HideRows += 2;
  7542. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7543. if (leftBindData != null)
  7544. {
  7545. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7546. designer.SetDataSource("LYJRS", leftBindData.rs);
  7547. designer.SetDataSource("LYJXS", leftBindData.xs);
  7548. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7549. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7550. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7551. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7552. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7553. }
  7554. else
  7555. {
  7556. hideRowsList.Add(Row + startIndex + HideRows);
  7557. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7558. }
  7559. #endregion
  7560. #region A段Right信息
  7561. var right = dto.rightInfo.Find(x => x.Type == "A");
  7562. if (right == null)
  7563. {
  7564. return Ok(jw);
  7565. }
  7566. HideRows += 4;
  7567. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7568. if (rightBindData != null)
  7569. {
  7570. //经济舱 + 双人间 TBR
  7571. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7572. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7573. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7574. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7575. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7576. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7577. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7578. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7579. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7580. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7581. }
  7582. else
  7583. {
  7584. hideRowsList.Add(Row + startIndex + HideRows);
  7585. }
  7586. HideRows += 2;
  7587. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7588. if (rightBindData != null)
  7589. {
  7590. //经济舱 + 单人间 SGR
  7591. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7592. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7593. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7594. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7595. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7596. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7597. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7598. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7599. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7600. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7601. }
  7602. else
  7603. {
  7604. hideRowsList.Add(Row + startIndex + HideRows);
  7605. }
  7606. HideRows += 2;
  7607. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7608. if (rightBindData != null)
  7609. {
  7610. //公务舱 + 单人间 SGR
  7611. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7612. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7613. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7614. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7615. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7616. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7617. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7618. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7619. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7620. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7621. }
  7622. else
  7623. {
  7624. hideRowsList.Add(Row + startIndex + HideRows);
  7625. }
  7626. HideRows += 2;
  7627. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7628. if (rightBindData != null)
  7629. {
  7630. //公务舱 + 小套房 JSES
  7631. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7632. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7633. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7634. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7635. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7636. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7637. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7638. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7639. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7640. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7641. }
  7642. else
  7643. {
  7644. hideRowsList.Add(Row + startIndex + HideRows);
  7645. }
  7646. HideRows += 2;
  7647. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7648. if (rightBindData != null)
  7649. {
  7650. //公务舱 + 小套房 JSES
  7651. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7652. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7653. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7654. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7655. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7656. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7657. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7658. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7659. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7660. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7661. }
  7662. else
  7663. {
  7664. hideRowsList.Add(Row + startIndex + HideRows);
  7665. }
  7666. HideRows += 2;
  7667. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7668. if (rightBindData != null)
  7669. {
  7670. //经济舱 + 大套房
  7671. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7672. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7673. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7674. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7675. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7676. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7677. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7678. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7679. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7680. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7681. }
  7682. else
  7683. {
  7684. hideRowsList.Add(Row + startIndex + HideRows);
  7685. }
  7686. HideRows += 2;
  7687. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7688. if (rightBindData != null)
  7689. {
  7690. //头等舱 + 小套房 JSES
  7691. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7692. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7693. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7694. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7695. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7696. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7697. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7698. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7699. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7700. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7701. }
  7702. else
  7703. {
  7704. hideRowsList.Add(Row + startIndex + HideRows);
  7705. }
  7706. HideRows += 2;
  7707. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7708. if (rightBindData != null)
  7709. {
  7710. //头等舱 + 大套房
  7711. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7712. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7713. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7714. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7715. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7716. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7717. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7718. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7719. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7720. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7721. }
  7722. else
  7723. {
  7724. hideRowsList.Add(Row + startIndex + HideRows);
  7725. }
  7726. #endregion
  7727. #region B段标题清空
  7728. designer.SetDataSource("CostBDRCB", "");
  7729. designer.SetDataSource("CostBRS", "");
  7730. designer.SetDataSource("CostBXS", "");
  7731. designer.SetDataSource("CostBZCB", "");
  7732. designer.SetDataSource("CostBDRBJ", "");
  7733. designer.SetDataSource("CostBZBJ", "");
  7734. designer.SetDataSource("CostBDRLR", "");
  7735. designer.SetDataSource("CostBZLR", "");
  7736. designer.SetDataSource("CostBDRCBOM", "");
  7737. designer.SetDataSource("CostBRSOM", "");
  7738. designer.SetDataSource("CostBZCBOM", "");
  7739. designer.SetDataSource("CostBDRBJOM", "");
  7740. designer.SetDataSource("CostBZBJOM", "");
  7741. designer.SetDataSource("CostBDRLROM", "");
  7742. designer.SetDataSource("CostBZLROM", "");
  7743. #endregion
  7744. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7745. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7746. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7747. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7748. designer.SetDataSource("DJName", "地接(CNY)");
  7749. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7750. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7751. designer.SetDataSource("GWName", "公务(CNY)");
  7752. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7753. designer.SetDataSource("LYJName", "零用金(CNY)");
  7754. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7755. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7756. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7757. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7758. designer.SetDataSource("BXName", "保险(CNY)");
  7759. designer.SetDataSource("VisaName", "签证(CNY)");
  7760. #region B段基本数据
  7761. if (dto.costType == "B")
  7762. {
  7763. left = dto.leftInfo.Find(x => x.Type == "B");
  7764. if (left == null)
  7765. {
  7766. return Ok(jw);
  7767. }
  7768. #region B段left数据
  7769. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7770. if (leftBindData != null)
  7771. {
  7772. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7773. designer.SetDataSource("BHSRS", leftBindData.rs);
  7774. designer.SetDataSource("BHSXS", leftBindData.xs);
  7775. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7776. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7777. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7778. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7779. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7780. }
  7781. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7782. if (leftBindData != null)
  7783. {
  7784. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7785. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7786. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7787. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7788. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7789. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7790. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7791. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7792. }
  7793. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7794. if (leftBindData != null)
  7795. {
  7796. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7797. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7798. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7799. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7800. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7801. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7802. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7803. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7804. }
  7805. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7806. if (leftBindData != null)
  7807. {
  7808. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  7809. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7810. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7811. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7812. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7813. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7814. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7815. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7816. }
  7817. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7818. if (leftBindData != null)
  7819. {
  7820. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7821. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7822. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7823. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7824. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7825. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7826. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7827. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7828. }
  7829. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7830. if (leftBindData != null)
  7831. {
  7832. designer.SetDataSource("BCPCB", leftBindData.cb);
  7833. designer.SetDataSource("BCPRS", leftBindData.rs);
  7834. designer.SetDataSource("BCPXS", leftBindData.xs);
  7835. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7836. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7837. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7838. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7839. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7840. }
  7841. //TBR
  7842. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7843. if (leftBindData != null)
  7844. {
  7845. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7846. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7847. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7848. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7849. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7850. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7851. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7852. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7853. }
  7854. //SGR
  7855. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7856. if (leftBindData != null)
  7857. {
  7858. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7859. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7860. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7861. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7862. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7863. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7864. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7865. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7866. }
  7867. //JS/ES
  7868. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7869. if (leftBindData != null)
  7870. {
  7871. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7872. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7873. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7874. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7875. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7876. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7877. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7878. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7879. }
  7880. //SUITE
  7881. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7882. if (leftBindData != null)
  7883. {
  7884. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7885. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7886. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7887. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7888. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7889. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7890. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7891. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7892. }
  7893. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7894. if (leftBindData != null)
  7895. {
  7896. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7897. designer.SetDataSource("BDJRS", leftBindData.rs);
  7898. designer.SetDataSource("BDJXS", leftBindData.xs);
  7899. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7900. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7901. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7902. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7903. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7904. }
  7905. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7906. if (leftBindData != null)
  7907. {
  7908. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7909. designer.SetDataSource("BGWRS", leftBindData.rs);
  7910. designer.SetDataSource("BGWXS", leftBindData.xs);
  7911. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7912. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7913. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7914. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7915. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7916. }
  7917. #region 优化方案
  7918. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7919. //excelBind.Add("零用金", new {
  7920. //cb="",
  7921. //rs="",
  7922. //xs ="",
  7923. //zcb = "",
  7924. //});
  7925. #endregion
  7926. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7927. if (leftBindData != null)
  7928. {
  7929. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7930. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7931. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7932. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7933. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7934. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7935. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7936. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7937. }
  7938. #endregion
  7939. #region B段Right信息
  7940. right = dto.rightInfo.Find(x => x.Type == "B");
  7941. if (right == null)
  7942. {
  7943. return Ok(jw);
  7944. }
  7945. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7946. if (rightBindData != null)
  7947. {
  7948. //经济舱 + 双人间 TBR
  7949. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7950. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7951. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7952. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7953. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7954. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7955. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7956. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7957. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7958. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7959. }
  7960. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7961. if (rightBindData != null)
  7962. {
  7963. //经济舱 + 单人间 SGR
  7964. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7965. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7966. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7967. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7968. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7969. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7970. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7971. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7972. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7973. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7974. }
  7975. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7976. if (rightBindData != null)
  7977. {
  7978. //公务舱 + 单人间 SGR
  7979. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7980. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7981. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7982. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7983. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7984. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7985. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7986. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7987. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7988. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7989. }
  7990. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7991. if (rightBindData != null)
  7992. {
  7993. //公务舱 + 小套房 JSES
  7994. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7995. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7996. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7997. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7998. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7999. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8000. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8001. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8002. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8003. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8004. }
  8005. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  8006. if (rightBindData != null)
  8007. {
  8008. //公务舱 + 小套房 JSES
  8009. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  8010. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  8011. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8012. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  8013. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8014. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8015. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8016. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8017. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8018. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8019. }
  8020. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  8021. if (rightBindData != null)
  8022. {
  8023. //经济舱 + 大套房
  8024. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  8025. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  8026. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8027. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  8028. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8029. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8030. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8031. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8032. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8033. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8034. }
  8035. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  8036. if (rightBindData != null)
  8037. {
  8038. //头等舱 + 小套房 JSES
  8039. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  8040. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  8041. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8042. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  8043. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8044. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8045. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8046. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8047. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8048. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8049. }
  8050. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  8051. if (rightBindData != null)
  8052. {
  8053. //头等舱 + 大套房
  8054. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  8055. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  8056. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  8057. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  8058. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  8059. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  8060. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  8061. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  8062. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  8063. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  8064. }
  8065. #endregion
  8066. #region 标题
  8067. designer.SetDataSource("CostBDRCB", "单人成本");
  8068. designer.SetDataSource("CostBRS", "人数");
  8069. designer.SetDataSource("CostBXS", "系数");
  8070. designer.SetDataSource("CostBZCB", "总成本");
  8071. designer.SetDataSource("CostBDRBJ", "单人报价");
  8072. designer.SetDataSource("CostBZBJ", "总报价");
  8073. designer.SetDataSource("CostBDRLR", "单人利润");
  8074. designer.SetDataSource("CostBZLR", "总利润");
  8075. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8076. designer.SetDataSource("CostBRSOM", "人数");
  8077. designer.SetDataSource("CostBZCBOM", "总成本");
  8078. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8079. designer.SetDataSource("CostBZBJOM", "总报价");
  8080. designer.SetDataSource("CostBDRLROM", "单人利润");
  8081. designer.SetDataSource("CostBZLROM", "总利润");
  8082. #endregion
  8083. }
  8084. #endregion
  8085. designer.SetDataSource("TzZCB2", TzZCB2);
  8086. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8087. designer.SetDataSource("TzZLR2", TzZLR2);
  8088. string[] dataSourceKeys = new string[]
  8089. {
  8090. "VF",
  8091. "TGS",
  8092. "TGOF",
  8093. "TGM",
  8094. "TGA",
  8095. "TGTF",
  8096. "TGEF",
  8097. "CFM",
  8098. "CFOF",
  8099. "B",
  8100. "L",
  8101. "D",
  8102. "TBR",
  8103. "SGR",
  8104. "JSES",
  8105. "Suite",
  8106. "TV",
  8107. "1L",
  8108. "IF",
  8109. "EF",
  8110. "BRF",
  8111. "TE",
  8112. "TGT",
  8113. "DRVT",
  8114. "PC",
  8115. "TLF",
  8116. "ECT"
  8117. };
  8118. foreach (var item in dataSourceKeys)
  8119. {
  8120. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8121. if (find != null)
  8122. {
  8123. designer.SetDataSource(item, find.text);
  8124. }
  8125. else
  8126. {
  8127. designer.SetDataSource(item, 0);
  8128. }
  8129. }
  8130. designer.SetDataSource(dt);
  8131. //根据数据源处理生成报表内容
  8132. designer.Process();
  8133. designer.Workbook.Worksheets[0].Name = "清单";
  8134. Worksheet sheet = designer.Workbook.Worksheets[0];
  8135. foreach (var Rowindex in hideRowsList)
  8136. {
  8137. ws.Cells.HideRows(Rowindex, 2);
  8138. }
  8139. byte[] bytes = null;
  8140. string strFileName = di.TeamName + "-团组-成本.xls";
  8141. using (MemoryStream stream = new MemoryStream())
  8142. {
  8143. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8144. bytes = stream.ToArray();
  8145. }
  8146. return Ok(JsonView(true, "", new
  8147. {
  8148. Data = bytes,
  8149. strFileName,
  8150. }));
  8151. }
  8152. /// <summary>
  8153. /// 导出客户报表
  8154. /// </summary>
  8155. /// <returns></returns>
  8156. [HttpPost]
  8157. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8158. {
  8159. var jw = JsonView(false);
  8160. if (dto.Diid == 0)
  8161. {
  8162. return Ok(JsonView(false, "请传递团组id"));
  8163. }
  8164. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8165. if (deleInfo.Code != 0)
  8166. {
  8167. return Ok(JsonView(false, "团组信息查询失败!"));
  8168. }
  8169. var di = deleInfo.Data as DelegationInfoWebView;
  8170. if (di == null)
  8171. {
  8172. return Ok(JsonView(false, "团组信息查询失败!"));
  8173. }
  8174. //文件名
  8175. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8176. //获取模板
  8177. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8178. //载入模板
  8179. Document doc = new Document(tmppath);
  8180. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8181. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8182. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8183. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8184. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8185. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8186. if (AParameter == null)
  8187. {
  8188. return Ok(JsonView(false, "系数不存在!"));
  8189. }
  8190. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8191. , TzAirDesc, TzZCost;
  8192. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8193. = TzAirDesc = TzZCost = string.Empty;
  8194. TzNumber = AParameter.CostTypenumber.ToString();
  8195. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8196. CarGuides1 = dto.CarGuides1;
  8197. Meal = dto.Meal;
  8198. SubsidizedMeals = dto.SubsidizedMeals;
  8199. NightRepair = dto.NightRepair;
  8200. AttractionsTickets = dto.AttractionsTickets;
  8201. MiscellaneousFees = dto.MiscellaneousFees;
  8202. ATip = dto.ATip;
  8203. TzHotelDesc = "";
  8204. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8205. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8206. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8207. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8208. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8209. TzAirDesc = "";
  8210. TzZCost = dto.TzZCost;
  8211. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8212. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8213. var index = 1;
  8214. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8215. foreach (var item in TzHotelDescArr)
  8216. {
  8217. if (AinfoArr != null)
  8218. {
  8219. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8220. if (Ainfo != null)
  8221. {
  8222. if (int.Parse(Ainfo.rs) <= 0)
  8223. {
  8224. continue;
  8225. }
  8226. var hotelText = string.Empty;
  8227. switch (item)
  8228. {
  8229. case "SGR":
  8230. hotelText = "单人间";
  8231. break;
  8232. case "JSES":
  8233. hotelText = "小套房";
  8234. break;
  8235. case "SUITE":
  8236. hotelText = "套房";
  8237. break;
  8238. case "TBR":
  8239. hotelText = "双人间";
  8240. break;
  8241. }
  8242. if (item != "TBR")
  8243. {
  8244. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8245. }
  8246. else
  8247. {
  8248. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8249. }
  8250. index++;
  8251. }
  8252. }
  8253. }
  8254. index = 1;
  8255. foreach (var item in TzAirDescArr)
  8256. {
  8257. if (AinfoArr != null)
  8258. {
  8259. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8260. if (Ainfo != null)
  8261. {
  8262. if (int.Parse(Ainfo.rs) <= 0)
  8263. {
  8264. continue;
  8265. }
  8266. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8267. index++;
  8268. }
  8269. }
  8270. }
  8271. if (dto.costType == "B")
  8272. {
  8273. if (BParameter == null)
  8274. {
  8275. return Ok(JsonView(false, "B段系数不存在!"));
  8276. }
  8277. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8278. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8279. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8280. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8281. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8282. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8283. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8284. foreach (var item in TzHotelDescArr)
  8285. {
  8286. if (AinfoArr != null)
  8287. {
  8288. TzHotelDesc += "B段信息 \r\n";
  8289. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8290. if (Ainfo != null)
  8291. {
  8292. if (int.Parse(Ainfo.rs) <= 0)
  8293. {
  8294. continue;
  8295. }
  8296. var hotelText = string.Empty;
  8297. switch (item)
  8298. {
  8299. case "SGR":
  8300. hotelText = "单人间";
  8301. break;
  8302. case "JSES":
  8303. hotelText = "小套房";
  8304. break;
  8305. case "SUITE":
  8306. hotelText = "套房";
  8307. break;
  8308. case "TBR":
  8309. hotelText = "双人间";
  8310. break;
  8311. }
  8312. if (item != "TBR")
  8313. {
  8314. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8315. }
  8316. else
  8317. {
  8318. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8319. }
  8320. index++;
  8321. }
  8322. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8323. }
  8324. }
  8325. index = 1;
  8326. foreach (var item in TzAirDescArr)
  8327. {
  8328. if (AinfoArr != null)
  8329. {
  8330. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8331. if (Ainfo != null)
  8332. {
  8333. if (int.Parse(Ainfo.rs) <= 0)
  8334. {
  8335. continue;
  8336. }
  8337. TzAirDesc += "(" + index + ".) " + item + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人 共" + Ainfo.rs + " ........小计RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8338. index++;
  8339. }
  8340. }
  8341. }
  8342. }
  8343. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8344. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8345. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8346. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8347. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8348. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8349. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8350. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8351. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8352. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8353. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8354. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8355. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8356. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8357. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8358. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8359. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8360. DickeyValue.Add("TzZCost", TzZCost);
  8361. foreach (var key in DickeyValue.Keys)
  8362. {
  8363. if (doc.Range.Bookmarks[key] != null)
  8364. {
  8365. Bookmark mark = doc.Range.Bookmarks[key];
  8366. mark.Text = DickeyValue[key];
  8367. }
  8368. }
  8369. byte[] bytes = null;
  8370. string strFileName = di.TeamName + "-客户报价.doc";
  8371. using (MemoryStream stream = new MemoryStream())
  8372. {
  8373. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8374. bytes = stream.ToArray();
  8375. }
  8376. return Ok(JsonView(true, "", new
  8377. {
  8378. Data = bytes,
  8379. strFileName,
  8380. }));
  8381. }
  8382. /// <summary>
  8383. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8384. /// </summary>
  8385. /// <param name="dto"></param>
  8386. /// <returns></returns>
  8387. [HttpPost]
  8388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8389. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8390. {
  8391. try
  8392. {
  8393. #region 参数验证
  8394. if (dto.DiId < 0)
  8395. {
  8396. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8397. }
  8398. List<int> cTableIds = new List<int>() {
  8399. 76 ,//酒店预订
  8400. 77 ,//行程
  8401. 79 ,//车/导游地接
  8402. 80 ,//签证
  8403. 81 ,//邀请/公务活
  8404. 82 ,//团组客户保险
  8405. 85 ,//机票预订
  8406. 98 ,//其他款项
  8407. 285 ,//收款退还
  8408. 751 ,//酒店早餐
  8409. 1015 // 超支费用
  8410. };
  8411. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8412. {
  8413. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8414. }
  8415. #endregion
  8416. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8417. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8418. if (_GroupCostParameters.Count <= 0)
  8419. {
  8420. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8421. }
  8422. if (_GroupCostParameters[0].IsShare == 0)
  8423. {
  8424. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8425. }
  8426. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8427. //处理date为空问题
  8428. if (_GroupCosts.Count > 0)
  8429. {
  8430. for (int i = 0; i < _GroupCosts.Count; i++)
  8431. {
  8432. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8433. {
  8434. if (i > 0)
  8435. {
  8436. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8437. }
  8438. }
  8439. }
  8440. }
  8441. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8442. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8443. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8444. string currCode = "";
  8445. #region currCode 验证
  8446. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8447. if (isInt)
  8448. {
  8449. var currData = currDatas.Find(it => it.Id == intCurrency);
  8450. if (currData != null)
  8451. {
  8452. currCode = currData.Name;
  8453. }
  8454. }
  8455. else
  8456. {
  8457. currCode = _GroupCostParameters[0].Currency.Trim();
  8458. }
  8459. #endregion
  8460. //op,酒店单段模式存储
  8461. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8462. {
  8463. CurrencyCode = currCode,
  8464. Rate = _GroupCostParameters[0].Rate,
  8465. CostType = _GroupCostParameters[0].CostType,
  8466. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8467. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8468. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8469. };
  8470. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8471. if (_GroupCostParameters.Count == 2)
  8472. {
  8473. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8474. }
  8475. foreach (var item in _GroupCostParameters)
  8476. {
  8477. decimal _rate = 1;
  8478. decimal _rate1 = item.Rate;
  8479. decimal _scale = 1;
  8480. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8481. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8482. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8483. //if (userInfo != null)
  8484. //{
  8485. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8486. // {
  8487. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8488. // {
  8489. // _scale = 1.00M;
  8490. // }
  8491. // }
  8492. //}
  8493. #endregion
  8494. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8495. {
  8496. CurrencyCode = currCode,
  8497. Rate = _rate1,
  8498. CostType = item.CostType,
  8499. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8500. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8501. CostTypeNumber = item.CostTypenumber
  8502. };
  8503. if (_GroupCostParameters.Count > 1)
  8504. {
  8505. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8506. }
  8507. else
  8508. {
  8509. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8510. }
  8511. if (dto.CTable == 79)//
  8512. {
  8513. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8514. modulePromptInfo.TotalCost = item.DJCB;
  8515. }
  8516. List<string> costTypes = new List<string>() { "A", "B" };
  8517. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8518. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8519. if (_GroupCostsDuplicates.Count() == 1)
  8520. {
  8521. _GroupCostsTypeData = _GroupCosts;
  8522. }
  8523. else
  8524. {
  8525. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8526. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8527. }
  8528. /*
  8529. * 76 酒店预订
  8530. * 77 行程
  8531. * 79 车/导游地接
  8532. * 80 签证
  8533. * 81 邀请/公务活动
  8534. * 82 团组客户保险
  8535. * 85 机票预订
  8536. * 98 其他款项
  8537. * 285 收款退还
  8538. * 751 酒店早餐
  8539. * 1015 超支费用
  8540. */
  8541. switch (dto.CTable)
  8542. {
  8543. case 76: // 酒店预订
  8544. _ModuleSubPromptInfo.AddRange(
  8545. _GroupCostsTypeData.Select(it => new
  8546. {
  8547. it.DAY,
  8548. it.Date,
  8549. it.ACCON,
  8550. it.ITIN,
  8551. it.SGR,
  8552. it.TBR,
  8553. it.JS_ES,
  8554. it.Suite
  8555. })
  8556. );
  8557. break;
  8558. case 79: // 车/导游地接
  8559. _ModuleSubPromptInfo.AddRange(
  8560. _GroupCostsTypeData.Select(it => new
  8561. {
  8562. Date = it.Date, //日期
  8563. CarFee = it.CarCost * _rate * _scale, //车费用
  8564. CarType = it.CarType, //车型
  8565. DriverFee = it.CFS * _rate * _scale, //司机工资
  8566. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8567. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8568. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8569. GuideFee = it.TGS * _rate * _scale, //导游费用
  8570. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8571. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8572. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8573. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8574. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8575. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8576. Breakfast = it.B * _rate * _scale, //早餐费
  8577. Lunch = it.L * _rate * _scale, //午餐费
  8578. Dinner = it.D * _rate * _scale, //晚餐费
  8579. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8580. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8581. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8582. TicketFee = it.EF * _rate * _scale, //门票费
  8583. TicketRemark = it.EFR, //门票费描述
  8584. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8585. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8586. SpentCash = it.PC * _rate * _scale, //零用金
  8587. LeadersFee = it.TLF * _rate * _scale, //领队费
  8588. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8589. })
  8590. );
  8591. break;
  8592. case 85: // 机票
  8593. List<dynamic> datas = new List<dynamic>();
  8594. datas.Add(
  8595. new
  8596. {
  8597. AirType = "经济舱",
  8598. AirNum = item.JJCRS,
  8599. AirDRCB = item.JJCCB,
  8600. AirZCB = (item.JJCRS * item.JJCCB)
  8601. }
  8602. );
  8603. datas.Add(
  8604. new
  8605. {
  8606. AirType = "公务舱",
  8607. AirNum = item.GWCRS,
  8608. AirDRCB = item.GWCCB,
  8609. AirZCB = (item.GWCRS * item.GWCCB)
  8610. }
  8611. );
  8612. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8613. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8614. modulePromptInfo.Data = new
  8615. {
  8616. airFeeData = datas,
  8617. airInitData = initDatas
  8618. };
  8619. _ModulePromptInfos.Add(modulePromptInfo);
  8620. break;
  8621. default:
  8622. break;
  8623. }
  8624. }
  8625. if (dto.CTable != 85)
  8626. {
  8627. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8628. _ModulePromptInfos.Add(_ModulePromptInfo);
  8629. }
  8630. _view.ModulePromptInfos = _ModulePromptInfos;
  8631. return Ok(JsonView(true, "操作成功!", _view));
  8632. }
  8633. catch (Exception ex)
  8634. {
  8635. return Ok(JsonView(false, ex.Message));
  8636. }
  8637. }
  8638. /// <summary>
  8639. /// 根据黑屏代码重新生成行程
  8640. /// </summary>
  8641. /// <param name="dto"></param>
  8642. /// <returns></returns>
  8643. [HttpPost]
  8644. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8645. {
  8646. var jw = JsonView(false);
  8647. var Create = _GroupCostRepository.
  8648. CreateGroupCostByBlackCode(dto.Diid);
  8649. jw.Msg = Create.Msg;
  8650. if (Create.Code == 0)
  8651. {
  8652. jw.Code = 200;
  8653. jw.Data = new
  8654. {
  8655. groupCost = Create.Data,
  8656. blackCodeIsTrue = true
  8657. };
  8658. }
  8659. else
  8660. {
  8661. jw.Code = 400;
  8662. jw.Data = new
  8663. {
  8664. groupCost = Create.Data,
  8665. blackCodeIsTrue = false,
  8666. };
  8667. }
  8668. return Ok(jw);
  8669. }
  8670. /// <summary>
  8671. /// 成本获取OP历史车费用
  8672. /// </summary>
  8673. /// <param name="dto"></param>
  8674. /// <returns></returns>
  8675. [HttpPost]
  8676. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8677. {
  8678. var jw = JsonView(false);
  8679. try
  8680. {
  8681. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8682. //获取现有所有车的数据
  8683. if (!dto.Param.IsNullOrWhiteSpace())
  8684. {
  8685. string sql = $@"
  8686. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8687. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8688. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8689. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  8690. AND gctggr.ServiceEndTime is not NULL
  8691. ORDER by gctggrc.id DESC
  8692. ";
  8693. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8694. var numeberResult = await Task.Run(() =>
  8695. {
  8696. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8697. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8698. return numberArr;
  8699. });
  8700. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8701. foreach (var item in numeberResult)
  8702. {
  8703. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8704. {
  8705. Country = "数据异常!",
  8706. City = string.Empty,
  8707. };
  8708. item.Area = find.Country + " " + find.City;
  8709. }
  8710. dbResult.AddRange(numeberResult);
  8711. if (dto.Param.Contains("、"))
  8712. {
  8713. var sp = dto.Param.Split("、");
  8714. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8715. .Where(x =>
  8716. {
  8717. return System.Array.Exists(sp, e =>
  8718. {
  8719. bool where = false;
  8720. if (x.Area != null)
  8721. {
  8722. where = x.Area.Contains(e);
  8723. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8724. {
  8725. return false;
  8726. }
  8727. }
  8728. if (x.PriceName != null && !where)
  8729. {
  8730. where = x.PriceName.Contains(e);
  8731. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8732. {
  8733. return false;
  8734. }
  8735. }
  8736. return where;
  8737. });
  8738. }).ToList();
  8739. }
  8740. else
  8741. {
  8742. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8743. .Where(x =>
  8744. {
  8745. bool where = false;
  8746. if (x.Area != null)
  8747. {
  8748. where = x.Area.Contains(dto.Param);
  8749. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8750. {
  8751. return false;
  8752. }
  8753. }
  8754. if (x.PriceName != null && !where)
  8755. {
  8756. where = x.PriceName.Contains(dto.Param);
  8757. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8758. {
  8759. return false;
  8760. }
  8761. }
  8762. return where;
  8763. }
  8764. )
  8765. .ToList();
  8766. }
  8767. }
  8768. var view = dbResult.Select(x =>
  8769. {
  8770. decimal dp = 0.00M;
  8771. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8772. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8773. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8774. {
  8775. if (startB && endB)
  8776. {
  8777. var timesp = endD.Subtract(startD);
  8778. if ((timesp.Days + 1) != 0)
  8779. {
  8780. dp = x.Price / (timesp.Days + 1);
  8781. }
  8782. }
  8783. }
  8784. else
  8785. {
  8786. dp = x.Price;
  8787. }
  8788. return new
  8789. {
  8790. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8791. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8792. x.Area,
  8793. x.id,
  8794. price = x.Price.ToString("F2"),
  8795. x.PriceName,
  8796. x.PriceContent,
  8797. x.TeamName,
  8798. x.DatePrice,
  8799. dayPrice = dp.ToString("F2"),
  8800. };
  8801. }).OrderByDescending(x => x.id).ToList();
  8802. jw = JsonView(true, "获取成功!", view);
  8803. }
  8804. catch (Exception e)
  8805. {
  8806. jw = JsonView(false, e.Message);
  8807. }
  8808. return Ok(jw);
  8809. }
  8810. #endregion
  8811. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8812. /// <summary>
  8813. /// 酒店预订
  8814. /// 酒店费用列表 根据团组Id查询
  8815. /// </summary>
  8816. /// <param name="_dto"></param>
  8817. /// <returns></returns>
  8818. [HttpPost]
  8819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8820. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8821. {
  8822. #region 参数验证
  8823. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8824. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8825. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8826. #region 团组操作权限验证 76 酒店预定模块
  8827. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8828. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8829. #endregion
  8830. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8831. #region 页面操作权限验证
  8832. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8833. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8834. #endregion
  8835. #endregion
  8836. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8837. }
  8838. /// <summary>
  8839. /// 酒店预订
  8840. /// 基础数据
  8841. /// </summary>
  8842. /// <param name="_dto"></param>
  8843. /// <returns></returns>
  8844. [HttpPost]
  8845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8846. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8847. {
  8848. #region 参数验证
  8849. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8850. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8851. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8852. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8853. #region 页面操作权限验证
  8854. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8855. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8856. #endregion
  8857. #region 团组操作权限验证 76 酒店预定模块
  8858. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8859. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8860. #endregion
  8861. #endregion
  8862. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8863. }
  8864. /// <summary>
  8865. /// 酒店预订
  8866. /// 创建 入住卷号码
  8867. /// </summary>
  8868. /// <param name="_dto"></param>
  8869. /// <returns></returns>
  8870. [HttpPost]
  8871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8872. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8873. {
  8874. try
  8875. {
  8876. #region 参数验证
  8877. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8878. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8879. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8880. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8881. #region 页面操作权限验证
  8882. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8883. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8884. #endregion
  8885. #region 团组操作权限验证 76 酒店预定模块
  8886. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8887. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8888. #endregion
  8889. #endregion
  8890. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8891. if (data.Code != 0)
  8892. {
  8893. return Ok(JsonView(false, data.Msg));
  8894. }
  8895. return Ok(JsonView(true, data.Msg, data.Data));
  8896. }
  8897. catch (Exception ex)
  8898. {
  8899. return Ok(JsonView(false, ex.Message));
  8900. }
  8901. }
  8902. /// <summary>
  8903. /// 酒店预订
  8904. /// 详情
  8905. /// </summary>
  8906. /// <param name="_dto"></param>
  8907. /// <returns></returns>
  8908. [HttpPost]
  8909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8910. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8911. {
  8912. #region 参数验证
  8913. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8914. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8915. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8916. #region 团组操作权限验证 76 酒店预定模块
  8917. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8918. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8919. #endregion
  8920. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8921. #region 页面操作权限验证
  8922. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8923. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8924. #endregion
  8925. #endregion
  8926. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8927. }
  8928. /// <summary>
  8929. /// 酒店预订
  8930. /// Add Or Edit
  8931. /// </summary>
  8932. /// <param name="_dto"></param>
  8933. /// <returns></returns>
  8934. [HttpPost]
  8935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8936. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8937. {
  8938. #region 参数验证
  8939. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8940. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8941. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8942. #region 团组操作权限验证 76 酒店预定模块
  8943. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8944. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8945. #endregion
  8946. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8947. #region 页面操作权限验证
  8948. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8949. if (_dto.Id == 0) // Add
  8950. {
  8951. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8952. }
  8953. else if (_dto.Id > 1) // Edit
  8954. {
  8955. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8956. }
  8957. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8958. #endregion
  8959. #endregion
  8960. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8961. if (_view.Code != 200)
  8962. {
  8963. return Ok(_view);
  8964. }
  8965. #region 应用推送
  8966. try
  8967. {
  8968. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8969. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8970. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8971. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8972. //自动审核
  8973. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8974. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  8975. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  8976. }
  8977. catch (Exception ex)
  8978. {
  8979. }
  8980. #endregion
  8981. return Ok(_view);
  8982. }
  8983. /// <summary>
  8984. /// 酒店自动审核测试
  8985. /// Add Or Edit
  8986. /// </summary>
  8987. /// <param name="_dto"></param>
  8988. /// <returns></returns>
  8989. [HttpPost]
  8990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8991. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  8992. {
  8993. #region 应用推送
  8994. try
  8995. {
  8996. //自动审核
  8997. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  8998. }
  8999. catch (Exception ex)
  9000. {
  9001. return Ok(JsonView(false, "操作失败"));
  9002. }
  9003. #endregion
  9004. return Ok(JsonView(false,"操作成功"));
  9005. }
  9006. /// <summary>
  9007. /// 酒店预订
  9008. /// Del
  9009. /// </summary>
  9010. /// <param name="_dto"></param>
  9011. /// <returns></returns>
  9012. [HttpPost]
  9013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9014. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  9015. {
  9016. #region 参数验证
  9017. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9018. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9019. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9020. #region 团组操作权限验证 76 酒店预定模块
  9021. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9022. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9023. #endregion
  9024. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9025. #region 页面操作权限验证
  9026. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9027. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9028. #endregion
  9029. #endregion
  9030. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  9031. }
  9032. /// <summary>
  9033. /// 酒店预订
  9034. /// 生成VOUCHER
  9035. /// 2024.05.06 之前版本
  9036. /// </summary>
  9037. /// <param name="_dto"></param>
  9038. /// <returns></returns>
  9039. [HttpPost]
  9040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9041. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  9042. {
  9043. try
  9044. {
  9045. #region 参数验证
  9046. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  9047. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9048. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  9049. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  9050. #region 团组操作权限验证 76 酒店预定模块
  9051. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9052. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9053. #endregion
  9054. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9055. #region 页面操作权限验证
  9056. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9057. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9058. #endregion
  9059. #endregion
  9060. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  9061. //判断数据是否完整
  9062. if (hr != null)
  9063. {
  9064. if (!string.IsNullOrEmpty(hr.DetermineNo))
  9065. {
  9066. string strFileName = "HotelStatement/";
  9067. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9068. if (dele != null)
  9069. strFileName += dele.TourCode;
  9070. //载入模板
  9071. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9072. Document doc = new Document(sss);
  9073. DocumentBuilder builder = new DocumentBuilder(doc);
  9074. #region 替换Word模板书签内容
  9075. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9076. //入住卷预定号码
  9077. if (doc.Range.Bookmarks["VNO"] != null)
  9078. {
  9079. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9080. mark.Text = hr.CheckNumber;
  9081. }
  9082. //酒店时间
  9083. if (doc.Range.Bookmarks["Date"] != null)
  9084. {
  9085. Bookmark mark = doc.Range.Bookmarks["Date"];
  9086. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9087. }
  9088. //团号
  9089. if (doc.Range.Bookmarks["TNo"] != null)
  9090. {
  9091. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9092. mark.Text = dele.TourCode;
  9093. }
  9094. //预定号码
  9095. if (doc.Range.Bookmarks["BookingId"] != null)
  9096. {
  9097. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9098. mark.Text = hr.ReservationsNo;
  9099. }
  9100. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9101. {
  9102. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9103. mark.Text = hr.DetermineNo;
  9104. }
  9105. //酒店城市
  9106. if (doc.Range.Bookmarks["City"] != null)
  9107. {
  9108. Bookmark mark = doc.Range.Bookmarks["City"];
  9109. mark.Text = hr.City;
  9110. }
  9111. //酒店名称
  9112. if (doc.Range.Bookmarks["HName"] != null)
  9113. {
  9114. Bookmark mark = doc.Range.Bookmarks["HName"];
  9115. mark.Text = hr.HotelName;
  9116. }
  9117. //酒店地址
  9118. if (doc.Range.Bookmarks["Address"] != null)
  9119. {
  9120. Bookmark mark = doc.Range.Bookmarks["Address"];
  9121. mark.Text = hr.HotelAddress;
  9122. }
  9123. //酒店电话
  9124. if (doc.Range.Bookmarks["Tel"] != null)
  9125. {
  9126. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9127. mark.Text = hr.HotelTel;
  9128. }
  9129. //酒店传真
  9130. if (doc.Range.Bookmarks["Fax"] != null)
  9131. {
  9132. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9133. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9134. {
  9135. mark.Text = hr.HotelFax;
  9136. }
  9137. }
  9138. //入住时间
  9139. if (doc.Range.Bookmarks["CIn"] != null)
  9140. {
  9141. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9142. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9143. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9144. }
  9145. //退房时间
  9146. if (doc.Range.Bookmarks["COut"] != null)
  9147. {
  9148. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9149. Bookmark mark = doc.Range.Bookmarks["COut"];
  9150. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9151. }
  9152. //客户名称
  9153. if (doc.Range.Bookmarks["GName"] != null)
  9154. {
  9155. string guestName = "";
  9156. string[] clients = new string[] { };
  9157. if (hr.GuestName.Contains(","))
  9158. {
  9159. clients = hr.GuestName.Split(",");
  9160. }
  9161. else
  9162. {
  9163. clients = new string[] { hr.GuestName };
  9164. }
  9165. List<int> clientIds_int = new List<int>();
  9166. if (clients.Length > 0)
  9167. {
  9168. foreach (var item in clients)
  9169. {
  9170. if (item.IsNumeric())
  9171. {
  9172. clientIds_int.Add(int.Parse(item));
  9173. }
  9174. }
  9175. }
  9176. if (clientIds_int.Count > 0)
  9177. {
  9178. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9179. foreach (var client in _clientDatas)
  9180. {
  9181. //男
  9182. if (client.Sex == 0) guestName += $"Mr.";
  9183. //女
  9184. else if (client.Sex == 1) guestName += $"Ms.";
  9185. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9186. {
  9187. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9188. }
  9189. //guestName += $"{client.Pinyin},";
  9190. }
  9191. if (guestName.Length > 0)
  9192. {
  9193. guestName = guestName.Substring(0, guestName.Length - 1);
  9194. }
  9195. }
  9196. else
  9197. {
  9198. guestName = hr.GuestName;
  9199. }
  9200. Bookmark mark = doc.Range.Bookmarks["GName"];
  9201. mark.Text = guestName;
  9202. }
  9203. //房间介绍
  9204. if (doc.Range.Bookmarks["ROOM"] != null)
  9205. {
  9206. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9207. mark.Text = hr.RoomExplanation;
  9208. }
  9209. //报价描述
  9210. if (doc.Range.Bookmarks["NOTE"] != null)
  9211. {
  9212. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9213. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9214. if (ss != null)
  9215. mark.Text = ss.Name;
  9216. }
  9217. //入住时间
  9218. if (doc.Range.Bookmarks["CheckIn"] != null)
  9219. {
  9220. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9221. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9222. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9223. }
  9224. //退房时间
  9225. if (doc.Range.Bookmarks["CheckOut"] != null)
  9226. {
  9227. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9228. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9229. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9230. }
  9231. //日期
  9232. if (doc.Range.Bookmarks["DT"] != null)
  9233. {
  9234. Bookmark mark = doc.Range.Bookmarks["DT"];
  9235. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9236. }
  9237. //名称
  9238. if (doc.Range.Bookmarks["VName"] != null)
  9239. {
  9240. Bookmark mark = doc.Range.Bookmarks["VName"];
  9241. mark.Text = hr.HotelName;
  9242. }
  9243. //号码
  9244. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9245. {
  9246. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9247. mark.Text = hr.CheckNumber;
  9248. }
  9249. #endregion
  9250. strFileName += "VOUCHER.doc";
  9251. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9252. doc.Save(fileDir);
  9253. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9254. return Ok(JsonView(true, "操作成功!", Url));
  9255. }
  9256. else
  9257. {
  9258. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9259. }
  9260. }
  9261. else
  9262. {
  9263. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9264. }
  9265. }
  9266. catch (Exception ex)
  9267. {
  9268. return Ok(JsonView(false, ex.Message));
  9269. }
  9270. }
  9271. /// <summary>
  9272. /// 酒店预订
  9273. /// 生成VOUCHER
  9274. /// 2024.05.06 之后版本
  9275. /// </summary>
  9276. /// <param name="_dto"></param>
  9277. /// <returns></returns>
  9278. [HttpPost]
  9279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9280. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9281. {
  9282. #region 参数验证
  9283. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9284. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9285. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9286. #region 团组操作权限验证 76 酒店预定模块
  9287. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9288. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9289. #endregion
  9290. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9291. #region 页面操作权限验证
  9292. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9293. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9294. #endregion
  9295. #endregion
  9296. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9297. //判断数据是否完整
  9298. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9299. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9300. string strFileName = "HotelStatement/";
  9301. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9302. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9303. #region 数据处理
  9304. List<int> guestIds = new List<int>();
  9305. int index = 0;
  9306. foreach (var item in hrDtas)
  9307. {
  9308. if (item.GuestName.Contains(","))
  9309. {
  9310. string[] guestIdArr = item.GuestName.Split(',');
  9311. foreach (var guestIdStr in guestIdArr)
  9312. {
  9313. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9314. if (guestBool)
  9315. {
  9316. guestIds.Add(guestId);
  9317. }
  9318. }
  9319. }
  9320. else guestNames += item.GuestName;
  9321. var voucherInfo = new HotelVoucherInfoView()
  9322. {
  9323. HotelName = item.HotelName,
  9324. CheckInDate = item.CheckInDate,
  9325. CheckOutDate = item.CheckOutDate,
  9326. ConfirmationNumber = item.DetermineNo.Trim(),
  9327. RoomType = item.RoomExplanation
  9328. };
  9329. vouchers.Add(voucherInfo);
  9330. }
  9331. if (guestIds.Count > 0)
  9332. {
  9333. guestIds = guestIds.Distinct().ToList();
  9334. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9335. if (guestDatas.Count > 0)
  9336. {
  9337. guestNames = "";
  9338. foreach (var guest in guestDatas)
  9339. {
  9340. string guestName = "";
  9341. if (guest.Sex == 0) guestName += @"MR.";
  9342. else if (guest.Sex == 1) guestName += @"MS.";
  9343. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9344. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9345. guestNames += @$"{guestName.Trim()}、";
  9346. }
  9347. if (guestNames.Length > 0)
  9348. {
  9349. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9350. }
  9351. }
  9352. }
  9353. #endregion
  9354. //载入模板
  9355. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9356. Document doc = new Document(sss);
  9357. DocumentBuilder builder = new DocumentBuilder(doc);
  9358. if (doc.Range.Bookmarks["GuestName"] != null)
  9359. {
  9360. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9361. mark.Text = guestNames;
  9362. }
  9363. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9364. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9365. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9366. for (int i = 1; i <= vouchers.Count; i++)
  9367. {
  9368. HotelVoucherInfoView hviv = vouchers[i - 1];
  9369. builder.MoveToCell(0, i, 0, 0);
  9370. builder.Write(hviv.HotelName);
  9371. builder.MoveToCell(0, i, 1, 0);
  9372. builder.Write(hviv.CheckInDate);
  9373. builder.MoveToCell(0, i, 2, 0);
  9374. builder.Write(hviv.CheckOutDate);
  9375. builder.MoveToCell(0, i, 3, 0);
  9376. builder.Write(hviv.RoomType);
  9377. builder.MoveToCell(0, i, 4, 0);
  9378. builder.Write(hviv.ConfirmationNumber);
  9379. }
  9380. //删除多余行
  9381. int currRowIndex = vouchers.Count + 1;
  9382. int delRows = 21 - currRowIndex;
  9383. if (delRows > 0)
  9384. {
  9385. for (int i = 0; i < delRows; i++)
  9386. {
  9387. table.Rows.RemoveAt(currRowIndex);
  9388. //cultivateRowIndex++;
  9389. }
  9390. }
  9391. strFileName += "VOUCHER.docx";
  9392. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9393. doc.Save(fileDir);
  9394. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9395. return Ok(JsonView(true, "操作成功!", Url));
  9396. }
  9397. /// <summary>
  9398. /// 酒店预订
  9399. /// 生成VOUCHER 批量生成
  9400. /// New
  9401. /// </summary>
  9402. /// <param name="_dto"></param>
  9403. /// <returns></returns>
  9404. [HttpPost]
  9405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9406. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9407. {
  9408. #region 参数验证
  9409. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9410. if (_dto.PageId < 1) _dto.PageId = 28;
  9411. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9412. #region 团组操作权限验证 76 酒店预定模块
  9413. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9414. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9415. #endregion
  9416. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9417. #region 页面操作权限验证
  9418. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9419. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9420. #endregion
  9421. #endregion
  9422. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9423. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9424. .OrderBy(x => x.CreateTime)
  9425. .ToListAsync();
  9426. //判断数据是否完整
  9427. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9428. string strFileName = "HotelStatement/";
  9429. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9430. if (dele != null)
  9431. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  9432. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9433. for (int i = 0; i < hrDtas.Count; i++)
  9434. {
  9435. string guestNames = string.Empty;
  9436. List<int> guestIds = new List<int>();
  9437. var item = hrDtas[i];
  9438. //处理客户姓名
  9439. if (item.GuestName.Contains(","))
  9440. {
  9441. string[] guestIdArr = item.GuestName.Split(',');
  9442. foreach (var guestIdStr in guestIdArr)
  9443. if (int.TryParse(guestIdStr, out int guestId))
  9444. guestIds.Add(guestId);
  9445. }
  9446. else {
  9447. //NaN
  9448. if (item.GuestName.Contains("NaN"))
  9449. {
  9450. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  9451. }
  9452. }
  9453. if (guestIds.Count > 0)
  9454. {
  9455. guestIds = guestIds.Distinct().ToList();
  9456. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9457. if (guestDatas1.Count > 0)
  9458. {
  9459. guestNames = "";
  9460. foreach (var guest in guestDatas1)
  9461. {
  9462. string guestName = "";
  9463. if (guest.Sex == 0) guestName += @"MR.";
  9464. else if (guest.Sex == 1) guestName += @"MS.";
  9465. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9466. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9467. guestNames += @$"{guestName.Trim()}、";
  9468. }
  9469. if (guestNames.Length > 0)
  9470. {
  9471. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9472. }
  9473. }
  9474. }
  9475. //if (!string.IsNullOrEmpty(guestNames))
  9476. //{
  9477. hrDtas[i].GuestName = guestNames;
  9478. //}
  9479. }
  9480. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  9481. Document doc = new Document();
  9482. DocumentBuilder builder = new DocumentBuilder(doc);
  9483. try
  9484. {
  9485. builder.MoveToDocumentStart();
  9486. foreach (var item in hrDtas)
  9487. {
  9488. //标题
  9489. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9490. builder.ParagraphFormat.LineSpacing = 1;
  9491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9492. builder.ParagraphFormat.Style.Font.Size = 9;
  9493. builder.ParagraphFormat.Style.Font.Bold = true;
  9494. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9495. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9496. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9497. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9498. builder.ParagraphFormat.LineSpacing = 1;
  9499. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9500. builder.ParagraphFormat.Style.Font.Size = 9;
  9501. builder.ParagraphFormat.Style.Font.Bold = true;
  9502. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9503. builder.StartTable();
  9504. // 设置边框颜色
  9505. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9506. //设置边框样式
  9507. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  9508. //表格
  9509. #region 第一行
  9510. builder.InsertCell();
  9511. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9512. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9513. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9514. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9515. builder.ParagraphFormat.Style.Font.Bold = false;
  9516. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9517. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9518. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9519. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9520. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9521. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9522. builder.Write("TOUR NO:");
  9523. builder.InsertCell();
  9524. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9525. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9526. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9527. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9528. builder.ParagraphFormat.Style.Font.Bold = false;
  9529. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9530. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9531. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9532. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9533. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9534. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9535. builder.Write($"{dele?.TourCode ?? "-"}");
  9536. builder.InsertCell();
  9537. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9538. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9539. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9540. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9541. builder.ParagraphFormat.Style.Font.Bold = false;
  9542. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9543. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9544. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9545. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9546. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9547. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9548. builder.Write($"CITY:");
  9549. builder.InsertCell();
  9550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9551. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9552. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9553. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9554. builder.ParagraphFormat.Style.Font.Bold = false;
  9555. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9557. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9558. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9559. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9560. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9561. builder.Write($"{item.City}");
  9562. builder.EndRow();
  9563. #endregion
  9564. #region 第二行
  9565. builder.InsertCell();
  9566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9567. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9570. builder.ParagraphFormat.Style.Font.Bold = false;
  9571. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9572. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9573. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9574. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9575. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9576. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9577. builder.Write("CONFIRMATION NO:");
  9578. builder.InsertCell();
  9579. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9580. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9581. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9582. builder.ParagraphFormat.Style.Font.Bold = false;
  9583. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9584. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9585. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9586. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9587. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9588. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9589. builder.CellFormat.VerticalMerge = CellMerge.None;
  9590. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9591. builder.Write($"{item.DetermineNo}");
  9592. builder.InsertCell();
  9593. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9594. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9595. builder.InsertCell();
  9596. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9597. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9598. builder.EndRow();
  9599. #endregion
  9600. #region 第三行
  9601. builder.InsertCell();
  9602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9603. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9604. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9605. builder.ParagraphFormat.Style.Font.Bold = false;
  9606. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9609. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9610. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9611. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9612. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9613. builder.Write($"HOTEL NAME:");
  9614. builder.InsertCell();
  9615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9617. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9618. builder.ParagraphFormat.Style.Font.Bold = false;
  9619. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9622. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9623. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9624. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9625. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9626. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9627. builder.Write($"{item.HotelName}");
  9628. builder.InsertCell();
  9629. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9630. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9631. builder.InsertCell();
  9632. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9633. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9634. builder.EndRow();
  9635. #endregion
  9636. #region 第四行
  9637. builder.InsertCell();
  9638. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9639. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9640. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9641. builder.ParagraphFormat.Style.Font.Bold = false;
  9642. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9643. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9644. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9645. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9646. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9647. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9648. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9649. builder.Write($"HOTEL ADDRESS:");
  9650. builder.InsertCell();
  9651. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9652. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9653. builder.ParagraphFormat.Style.Font.Size = 8;
  9654. builder.ParagraphFormat.Style.Font.Bold = false;
  9655. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9656. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9657. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9658. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9659. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9660. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9661. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9662. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9663. builder.Write($"{item.HotelAddress}");
  9664. builder.InsertCell();
  9665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9666. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9667. builder.InsertCell();
  9668. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9669. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9670. builder.EndRow();
  9671. #endregion
  9672. #region 第五行
  9673. builder.InsertCell();
  9674. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9675. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9676. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9677. builder.ParagraphFormat.Style.Font.Bold = false;
  9678. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9679. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9680. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9681. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9682. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9683. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9684. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9685. builder.Write("TEL:");
  9686. builder.InsertCell();
  9687. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9688. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9689. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9690. builder.ParagraphFormat.Style.Font.Bold = false;
  9691. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9692. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9693. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9694. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9695. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9696. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9697. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9698. builder.Write($"{item.HotelTel}");
  9699. builder.InsertCell();
  9700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9701. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9702. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9703. builder.ParagraphFormat.Style.Font.Bold = false;
  9704. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9705. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9706. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9707. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9708. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9709. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9710. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9711. builder.Write($"FAX:");
  9712. builder.InsertCell();
  9713. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9714. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9715. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9716. builder.ParagraphFormat.Style.Font.Bold = false;
  9717. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9718. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9719. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9720. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9721. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9722. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9723. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9724. builder.Write($"{item.HotelFax}");
  9725. builder.EndRow();
  9726. #endregion
  9727. #region 第六行
  9728. builder.InsertCell();
  9729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9730. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9731. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9732. builder.ParagraphFormat.Style.Font.Bold = false;
  9733. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9734. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9735. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9736. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9737. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9738. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9739. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9740. builder.Write("CHECK IN:");
  9741. builder.InsertCell();
  9742. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9743. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9744. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9745. builder.ParagraphFormat.Style.Font.Bold = false;
  9746. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9747. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9748. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9749. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9750. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9751. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9752. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9753. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  9754. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9755. builder.Write($"{checkInStr}");
  9756. builder.InsertCell();
  9757. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9758. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9759. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9760. builder.ParagraphFormat.Style.Font.Bold = false;
  9761. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9762. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9763. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9764. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9765. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9766. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9767. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9768. builder.Write($"CHECK OUT:");
  9769. builder.InsertCell();
  9770. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9771. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9772. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9773. builder.ParagraphFormat.Style.Font.Bold = false;
  9774. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9775. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9776. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9777. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9778. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9779. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9780. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9781. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  9782. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  9783. builder.Write($"{checkOutStr}");
  9784. builder.EndRow();
  9785. #endregion
  9786. #region 第七行
  9787. builder.InsertCell();
  9788. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9789. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9790. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9791. builder.ParagraphFormat.Style.Font.Bold = false;
  9792. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9793. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9794. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9795. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9796. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9797. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9798. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9799. builder.Write($"GUEST NAME:");
  9800. builder.InsertCell();
  9801. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9802. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9803. builder.ParagraphFormat.Style.Font.Size = 8;
  9804. builder.ParagraphFormat.Style.Font.Bold = false;
  9805. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9806. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9807. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9808. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9809. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9810. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9811. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9812. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9813. builder.Write($"{item.GuestName}");
  9814. builder.InsertCell();
  9815. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9816. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9817. builder.InsertCell();
  9818. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9819. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9820. builder.EndRow();
  9821. #endregion
  9822. #region 第八行
  9823. builder.InsertCell();
  9824. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9825. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9826. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9827. builder.ParagraphFormat.Style.Font.Bold = false;
  9828. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9829. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9830. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9831. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9832. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9833. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9834. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9835. builder.Write($"ROOM TYPE:");
  9836. builder.InsertCell();
  9837. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9838. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9839. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9840. builder.ParagraphFormat.Style.Font.Bold = false;
  9841. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9842. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9843. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9844. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9845. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9846. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9847. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9848. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9849. builder.Write($"{item.RoomExplanation}");
  9850. builder.InsertCell();
  9851. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9852. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9853. builder.InsertCell();
  9854. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9855. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9856. builder.EndRow();
  9857. #endregion
  9858. #region 第九行
  9859. builder.InsertCell();
  9860. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9861. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9862. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9863. builder.ParagraphFormat.Style.Font.Bold = false;
  9864. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9865. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9866. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9867. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  9868. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  9869. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  9870. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  9871. builder.Write($"NOTE:");
  9872. builder.InsertCell();
  9873. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9874. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9875. builder.ParagraphFormat.Style.Font.Size = 7.5;
  9876. builder.ParagraphFormat.Style.Font.Bold = false;
  9877. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9878. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9879. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9880. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9881. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  9882. builder.InsertCell();
  9883. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9884. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9885. builder.InsertCell();
  9886. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9887. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9888. builder.EndRow();
  9889. #endregion
  9890. builder.EndTable();
  9891. //换行
  9892. builder.Writeln("");
  9893. builder.Writeln("");
  9894. }
  9895. #region 设置页眉
  9896. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  9897. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  9898. if (System.IO.File.Exists(voucherHeaderPath))
  9899. {
  9900. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  9901. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  9902. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  9903. Shape shape = builder.InsertImage(imageBytes);
  9904. // 调整图片位置
  9905. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  9906. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  9907. shape.Top = 50; // 将图片距离页眉上边缘的距离
  9908. shape.Left = 0; // 将图片距离页面左边缘的距离
  9909. shape.Width = 81; // 设置图片宽度
  9910. shape.Height = 36; // 设置图片高度
  9911. }
  9912. //靠右
  9913. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  9914. //// 设置页脚上下边距
  9915. //builder.PageSetup.HeaderDistance = 42;
  9916. // 添加页眉线
  9917. Aspose.Words.Border borderHeader = null;
  9918. try
  9919. {
  9920. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  9921. }
  9922. catch (Exception e)
  9923. {
  9924. // TODO Auto-generated catch block
  9925. //e.printStackTrace();
  9926. }
  9927. borderHeader.Shadow = true;
  9928. borderHeader.DistanceFromText = 2;
  9929. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  9930. #endregion
  9931. }
  9932. catch (Exception ex)
  9933. {
  9934. }
  9935. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9936. doc.Save(fileDir);
  9937. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9938. return Ok(JsonView(true, "操作成功!", Url));
  9939. }
  9940. /// <summary>
  9941. /// 酒店预订
  9942. /// 生成 预定成本 Excel
  9943. /// </summary>
  9944. /// <param name="_dto"></param>
  9945. /// <returns></returns>
  9946. [HttpPost]
  9947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9948. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9949. {
  9950. #region 参数验证
  9951. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9952. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9953. if (!vadalitorRes.IsValid)
  9954. {
  9955. var errors = new StringBuilder();
  9956. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9957. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9958. }
  9959. #region 团组操作权限验证 76 酒店预定模块
  9960. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9961. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9962. #endregion
  9963. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9964. #region 页面操作权限验证
  9965. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9966. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9967. #endregion
  9968. #endregion
  9969. decimal _rate = 1.00M;
  9970. string _currency = "";
  9971. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9972. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9973. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9974. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9975. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9976. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9977. {
  9978. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9979. }
  9980. _currency = _GroupCostParameter.Currency;
  9981. bool isIntType = int.TryParse(_currency, out int currId);
  9982. if (isIntType)
  9983. {
  9984. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9985. }
  9986. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9987. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9988. if (currInfo == null)
  9989. {
  9990. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9991. }
  9992. if (!_currency.ToUpper().Equals("CNY"))
  9993. {
  9994. _rate = _GroupCostParameter.Rate;
  9995. }
  9996. _rate = currInfo.Rate;
  9997. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9998. string strFileName = "HotelStatement/";
  9999. string guestNames = ""; //格式Mr.xxx Ms.xxx
  10000. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  10001. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  10002. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  10003. #region 数据处理
  10004. foreach (var item in hrDtas)
  10005. {
  10006. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  10007. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  10008. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  10009. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  10010. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  10011. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  10012. string singleRoomFeeStr = string.Empty,
  10013. doubleRoomFeeStr = string.Empty,
  10014. suiteRoomFeeStr = string.Empty,
  10015. otherRoomFeeStr = string.Empty,
  10016. payMoneyStr = string.Empty,
  10017. cardPriceStr = string.Empty;
  10018. if (roomCurr.Equals(_currency))
  10019. {
  10020. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  10021. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  10022. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  10023. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  10024. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  10025. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  10026. }
  10027. else
  10028. {
  10029. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  10030. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  10031. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  10032. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  10033. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  10034. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  10035. }
  10036. string breakfastPriceStr = string.Empty,
  10037. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  10038. governmentRentStr = string.Empty,
  10039. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  10040. cityTaxStrStr = string.Empty,
  10041. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  10042. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  10043. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  10044. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  10045. int payDId = roomInfo?.PayDId ?? 0;
  10046. pcfds.Add(new HotelReservations_PCFD_View()
  10047. {
  10048. City = item.City,
  10049. HotelName = item.HotelName,
  10050. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  10051. // SingleRoomCount = item.SingleRoomCount,
  10052. SingleRoomPrice = singleRoomFeeStr,
  10053. // DoubleRoomCount = item.DoubleRoomCount,
  10054. DoubleRoomPrice = doubleRoomFeeStr,
  10055. //SuiteRoomCount = item.SuiteRoomCount,
  10056. SuiteRoomPrice = suiteRoomFeeStr,
  10057. OtherRoomPrice = otherRoomFeeStr,
  10058. //OtherRoomCount = item.OtherRoomCount,
  10059. BreakfastPrice = breakfastPriceStr,
  10060. GovernmentRent = governmentRentStr,
  10061. CityTax = cityTaxStrStr,
  10062. RoomExplanation = item.RoomExplanation,
  10063. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  10064. PayTime = roomInfo?.ConsumptionDate,
  10065. BankNo = roomInfo?.BankNo,
  10066. PayMoney = payMoneyStr,
  10067. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  10068. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  10069. CardPrice = cardPriceStr,
  10070. Remark = ccpInfo.Remark
  10071. });
  10072. }
  10073. #endregion
  10074. //载入模板
  10075. WorkbookDesigner designer = new WorkbookDesigner();
  10076. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  10077. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  10078. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  10079. designer.SetDataSource("TourNo", groupInfo.TourCode);
  10080. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  10081. designer.SetDataSource("Opertor", userInfo.CnName);
  10082. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  10083. dt.TableName = "ViewMyHotelReservations";
  10084. designer.SetDataSource(dt);
  10085. designer.Process();
  10086. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10087. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  10088. designer.Workbook.Save(serverPath);
  10089. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  10090. #region 删除指定行
  10091. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  10092. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  10093. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  10094. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  10095. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  10096. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  10097. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  10098. cssIndex = dt.Columns["CityTax"].Ordinal,
  10099. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  10100. remarkIndex = dt.Columns["Remark"].Ordinal;
  10101. //删除指定列
  10102. foreach (DataRow item in dt.Rows)
  10103. {
  10104. string singleStr = item["SingleRoomPrice"].ToString();
  10105. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  10106. if (containsDigitButNotZero1) singleDel = false;
  10107. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  10108. string doubleStr = item["DoubleRoomPrice"].ToString();
  10109. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10110. if (containsDigitButNotZero2) doubleDel = false;
  10111. string suiteStr = item["SuiteRoomPrice"].ToString();
  10112. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  10113. if (containsDigitButNotZero3) suiteDel = false;
  10114. string otherStr = item["OtherRoomPrice"].ToString();
  10115. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  10116. if (containsDigitButNotZero4) otherDel = false;
  10117. string zcStr = item["BreakfastPrice"].ToString();
  10118. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  10119. if (containsDigitButNotZero5) zcDel = false;
  10120. string dsStr = item["GovernmentRent"].ToString();
  10121. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  10122. if (containsDigitButNotZero6) dsDel = false;
  10123. string cssStr = item["CityTax"].ToString();
  10124. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  10125. if (containsDigitButNotZero7) cssDel = false;
  10126. string cpStr = item["ConsumptionPatterns"].ToString();
  10127. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  10128. string remarkStr = item["Remark"].ToString();
  10129. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  10130. }
  10131. DeleteColumn(serverPath, remarkIndex, remarkDel);
  10132. DeleteColumn(serverPath, cpIndex, cpDel);
  10133. DeleteColumn(serverPath, dsIndex, dsDel);
  10134. DeleteColumn(serverPath, cssIndex, cssDel);
  10135. DeleteColumn(serverPath, zcIndex, zcDel);
  10136. DeleteColumn(serverPath, otherIndex, otherDel);
  10137. DeleteColumn(serverPath, suiteIndex, suiteDel);
  10138. DeleteColumn(serverPath, doubleIndex, doubleDel);
  10139. DeleteColumn(serverPath, singleIndex, singleDel);
  10140. #endregion
  10141. //只保留第一个表格
  10142. DeleteSheet(serverPath);
  10143. return Ok(JsonView(true, "操作成功", url = rst));
  10144. }
  10145. /// <summary>
  10146. /// 删除指定列
  10147. /// </summary>
  10148. /// <param name="file"></param>
  10149. /// <param name="columnIndex"></param>
  10150. /// <param name="isDel"></param>
  10151. private void DeleteColumn(string file, int columnIndex, bool isDel)
  10152. {
  10153. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10154. //wb.Save(file);
  10155. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  10156. if (sheet1 != null)
  10157. {
  10158. if (isDel)
  10159. {
  10160. Cells cells = sheet1.Cells;
  10161. cells.DeleteColumn(columnIndex);
  10162. }
  10163. }
  10164. wb.Save(file);
  10165. }
  10166. /// <summary>
  10167. /// 删除sheet
  10168. /// </summary>
  10169. /// <param name="file"></param>
  10170. /// <param name="sheetName"></param>
  10171. private void DeleteSheet(string file, string sheetName = "")
  10172. {
  10173. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10174. //wb.Save(file);
  10175. List<string> sheets = new List<string>();
  10176. foreach (var item in wb.Worksheets)
  10177. {
  10178. sheets.Add(item.Name);
  10179. }
  10180. if (sheets.Count > 0)
  10181. {
  10182. sheets.RemoveAt(0);//不删除第一个sheet
  10183. foreach (var item in sheets)
  10184. {
  10185. wb.Worksheets.RemoveAt(item);
  10186. }
  10187. }
  10188. wb.Save(file);
  10189. }
  10190. /// <summary>
  10191. /// 酒店预订
  10192. /// 确认单
  10193. /// </summary>
  10194. /// <param name="_dto"></param>
  10195. /// <returns></returns>
  10196. [HttpPost]
  10197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10198. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10199. {
  10200. try
  10201. {
  10202. #region 参数验证
  10203. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10204. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10205. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10206. #region 团组操作权限验证 76 酒店预定模块
  10207. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10208. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10209. #endregion
  10210. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10211. #region 页面操作权限验证
  10212. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10213. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10214. #endregion
  10215. #endregion
  10216. //团组信息
  10217. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10218. //酒店数据
  10219. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10220. if (listhoteldata.Count < 0)
  10221. {
  10222. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10223. }
  10224. //利datatable存储
  10225. DataTable dt = new DataTable();
  10226. dt.Columns.Add("CheckInDate", typeof(string));
  10227. dt.Columns.Add("City", typeof(string));
  10228. dt.Columns.Add("Hotel", typeof(string));
  10229. dt.Columns.Add("Room", typeof(string));
  10230. for (int i = 0; i < listhoteldata.Count; i++)
  10231. {
  10232. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10233. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10234. while (dayStart < dayEnd)
  10235. {
  10236. string temp = "";
  10237. DataRow row = dt.NewRow();
  10238. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10239. row["City"] = listhoteldata[i].City;
  10240. row["Hotel"] = listhoteldata[i].HotelName;
  10241. if (listhoteldata[i].SingleRoomCount > 0)
  10242. {
  10243. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10244. }
  10245. if (listhoteldata[i].DoubleRoomCount > 0)
  10246. {
  10247. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10248. }
  10249. if (listhoteldata[i].SuiteRoomCount > 0)
  10250. {
  10251. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10252. }
  10253. if (listhoteldata[i].OtherRoomCount > 0)
  10254. {
  10255. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10256. }
  10257. row["Room"] = temp;
  10258. dt.Rows.Add(row);
  10259. dayStart = dayStart.AddDays(1);
  10260. }
  10261. }
  10262. Dictionary<string, string> dic = new Dictionary<string, string>();
  10263. dic.Add("Dele", di.TeamName);
  10264. dic.Add("City", di.VisitCountry);
  10265. //模板路径
  10266. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10267. //载入模板
  10268. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10269. DocumentBuilder builder = new DocumentBuilder(doc);
  10270. foreach (var key in dic.Keys)
  10271. {
  10272. builder.MoveToBookmark(key);
  10273. builder.Write(dic[key]);
  10274. }
  10275. //获取word里所有表格
  10276. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10277. //获取所填表格的序数
  10278. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10279. var rowStart = tableOne.Rows[0]; //获取第1行
  10280. //循环赋值
  10281. for (int i = 0; i < dt.Rows.Count; i++)
  10282. {
  10283. builder.MoveToCell(0, i + 1, 0, 0);
  10284. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10285. builder.MoveToCell(0, i + 1, 1, 0);
  10286. builder.Write(dt.Rows[i]["City"].ToString());
  10287. builder.MoveToCell(0, i + 1, 2, 0);
  10288. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10289. builder.MoveToCell(0, i + 1, 3, 0);
  10290. builder.Write(dt.Rows[i]["Room"].ToString());
  10291. }
  10292. //删除多余行
  10293. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10294. {
  10295. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10296. }
  10297. string strFileName = di.TeamName + "酒店确认单.doc";
  10298. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10299. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10300. return Ok(JsonView(true, "成功", url));
  10301. }
  10302. catch (Exception ex)
  10303. {
  10304. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10305. }
  10306. }
  10307. #endregion
  10308. #region 团组状态
  10309. /// <summary>
  10310. /// 团组状态列表 Page
  10311. /// </summary>
  10312. /// <param name="dto">团组列表请求dto</param>
  10313. /// <returns></returns>
  10314. [HttpPost]
  10315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10316. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10317. {
  10318. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10319. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10320. {
  10321. string sqlWhere = string.Empty;
  10322. if (dto.IsSure == 0) //未完成
  10323. {
  10324. sqlWhere += string.Format(@" And IsSure = 0");
  10325. }
  10326. else if (dto.IsSure == 1) //已完成
  10327. {
  10328. sqlWhere += string.Format(@" And IsSure = 1");
  10329. }
  10330. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10331. {
  10332. string tj = dto.SearchCriteria;
  10333. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
  10334. tj, tj, tj, tj, tj);
  10335. }
  10336. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10337. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10338. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10339. From (
  10340. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10341. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10342. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10343. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10344. From Grp_DelegationInfo gdi
  10345. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10346. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10347. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10348. Where gdi.IsDel = 0 {0}
  10349. ) temp ", sqlWhere);
  10350. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10351. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10352. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10353. }
  10354. else
  10355. {
  10356. return Ok(JsonView(false, "查询失败"));
  10357. }
  10358. }
  10359. /// <summary>
  10360. /// 团组状态
  10361. /// 设置操作完成
  10362. /// </summary>
  10363. /// <param name="dto">团组列表请求dto</param>
  10364. /// <returns></returns>
  10365. [HttpPost]
  10366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10367. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10368. {
  10369. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10370. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10371. {
  10372. Id = dto.Id,
  10373. IsSure = 1
  10374. };
  10375. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10376. .UpdateColumns(it => new { it.IsSure })
  10377. .WhereColumns(it => new { it.Id })
  10378. .ExecuteCommandAsync();
  10379. if (result > 0)
  10380. {
  10381. return Ok(JsonView(true, "操作完成!"));
  10382. }
  10383. return Ok(JsonView(false, "操作失败!"));
  10384. }
  10385. #endregion
  10386. #region 保险费用录入
  10387. /// <summary>
  10388. /// 根据团组Id查询保险费用列表
  10389. /// </summary>
  10390. /// <param name="dto"></param>
  10391. /// <returns></returns>
  10392. [HttpPost]
  10393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10394. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10395. {
  10396. try
  10397. {
  10398. Result groupData = await _customersRep.CustomersByDiId(dto);
  10399. if (groupData.Code != 0)
  10400. {
  10401. return Ok(JsonView(false, groupData.Msg));
  10402. }
  10403. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10404. }
  10405. catch (Exception ex)
  10406. {
  10407. return Ok(JsonView(false, ex.Message));
  10408. }
  10409. }
  10410. /// <summary>
  10411. /// 根据保险费用Id查询保险费用详细
  10412. /// </summary>
  10413. /// <param name="dto"></param>
  10414. /// <returns></returns>
  10415. [HttpPost]
  10416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10417. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10418. {
  10419. try
  10420. {
  10421. Result groupData = await _customersRep.CustomersById(dto);
  10422. if (groupData.Code != 0)
  10423. {
  10424. return Ok(JsonView(false, groupData.Msg));
  10425. }
  10426. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10427. }
  10428. catch (Exception ex)
  10429. {
  10430. return Ok(JsonView(false, ex.Message));
  10431. }
  10432. }
  10433. /// <summary>
  10434. /// 保险费用录入页面初始化绑定
  10435. /// </summary>
  10436. /// <param name="dto"></param>
  10437. /// <returns></returns>
  10438. [HttpPost]
  10439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10440. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10441. {
  10442. try
  10443. {
  10444. Result groupData = await _customersRep.CustomersInitialize(dto);
  10445. if (groupData.Code != 0)
  10446. {
  10447. return Ok(JsonView(false, groupData.Msg));
  10448. }
  10449. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10450. }
  10451. catch (Exception ex)
  10452. {
  10453. return Ok(JsonView(false, ex.Message));
  10454. }
  10455. }
  10456. /// <summary>
  10457. /// 保险费用操作(Status:1.新增,2.修改)
  10458. /// </summary>
  10459. /// <param name="dto"></param>
  10460. /// <returns></returns>
  10461. [HttpPost]
  10462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10463. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10464. {
  10465. try
  10466. {
  10467. Result groupData = await _customersRep.OpCustomers(dto);
  10468. if (groupData.Code != 0)
  10469. {
  10470. return Ok(JsonView(false, groupData.Msg));
  10471. }
  10472. #region 应用推送
  10473. try
  10474. {
  10475. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10476. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10477. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10478. }
  10479. catch (Exception ex)
  10480. {
  10481. }
  10482. #endregion
  10483. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10484. }
  10485. catch (Exception ex)
  10486. {
  10487. return Ok(JsonView(false, ex.Message));
  10488. }
  10489. }
  10490. /// <summary>
  10491. /// 保险文件上传
  10492. /// </summary>
  10493. /// <param name="file"></param>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> UploadCus(IFormFile file)
  10498. {
  10499. try
  10500. {
  10501. if (file != null)
  10502. {
  10503. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10504. //文件名称
  10505. string projectFileName = file.FileName;
  10506. //上传的文件的路径
  10507. string filePath = "";
  10508. if (!Directory.Exists(fileDir))
  10509. {
  10510. Directory.CreateDirectory(fileDir);
  10511. }
  10512. //上传的文件的路径
  10513. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10514. using (FileStream fs = System.IO.File.Create(filePath))
  10515. {
  10516. file.CopyTo(fs);
  10517. fs.Flush();
  10518. }
  10519. return Ok(JsonView(true, "上传成功!", projectFileName));
  10520. }
  10521. else
  10522. {
  10523. return Ok(JsonView(false, "上传失败!"));
  10524. }
  10525. }
  10526. catch (Exception ex)
  10527. {
  10528. return Ok(JsonView(false, "程序错误!"));
  10529. throw;
  10530. }
  10531. }
  10532. /// <summary>
  10533. /// 保险删除指定文件
  10534. /// </summary>
  10535. /// <param name="dto"></param>
  10536. /// <returns></returns>
  10537. [HttpPost]
  10538. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10539. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10540. {
  10541. try
  10542. {
  10543. string filePath = "";
  10544. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10545. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10546. //int id = 0;
  10547. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10548. // 删除该文件
  10549. try
  10550. {
  10551. System.IO.File.Delete(filePath);
  10552. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  10553. {
  10554. Attachment = "",
  10555. }).ExecuteCommandAsync();
  10556. if (result != 0)
  10557. {
  10558. return Ok(JsonView(true, "成功!"));
  10559. }
  10560. else
  10561. {
  10562. return Ok(JsonView(false, "失败!"));
  10563. }
  10564. }
  10565. catch (Exception)
  10566. {
  10567. var result = await _sqlSugar.Updateable<Grp_Customers>().Where(a => a.Id == dto.Id && a.IsDel == 0 && a.Attachment == dto.fileName).SetColumns(a => new Grp_Customers()
  10568. {
  10569. Attachment = "",
  10570. }).ExecuteCommandAsync();
  10571. if (result != 0)
  10572. {
  10573. return Ok(JsonView(true, "成功!"));
  10574. }
  10575. else
  10576. {
  10577. return Ok(JsonView(false, "失败!"));
  10578. }
  10579. }
  10580. }
  10581. catch (Exception ex)
  10582. {
  10583. return Ok(JsonView(false, "程序错误!"));
  10584. throw;
  10585. }
  10586. }
  10587. /// <summary>
  10588. /// 保险费用操作(删除)
  10589. /// </summary>
  10590. /// <param name="dto"></param>
  10591. /// <returns></returns>
  10592. [HttpPost]
  10593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10594. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10595. {
  10596. try
  10597. {
  10598. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10599. if (!res)
  10600. {
  10601. return Ok(JsonView(false, "删除失败"));
  10602. }
  10603. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10604. {
  10605. IsDel = 1,
  10606. DeleteUserId = dto.DeleteUserId,
  10607. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10608. }).ExecuteCommandAsync();
  10609. return Ok(JsonView(true, "删除成功!"));
  10610. }
  10611. catch (Exception ex)
  10612. {
  10613. return Ok(JsonView(false, "程序错误!"));
  10614. throw;
  10615. }
  10616. }
  10617. #endregion
  10618. #region 接团客户名单 PageId 104
  10619. /// <summary>
  10620. /// 接团客户名单
  10621. /// 迁移数据(慎用!)
  10622. /// </summary>
  10623. /// <param name="dto"></param>
  10624. /// <returns></returns>
  10625. [HttpPost]
  10626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10627. public async Task<IActionResult> PostTourClientListChange()
  10628. {
  10629. try
  10630. {
  10631. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10632. //var groupClinetData1
  10633. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10634. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10635. int updateCount = 0;
  10636. if (oldOAClientList.Count > 0)
  10637. {
  10638. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10639. _sqlSugar.BeginTran();
  10640. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10641. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10642. foreach (var item in oldOAClientList)
  10643. {
  10644. int comId = 0;
  10645. string format = "yyyy-MM-dd HH:mm:ss";
  10646. string data11 = "1990-01-01 00:00";
  10647. var data1 = IsValidDate(item.OPdate, format);
  10648. if (data1) data11 = item.OPdate;
  10649. //客户公司验证
  10650. if (!string.IsNullOrEmpty(item.Company))
  10651. {
  10652. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10653. if (clientComInfo == null) // add
  10654. {
  10655. var addInfo = new Crm_CustomerCompany()
  10656. {
  10657. CompanyAbbreviation = "",
  10658. CompanyFullName = item.Company,
  10659. Address = "",
  10660. PostCodes = "",
  10661. LastedOpUserId = item.OPer,
  10662. LastedOpDt = Convert.ToDateTime(data11),
  10663. CreateUserId = item.OPer,
  10664. CreateTime = Convert.ToDateTime(data11),
  10665. IsDel = 0
  10666. };
  10667. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10668. if (comId1 > 0) comId = comId1;
  10669. }
  10670. else comId = clientComInfo.Id;
  10671. }
  10672. //客户人员验证
  10673. int clientId = 0;
  10674. string name = item.LastName + item.Name;
  10675. if (!string.IsNullOrEmpty(name))
  10676. {
  10677. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10678. if (clientInfo == null)
  10679. {
  10680. DateTime? dateTime = null;
  10681. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10682. if (isDt) dateTime = birthDayDt;
  10683. var addInfo1 = new Crm_DeleClient()
  10684. {
  10685. CrmCompanyId = comId,
  10686. DiId = -1,
  10687. LastName = item.LastName,
  10688. FirstName = item.Name,
  10689. OldName = "",
  10690. Pinyin = item.Pinyin,
  10691. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10692. Marriage = 0,
  10693. Phone = item.Phone,
  10694. Job = item.Job,
  10695. BirthDay = dateTime
  10696. };
  10697. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10698. if (clientId1 > 0) clientId = clientId1;
  10699. }
  10700. else clientId = clientInfo.Id;
  10701. }
  10702. if (clientId < 1)
  10703. {
  10704. continue;
  10705. }
  10706. int airType = 0;
  10707. if (item.AirType == "超经舱") airType = 459;
  10708. else if (item.AirType == "公务舱") airType = 458;
  10709. else if (item.AirType == "经济舱") airType = 460;
  10710. else if (item.AirType == "其他") airType = 565;
  10711. else if (item.AirType == "头等舱") airType = 457;
  10712. var _TourClientListEntity = new Grp_TourClientList()
  10713. {
  10714. DiId = item.Diid,
  10715. ClientId = clientId,
  10716. CreateUserId = item.OPer,
  10717. CreateTime = Convert.ToDateTime(data11),
  10718. Remark = item.Remark,
  10719. IsDel = item.Isdel,
  10720. ShippingSpaceTypeId = airType,
  10721. ShippingSpaceSpecialNeeds = item.AirRemark,
  10722. HotelSpecialNeeds = item.RoomType
  10723. };
  10724. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10725. if (_TourClientList > 0)
  10726. {
  10727. updateCount++;
  10728. }
  10729. }
  10730. _sqlSugar.CommitTran();
  10731. }
  10732. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10733. }
  10734. catch (Exception ex)
  10735. {
  10736. _sqlSugar.RollbackTran();
  10737. return Ok(JsonView(false, ex.Message));
  10738. }
  10739. return Ok(JsonView(true));
  10740. }
  10741. private bool IsValidDate(string dateString, string format)
  10742. {
  10743. DateTime dateValue;
  10744. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10745. return valid;
  10746. }
  10747. /// <summary>
  10748. /// 接团客户名单
  10749. /// 根据团组Id查询List
  10750. /// </summary>
  10751. /// <param name="dto"></param>
  10752. /// <returns></returns>
  10753. [HttpPost]
  10754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10755. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10756. {
  10757. #region 参数验证
  10758. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10759. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10760. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10761. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10762. #region 页面操作权限验证
  10763. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10764. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10765. #endregion
  10766. #endregion
  10767. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10768. if (viewData.Code != 0)
  10769. {
  10770. return Ok(JsonView(false, viewData.Msg));
  10771. }
  10772. return Ok(JsonView(viewData.Data));
  10773. }
  10774. /// <summary>
  10775. /// 接团客户名单
  10776. /// 基础数据 Init
  10777. /// </summary>
  10778. /// <param name="_dto"></param>
  10779. /// <returns></returns>
  10780. [HttpPost]
  10781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10782. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10783. {
  10784. #region 参数验证
  10785. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10786. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10787. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10788. #region 页面操作权限验证
  10789. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10790. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10791. #endregion
  10792. #endregion
  10793. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10794. if (viewData.Code != 0)
  10795. {
  10796. return Ok(JsonView(false, viewData.Msg));
  10797. }
  10798. return Ok(JsonView(viewData.Data));
  10799. }
  10800. /// <summary>
  10801. /// 接团客户名单
  10802. /// 根据 Id查询 Details
  10803. /// </summary>
  10804. /// <param name="_dto"></param>
  10805. /// <returns></returns>
  10806. [HttpPost]
  10807. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10808. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10809. {
  10810. #region 参数验证
  10811. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10812. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10813. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10814. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10815. #region 页面操作权限验证
  10816. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10817. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10818. #endregion
  10819. #endregion
  10820. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10821. if (viewData.Code != 0)
  10822. {
  10823. return Ok(JsonView(false, viewData.Msg));
  10824. }
  10825. return Ok(JsonView(viewData.Data));
  10826. }
  10827. /// <summary>
  10828. /// 接团客户名单
  10829. /// Add Or Edit
  10830. /// </summary>
  10831. /// <param name="_dto"></param>
  10832. /// <returns></returns>
  10833. [HttpPost]
  10834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10835. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10836. {
  10837. #region 参数验证
  10838. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10839. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10840. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10841. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10842. #region 页面操作权限验证
  10843. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10844. if (_dto.Id == 0) //添加
  10845. {
  10846. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10847. }
  10848. else if (_dto.Id >= 0) //修改
  10849. {
  10850. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10851. }
  10852. #endregion
  10853. #endregion
  10854. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10855. if (viewData.Code != 0)
  10856. {
  10857. return Ok(JsonView(false, viewData.Msg));
  10858. }
  10859. return Ok(JsonView(true));
  10860. }
  10861. /// <summary>
  10862. /// 接团客户名单
  10863. /// AddMultiple(添加多个)
  10864. /// </summary>
  10865. /// <param name="_dto"></param>
  10866. /// <returns></returns>
  10867. [HttpPost]
  10868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10869. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10870. {
  10871. #region 参数验证
  10872. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10873. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10874. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10875. #region 页面操作权限验证
  10876. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10877. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10878. #endregion
  10879. #endregion
  10880. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10881. if (viewData.Code != 0)
  10882. {
  10883. return Ok(JsonView(false, viewData.Msg));
  10884. }
  10885. return Ok(JsonView(true));
  10886. }
  10887. /// <summary>
  10888. /// 接团客户名单
  10889. /// Del
  10890. /// </summary>
  10891. /// <param name="_dto"></param>
  10892. /// <returns></returns>
  10893. [HttpPost]
  10894. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10895. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10896. {
  10897. #region 参数验证
  10898. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10899. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10900. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10901. #region 页面操作权限验证
  10902. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10903. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10904. #endregion
  10905. #endregion
  10906. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10907. if (viewData.Code != 0)
  10908. {
  10909. return Ok(JsonView(false, viewData.Msg));
  10910. }
  10911. return Ok(JsonView(true));
  10912. }
  10913. /// <summary>
  10914. /// 接团客户名单
  10915. /// 文件下载 客户名单
  10916. /// </summary>
  10917. /// <param name="_dto"></param>
  10918. /// <returns></returns>
  10919. [HttpPost]
  10920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10921. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10922. {
  10923. #region 参数验证
  10924. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10925. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10926. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10927. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10928. #region 页面操作权限验证
  10929. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10930. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10931. #endregion
  10932. #endregion
  10933. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10934. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10935. From Grp_TourClientList tcl
  10936. Left Join
  10937. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10938. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10939. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10940. From Crm_DeleClient dc
  10941. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10942. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10943. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10944. Where dc.IsDel = 0) temp
  10945. On temp.DcId =tcl.ClientId
  10946. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10947. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10948. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10949. //载入模板
  10950. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10951. if (_dto.Language == 1)
  10952. {
  10953. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10954. }
  10955. //载入模板
  10956. var doc = new Document(tempPath);
  10957. DocumentBuilder builder = new DocumentBuilder(doc);
  10958. //获取word里所有表格
  10959. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10960. //获取所填表格的序数
  10961. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10962. var rowStart = tableOne.Rows[0]; //获取第1行
  10963. if (_dto.Language == 0)
  10964. {
  10965. //循环赋值
  10966. for (int i = 0; i < DcList.Count; i++)
  10967. {
  10968. builder.MoveToCell(0, i + 1, 0, 0);
  10969. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10970. builder.MoveToCell(0, i + 1, 1, 0);
  10971. int sex = DcList[i].Sex;
  10972. string sexStr = string.Empty;
  10973. if (sex == 0) sexStr = "男";
  10974. else if (sex == 1) sexStr = "女";
  10975. else sexStr = "未设置";
  10976. builder.Write(sexStr);
  10977. builder.MoveToCell(0, i + 1, 2, 0);
  10978. string birthDay = DcList[i].BirthDay;
  10979. string birthDayStr = string.Empty;
  10980. if (!string.IsNullOrEmpty(birthDay))
  10981. {
  10982. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10983. }
  10984. builder.Write(birthDayStr);
  10985. builder.MoveToCell(0, i + 1, 3, 0);
  10986. string company = "";
  10987. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10988. {
  10989. company = DcList[i].CompanyFullName.ToString();
  10990. }
  10991. builder.Write(company);
  10992. builder.MoveToCell(0, i + 1, 4, 0);
  10993. builder.Write(DcList[i].Job);
  10994. }
  10995. }
  10996. else if (_dto.Language == 1)
  10997. {
  10998. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10999. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  11000. List<string> transArrayStr = new List<string>();
  11001. string transStrRes1 = "";
  11002. for (int i = 0; i < DcList.Count; i++)
  11003. {
  11004. var dc = DcList[i];
  11005. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  11006. if (dc.Job.Equals("暂无")) dc.Job = "-";
  11007. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  11008. if (DcList.Count - 1 == i) transStrRes1 += str1;
  11009. else transStrRes1 += $"{str1}|";
  11010. }
  11011. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  11012. string transStrRes = "";
  11013. if (transStrRes1.Length > 0 )
  11014. {
  11015. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  11016. }
  11017. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  11018. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  11019. //List<string> transArray = new List<string> { };
  11020. List<TranslateInfo> transArray = new List<TranslateInfo>();
  11021. if (transStrRes.Contains("|"))
  11022. {
  11023. string[] transArray1 = transStrRes.Split('|');
  11024. if (transArray1.Length > 0)
  11025. {
  11026. foreach (var item in transArray1)
  11027. {
  11028. if (item.Contains("&"))
  11029. {
  11030. string[] transArray2 = item.Split('&');
  11031. int index = 0;
  11032. string companyName = "", job = "";
  11033. if (transArray2.Length > 0)
  11034. {
  11035. bool success = int.TryParse(transArray2[0].Trim(), out index);
  11036. if (1 < transArray2.Length) companyName = transArray2[1];
  11037. if (2 < transArray2.Length) job = transArray2[2];
  11038. }
  11039. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  11040. }
  11041. }
  11042. }
  11043. }
  11044. //循环赋值
  11045. for (int i = 0; i < DcList.Count; i++)
  11046. {
  11047. string PYName = "";
  11048. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  11049. {
  11050. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  11051. string PY_First = DcList[i].Pinyin.Split('/')[1];
  11052. PYName = PY_First + " " + PY_Last;
  11053. }
  11054. else
  11055. {
  11056. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  11057. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  11058. PYName = PY_First + " " + PY_Last;
  11059. }
  11060. builder.MoveToCell(0, i + 1, 0, 0);
  11061. builder.Write(PYName);
  11062. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  11063. builder.MoveToCell(0, i + 1, 1, 0);
  11064. builder.Write(sex);
  11065. DateTime birthDt;
  11066. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  11067. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  11068. builder.MoveToCell(0, i + 1, 2, 0);
  11069. builder.Write(birthday);
  11070. string company = string.Empty,job = string.Empty;
  11071. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  11072. if (dcTransInfo != null)
  11073. {
  11074. company = dcTransInfo.CompanyName;
  11075. job = dcTransInfo.Job;
  11076. }
  11077. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  11078. {
  11079. //查询对照表
  11080. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  11081. if (tempCec != null)
  11082. {
  11083. company = tempCec.enName;
  11084. }
  11085. //翻译
  11086. else
  11087. {
  11088. }
  11089. }
  11090. builder.MoveToCell(0, i + 1, 3, 0);
  11091. builder.Write(company);
  11092. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  11093. {
  11094. //查询对照表
  11095. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  11096. if (tempPec != null)
  11097. {
  11098. job = tempPec.enName;
  11099. }
  11100. //翻译
  11101. else
  11102. {
  11103. }
  11104. }
  11105. builder.MoveToCell(0, i + 1, 4, 0);
  11106. builder.Write(job);
  11107. }
  11108. }
  11109. //删除多余行
  11110. while (tableOne.Rows.Count > DcList.Count + 1)
  11111. {
  11112. tableOne.Rows.RemoveAt(DcList.Count + 1);
  11113. }
  11114. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  11115. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  11116. doc.Save(fileDir);
  11117. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  11118. return Ok(JsonView(true, "操作成功!", Url));
  11119. }
  11120. private class TranslateInfo
  11121. {
  11122. public int Index { get; set; }
  11123. public string CompanyName { get; set; }
  11124. public string Job { get; set; }
  11125. }
  11126. #endregion
  11127. #region 团组倒推表
  11128. /// <summary>
  11129. /// 倒推表基础数据
  11130. /// Init
  11131. /// </summary>
  11132. /// <param name="dto"></param>
  11133. /// <returns></returns>
  11134. [HttpPost]
  11135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11136. public async Task<IActionResult> PostInvertedListInit()
  11137. {
  11138. var viewData = await _invertedListRep._Init();
  11139. if (viewData.Code != 0)
  11140. {
  11141. return Ok(JsonView(false, viewData.Msg));
  11142. }
  11143. return Ok(JsonView(viewData.Data));
  11144. }
  11145. /// <summary>
  11146. /// 倒推表
  11147. /// Info
  11148. /// </summary>
  11149. /// <param name="dto"></param>
  11150. /// <returns></returns>
  11151. [HttpPost]
  11152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11153. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  11154. {
  11155. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  11156. if (viewData.Code != 0)
  11157. {
  11158. return Ok(JsonView(false, viewData.Msg));
  11159. }
  11160. return Ok(JsonView(viewData.Data));
  11161. }
  11162. /// <summary>
  11163. /// 倒推表
  11164. /// Create
  11165. /// </summary>
  11166. /// <param name="dto"></param>
  11167. /// <returns></returns>
  11168. [HttpPost]
  11169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11170. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11171. {
  11172. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11173. if (viewData.Code != 0)
  11174. {
  11175. return Ok(JsonView(false, viewData.Msg));
  11176. }
  11177. return Ok(JsonView(viewData.Data));
  11178. }
  11179. /// <summary>
  11180. /// 倒推表
  11181. /// Update
  11182. /// </summary>
  11183. /// <param name="dto"></param>
  11184. /// <returns></returns>
  11185. [HttpPost]
  11186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11187. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11188. {
  11189. var viewData = await _invertedListRep._Update(dto);
  11190. if (viewData.Code != 0)
  11191. {
  11192. return Ok(JsonView(false, viewData.Msg));
  11193. }
  11194. return Ok(JsonView(viewData.Data));
  11195. }
  11196. /// <summary>
  11197. /// 倒推表
  11198. /// File Download
  11199. /// </summary>
  11200. /// <param name="dto"></param>
  11201. /// <returns></returns>
  11202. [HttpPost]
  11203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11204. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11205. {
  11206. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11207. if (info2.Code != 0)
  11208. {
  11209. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11210. }
  11211. var info1 = info2.Data as InvertedListInfoView;
  11212. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11213. string teamName = "";
  11214. if (info != null) teamName = info.TeamName;
  11215. //载入模板
  11216. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11217. DocumentBuilder builder = new DocumentBuilder(doc);
  11218. //利用键值对存放数据
  11219. Dictionary<string, string> dic = new Dictionary<string, string>();
  11220. dic.Add("TeamName", teamName);
  11221. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11222. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11223. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11224. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11225. dic.Add("SQRemark", info1.ApprovalRemark);
  11226. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11227. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11228. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11229. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11230. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11231. dic.Add("QZRemark", info1.VisaInformationRemark);
  11232. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11233. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11234. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11235. dic.Add("CQRemark", info1.IssueVisaRemark);
  11236. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11237. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11238. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11239. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11240. #region 填充word模板书签内容
  11241. foreach (var key in dic.Keys)
  11242. {
  11243. builder.MoveToBookmark(key);
  11244. builder.Write(dic[key]);
  11245. }
  11246. #endregion
  11247. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11248. string fileName = $"{teamName}团出行准备流程表.doc";
  11249. string filePath = fileDir + $@"InvertedList/{fileName}";
  11250. doc.Save(filePath);
  11251. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11252. return Ok(JsonView(true, "操作成功!", Url));
  11253. }
  11254. #endregion
  11255. #region 三公签证费用(签证费、代办费)
  11256. /// <summary>
  11257. /// 三公签证费用(签证费、代办费)
  11258. /// List
  11259. /// </summary>
  11260. /// <returns></returns>
  11261. [HttpPost]
  11262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11263. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11264. {
  11265. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11266. if (_view.Code != 0)
  11267. {
  11268. return Ok(JsonView(false, _view.Msg));
  11269. }
  11270. return Ok(JsonView(true, "操作成功!", _view.Data));
  11271. }
  11272. /// <summary>
  11273. /// 三公签证费用(签证费、代办费)
  11274. /// Add Or Update
  11275. /// </summary>
  11276. /// <returns></returns>
  11277. [HttpPost]
  11278. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11279. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11280. {
  11281. var _view = await _visaFeeInfoRep._Update(_dto);
  11282. if (_view.Code != 0)
  11283. {
  11284. return Ok(JsonView(false, _view.Msg));
  11285. }
  11286. return Ok(JsonView(true, _view.Msg));
  11287. }
  11288. #endregion
  11289. #region 酒店询价
  11290. /// <summary>
  11291. /// 酒店询价
  11292. /// Init
  11293. /// </summary>
  11294. /// <param name="dto"></param>
  11295. /// <returns></returns>
  11296. [HttpPost]
  11297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11298. public async Task<IActionResult> PostHotelInquiryInit()
  11299. {
  11300. var res = await _hotelInquiryRep._Init();
  11301. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11302. return Ok(JsonView(true, res.Msg, res.Data));
  11303. }
  11304. /// <summary>
  11305. /// 酒店询价
  11306. /// page Item
  11307. /// </summary>
  11308. /// <param name="_dto"></param>
  11309. /// <returns></returns>
  11310. [HttpPost]
  11311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11312. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11313. {
  11314. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11315. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11316. var view = res.Data as PageDataViewBase;
  11317. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11318. }
  11319. /// <summary>
  11320. /// 酒店询价
  11321. /// info
  11322. /// </summary>
  11323. /// <param name="_dto"></param>
  11324. /// <returns></returns>
  11325. [HttpPost]
  11326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11327. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11328. {
  11329. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11330. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11331. return Ok(JsonView(true, res.Msg, res.Data));
  11332. }
  11333. /// <summary>
  11334. /// 酒店询价
  11335. /// Add Or Edit
  11336. /// </summary>
  11337. /// <param name="_dto"></param>
  11338. /// <returns></returns>
  11339. [HttpPost]
  11340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11341. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11342. {
  11343. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11344. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11345. return Ok(JsonView(true, res.Msg, res.Data));
  11346. }
  11347. /// <summary>
  11348. /// 酒店询价
  11349. /// Del
  11350. /// </summary>
  11351. /// <param name="_dto"></param>
  11352. /// <returns></returns>
  11353. [HttpPost]
  11354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11355. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11356. {
  11357. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11358. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11359. return Ok(JsonView(true, res.Msg, res.Data));
  11360. }
  11361. #endregion
  11362. #region 下载匹配op行程单
  11363. /// <summary>
  11364. /// 匹配op行程单
  11365. /// Init
  11366. /// </summary>
  11367. /// <param name="dto">团组列表请求dto</param>
  11368. /// <returns></returns>
  11369. [HttpPost]
  11370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11371. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11372. {
  11373. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11374. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11375. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11376. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11377. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11378. .Where(it => it.IsDel == 0)
  11379. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11380. .OrderByDescending(it => it.CreateUserId)
  11381. .ToList();
  11382. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11383. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11384. var diids = groupInfos.Select(it => it.Id).ToList();
  11385. List<string> countrys = new List<string>();
  11386. foreach (var item in country)
  11387. {
  11388. var data = _groupRepository.FormartTeamName(item);
  11389. var dataArray = _groupRepository.GroupSplitCountry(data);
  11390. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11391. }
  11392. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11393. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11394. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11395. foreach (var item in areaItem)
  11396. {
  11397. string areaStr = item.Value;
  11398. if (!string.IsNullOrEmpty(areaStr))
  11399. {
  11400. string[] str1 = areaStr.Split("-");
  11401. if (str1.Length > 0)
  11402. {
  11403. areaArray.AddRange(str1);
  11404. }
  11405. }
  11406. }
  11407. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11408. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11409. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11410. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11411. .ToList();
  11412. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11413. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11414. .Where(it => countriesIds.Contains(it.Id))
  11415. .Select(it => new { it.Id, Name = it.Name_CN })
  11416. .ToList();
  11417. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11418. .Select(it => it.TeamName).ToList();
  11419. stopwatch.Stop();
  11420. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11421. }
  11422. ///// <summary>
  11423. ///// 匹配op行程单
  11424. ///// Init 查询区域数据
  11425. ///// </summary>
  11426. ///// <param name="dto">团组列表请求dto</param>
  11427. ///// <returns></returns>
  11428. //[HttpPost]
  11429. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11430. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11431. //{
  11432. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11433. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11434. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11435. // if (string.IsNullOrEmpty(countriesDataStr))
  11436. // {
  11437. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11438. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11439. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11440. // }
  11441. // else
  11442. // {
  11443. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11444. // }
  11445. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11446. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11447. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11448. // List<dynamic> childList = new List<dynamic>();
  11449. // int parentId = dto.CountriesId;
  11450. // if (provinceData.Count > 1)
  11451. // {
  11452. // foreach (var item1 in provinceData)
  11453. // {
  11454. // List<dynamic> childList1 = new List<dynamic>();
  11455. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11456. // foreach (var item2 in citiesData1)
  11457. // {
  11458. // List<dynamic> childList2 = new List<dynamic>();
  11459. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11460. // foreach (var item3 in countiesData1)
  11461. // {
  11462. // childList2.Add(new
  11463. // {
  11464. // id = item3.Id,
  11465. // parentId = item2.Id,
  11466. // level = "district",
  11467. // name = item3.Name_CN,
  11468. // });
  11469. // }
  11470. // childList1.Add(new
  11471. // {
  11472. // id = item2.Id,
  11473. // parentId = item1.Id,
  11474. // level = "city",
  11475. // name = item2.Name_CN,
  11476. // childList = childList2
  11477. // });
  11478. // }
  11479. // childList.Add(new
  11480. // {
  11481. // id = item1.Id,
  11482. // parentId = parentId,
  11483. // level = "province",
  11484. // name = item1.Name_CN,
  11485. // childList = childList1
  11486. // });
  11487. // }
  11488. // //城市
  11489. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11490. // foreach (var item2 in citiesData2)
  11491. // {
  11492. // List<dynamic> childList22 = new List<dynamic>();
  11493. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11494. // foreach (var item3 in countiesData1)
  11495. // {
  11496. // childList22.Add(new
  11497. // {
  11498. // id = item3.Id,
  11499. // parentId = item2.Id,
  11500. // level = "district",
  11501. // name = item3.Name_CN,
  11502. // });
  11503. // }
  11504. // childList.Add(new
  11505. // {
  11506. // id = item2.Id,
  11507. // parentId = parentId,
  11508. // level = "city",
  11509. // name = item2.Name_CN,
  11510. // childList = childList22
  11511. // });
  11512. // }
  11513. // }
  11514. // else
  11515. // {
  11516. // foreach (var item2 in citiesData)
  11517. // {
  11518. // string cname = item2.Name_CN;
  11519. // List<dynamic> childList1 = new List<dynamic>();
  11520. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11521. // foreach (var item3 in countiesData1)
  11522. // {
  11523. // childList1.Add(new
  11524. // {
  11525. // Id = item3.Id,
  11526. // parentId = item2.Id,
  11527. // level = "district",
  11528. // name = item3.Name_CN
  11529. // });
  11530. // }
  11531. // childList.Add(new
  11532. // {
  11533. // id = item2.Id,
  11534. // parentId = parentId,
  11535. // level = "city",
  11536. // name = item2.Name_CN,
  11537. // childList = childList1
  11538. // });
  11539. // }
  11540. // }
  11541. // stopwatch.Stop();
  11542. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11543. //}
  11544. /// <summary>
  11545. /// 匹配op行程单
  11546. /// 接团信息列表 Page
  11547. /// </summary>
  11548. /// <param name="dto">团组列表请求dto</param>
  11549. /// <returns></returns>
  11550. [HttpPost]
  11551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11552. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11553. {
  11554. var swatch = new Stopwatch();
  11555. swatch.Start();
  11556. #region 参数验证
  11557. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11558. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11559. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11560. #region 页面操作权限验证
  11561. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11562. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11563. #endregion
  11564. #endregion
  11565. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11566. {
  11567. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11568. string sqlWhere = "";
  11569. if (!string.IsNullOrEmpty(dto.Country))
  11570. {
  11571. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11572. }
  11573. if (!string.IsNullOrEmpty(dto.Area))
  11574. {
  11575. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11576. }
  11577. if (!string.IsNullOrEmpty(dto.TeamName))
  11578. {
  11579. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11580. }
  11581. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11582. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11583. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11584. swatch.Stop();
  11585. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11586. }
  11587. else
  11588. {
  11589. return Ok(JsonView(false, "查询失败"));
  11590. }
  11591. }
  11592. /// <summary>
  11593. /// 匹配op行程单
  11594. /// 行程单下载
  11595. /// </summary>
  11596. /// <param name="dto">团组列表请求dto</param>
  11597. /// <returns></returns>
  11598. [HttpPost]
  11599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11600. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11601. {
  11602. #region 参数验证
  11603. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11604. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11605. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11606. #region 页面操作权限验证
  11607. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11608. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11609. #endregion
  11610. #endregion
  11611. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11612. {
  11613. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11614. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11615. }
  11616. else
  11617. {
  11618. return Ok(JsonView(false, "下载失败!"));
  11619. }
  11620. }
  11621. #endregion
  11622. #region 国家信息 数据 注释
  11623. //[HttpPost]
  11624. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11625. //{
  11626. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11627. // foreach (var item in dto)
  11628. // {
  11629. // infos.Add(new Grp_GroupsTaskAssignment()
  11630. // {
  11631. // DIId = item,
  11632. // CTId = 82,
  11633. // UId = 248,
  11634. // IsEnable = 1,
  11635. // CreateUserId = 233,
  11636. // CreateTime = DateTime.Now,
  11637. // IsDel = 0
  11638. // });
  11639. // infos.Add(new Grp_GroupsTaskAssignment()
  11640. // {
  11641. // DIId = item,
  11642. // CTId = 82,
  11643. // UId = 286,
  11644. // IsEnable = 1,
  11645. // CreateUserId = 233,
  11646. // CreateTime = DateTime.Now,
  11647. // IsDel = 0
  11648. // });
  11649. // }
  11650. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11651. // return Ok("操作成功");
  11652. //}
  11653. //public class paramJsonDto
  11654. //{
  11655. // public List<CountriesInfo> str { get; set; }
  11656. //}
  11657. //[HttpPost]
  11658. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11659. //{
  11660. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11661. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11662. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11663. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11664. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11665. // _sqlSugar.BeginTran();
  11666. // int countitiesIndex = 0;
  11667. // foreach (var item in dto.str)
  11668. // {
  11669. // dynamic data = item.c;
  11670. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11671. // if (data != null)
  11672. // {
  11673. // countitiesIndex++;
  11674. // foreach (var item1 in data)
  11675. // {
  11676. // string cnname = item1.cn;
  11677. // string enname = item1.en;
  11678. // Sys_Cities provinceInfo = new Sys_Cities()
  11679. // {
  11680. // CountriesId = countriesId,
  11681. // Name_CN = cnname,
  11682. // Name_EN = enname,
  11683. // ParentId = 0,
  11684. // IsCapital = 1,
  11685. // CreateUserId = 208,
  11686. // CreateTime = DateTime.Now,
  11687. // IsDel = 0
  11688. // };
  11689. // if (item1.lv == "province") //省份
  11690. // {
  11691. // provinceInfo.Level = 1;
  11692. // int provinceId = 0;
  11693. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11694. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11695. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11696. // var data1 = item1.c;
  11697. // foreach (var item2 in data1)
  11698. // {
  11699. // if (item2.lv == "city")
  11700. // {
  11701. // string citycnname = item2.cn;
  11702. // string cityenname = item2.en;
  11703. // Sys_Cities cityInfo = new Sys_Cities()
  11704. // {
  11705. // CountriesId = countriesId,
  11706. // ParentId = provinceId,
  11707. // Level = 2,
  11708. // Name_CN = citycnname,
  11709. // Name_EN = cityenname,
  11710. // IsCapital = 1,
  11711. // CreateUserId = 208,
  11712. // CreateTime = DateTime.Now,
  11713. // IsDel = 0
  11714. // };
  11715. // if (item2.c != null)
  11716. // {
  11717. // int cityId = 0;
  11718. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11719. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11720. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11721. // foreach (var item3 in item2.c)
  11722. // {
  11723. // if (item3.lv == "district")
  11724. // {
  11725. // var districtInfo = new Sys_Cities()
  11726. // {
  11727. // CountriesId = countriesId,
  11728. // Name_CN = item3.cn,
  11729. // Name_EN = item3.en,
  11730. // Level = 3,
  11731. // ParentId = cityId,
  11732. // IsCapital = 1,
  11733. // CreateUserId = 208,
  11734. // CreateTime = DateTime.Now,
  11735. // IsDel = 0
  11736. // };
  11737. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11738. // //{
  11739. // districts.Add(districtInfo);
  11740. // //}
  11741. // }
  11742. // }
  11743. // }
  11744. // else
  11745. // {
  11746. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11747. // //{
  11748. // cities.Add(cityInfo);
  11749. // //}
  11750. // }
  11751. // }
  11752. // }
  11753. // }
  11754. // else if (item1.lv == "city")//城市
  11755. // {
  11756. // provinceInfo.Level = 2;
  11757. // if (item1.c != null)
  11758. // {
  11759. // int cityId = 0;
  11760. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11761. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11762. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11763. // foreach (var item3 in item1.c)
  11764. // {
  11765. // if (item3.lv == "district")
  11766. // {
  11767. // var districtInfo = new Sys_Cities()
  11768. // {
  11769. // CountriesId = countriesId,
  11770. // Name_CN = item3.cn,
  11771. // Name_EN = item3.en,
  11772. // Level = 3,
  11773. // ParentId = cityId,
  11774. // IsCapital = 1,
  11775. // CreateUserId = 208,
  11776. // CreateTime = DateTime.Now,
  11777. // IsDel = 0
  11778. // };
  11779. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11780. // //{
  11781. // districts.Add(districtInfo);
  11782. // //}
  11783. // }
  11784. // }
  11785. // }
  11786. // else
  11787. // {
  11788. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11789. // //{
  11790. // cities.Add(provinceInfo);
  11791. // //}
  11792. // }
  11793. // }
  11794. // }
  11795. // }
  11796. // }
  11797. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11798. // cities = cities.Distinct().ToList();
  11799. // districts = districts.Distinct().ToList();
  11800. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11801. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11802. // cities.AddRange(districts);
  11803. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11804. // //_sqlSugar.RollbackTran();
  11805. // _sqlSugar.CommitTran();
  11806. // return Ok(JsonView(false, "操作成功!"));
  11807. //}
  11808. //[HttpPost]
  11809. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11810. //{
  11811. // List<CountitiesInfo> infos = dto.MyProperty;
  11812. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11813. // _sqlSugar.BeginTran();
  11814. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11815. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11816. // foreach (var item in infos)
  11817. // {
  11818. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11819. // if (countryInfo != null)
  11820. // {
  11821. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11822. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11823. // if (cityInfo1 != null)
  11824. // {
  11825. // cityInfo1.IsCapital = 0;
  11826. // cityInfos.Add(cityInfo1);
  11827. // }
  11828. // }
  11829. // }
  11830. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11831. // .UpdateColumns(it => it.IsCapital)
  11832. // .WhereColumns(it => it.Id)
  11833. // .ExecuteCommand();
  11834. // //_sqlSugar.RollbackTran();
  11835. // _sqlSugar.CommitTran();
  11836. // return Ok(JsonView(false, "操作成功!"));
  11837. //}
  11838. //public class CounrtiesDto
  11839. //{
  11840. // public List<CountitiesInfo> MyProperty { get; set; }
  11841. //}
  11842. //public class CountitiesInfo
  11843. //{
  11844. // /// <summary>
  11845. // /// 圣约翰
  11846. // /// </summary>
  11847. // public string capital_name_chinese { get; set; }
  11848. // /// <summary>
  11849. // ///
  11850. // /// </summary>
  11851. // public string capital_name { get; set; }
  11852. // /// <summary>
  11853. // ///
  11854. // /// </summary>
  11855. // public string country_type { get; set; }
  11856. // /// <summary>
  11857. // /// 安提瓜和巴布达
  11858. // /// </summary>
  11859. // public string country_name_chinese { get; set; }
  11860. // /// <summary>
  11861. // /// 安提瓜和巴布达
  11862. // /// </summary>
  11863. // public string country_name_chinese_short { get; set; }
  11864. // /// <summary>
  11865. // /// 安提瓜和巴布达
  11866. // /// </summary>
  11867. // public string country_name_chinese_UN { get; set; }
  11868. // /// <summary>
  11869. // ///
  11870. // /// </summary>
  11871. // public string country_name_english_abbreviation { get; set; }
  11872. // /// <summary>
  11873. // ///
  11874. // /// </summary>
  11875. // public string country_name_english_formal { get; set; }
  11876. // /// <summary>
  11877. // ///
  11878. // /// </summary>
  11879. // public string country_name_english_UN { get; set; }
  11880. // /// <summary>
  11881. // ///
  11882. // /// </summary>
  11883. // public string continent_name { get; set; }
  11884. // /// <summary>
  11885. // ///
  11886. // /// </summary>
  11887. // public string subregion_name { get; set; }
  11888. // /// <summary>
  11889. // ///
  11890. // /// </summary>
  11891. // public string country_code2 { get; set; }
  11892. // /// <summary>
  11893. // ///
  11894. // /// </summary>
  11895. // public string country_code3 { get; set; }
  11896. // /// <summary>
  11897. // ///
  11898. // /// </summary>
  11899. // public string phone_code { get; set; }
  11900. //}
  11901. //public class CountriesInfo : BasicInfo
  11902. //{
  11903. // public List<CitiesInfo> c { get; set; }
  11904. //}
  11905. //public class CitiesInfo : BasicInfo
  11906. //{
  11907. // public List<AreaInfo> c { get; set; }
  11908. //}
  11909. //public class AreaInfo : BasicInfo
  11910. //{
  11911. // public List<AreaInfo> c { get; set; }
  11912. //}
  11913. //public class BasicInfo
  11914. //{
  11915. // public string code { get; set; }
  11916. // public string cn { get; set; }
  11917. // public string lv { get; set; }
  11918. // public string en { get; set; }
  11919. //}
  11920. #endregion
  11921. #region 查看邀请方
  11922. /// <summary>
  11923. /// 查看邀请方
  11924. /// 邀请方信息 Init
  11925. /// </summary>
  11926. /// <param name="dto"></param>
  11927. /// <returns></returns>
  11928. [HttpPost]
  11929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11930. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11931. {
  11932. string sqlWhere = string.Empty;
  11933. if (!string.IsNullOrEmpty(dto.Search))
  11934. {
  11935. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11936. }
  11937. string sql = string.Format($@"Select
  11938. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11939. Id,
  11940. UnitName
  11941. From Res_InvitationOfficialActivityData
  11942. Where IsDel = 0
  11943. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11944. RefAsync<int> total = 0;
  11945. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11946. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11947. }
  11948. /// <summary>
  11949. /// 查看邀请方
  11950. /// 国家信息 Init
  11951. /// </summary>
  11952. /// <param name="dto"></param>
  11953. /// <returns></returns>
  11954. [HttpPost]
  11955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11956. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11957. {
  11958. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11959. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11960. var diids = groupInfos.Select(it => it.Id).ToList();
  11961. List<string> countrys = new List<string>();
  11962. foreach (var item in country)
  11963. {
  11964. var data = _groupRepository.FormartTeamName(item);
  11965. var dataArray = _groupRepository.GroupSplitCountry(data);
  11966. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11967. }
  11968. countrys = countrys.Distinct().ToList();
  11969. for (int i = 0; i < countrys.Count; i++)
  11970. {
  11971. string item = countrys[i];
  11972. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11973. {
  11974. countrys.Remove(item);
  11975. i--;
  11976. }
  11977. }
  11978. RefAsync<int> total = 0;
  11979. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11980. .Where(it => countrys.Contains(it.Name_CN))
  11981. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11982. .Select(it => new { id = it.Id, name = it.Name_CN })
  11983. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11984. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11985. }
  11986. /// <summary>
  11987. /// 查看邀请方
  11988. /// 城市信息 Init
  11989. /// </summary>
  11990. /// <param name="dto"></param>
  11991. /// <returns></returns>
  11992. [HttpPost]
  11993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11994. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11995. {
  11996. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11997. RefAsync<int> total = 0;
  11998. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11999. .Where(it => it.CountriesId == dto.CountiesId)
  12000. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  12001. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  12002. .Select(it => new { id = it.Id, name = it.Name_CN })
  12003. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12004. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  12005. }
  12006. /// <summary>
  12007. /// 查看邀请方
  12008. /// 团组名称 Init
  12009. /// </summary>
  12010. /// <param name="dto"></param>
  12011. /// <returns></returns>
  12012. [HttpPost]
  12013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12014. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  12015. {
  12016. var watch = new Stopwatch();
  12017. watch.Start();
  12018. RefAsync<int> total = 0;
  12019. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  12020. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  12021. .Where((oa, di) => oa.IsDel == 0)
  12022. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  12023. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  12024. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  12025. .Distinct()
  12026. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12027. watch.Stop();
  12028. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  12029. }
  12030. /// <summary>
  12031. /// 查看邀请方
  12032. /// 团组 & 邀请方信息
  12033. /// </summary>
  12034. /// <param name="dto"></param>
  12035. /// <returns></returns>
  12036. [HttpPost]
  12037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12038. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  12039. {
  12040. var watch = new Stopwatch();
  12041. watch.Start();
  12042. RefAsync<int> total = 0;
  12043. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  12044. .AS("Grp_DelegationInfo")
  12045. .Includes(x => x.InvitingInfos)
  12046. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  12047. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  12048. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  12049. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  12050. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  12051. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  12052. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12053. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  12054. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  12055. infos.ForEach(x =>
  12056. {
  12057. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  12058. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  12059. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  12060. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  12061. });
  12062. watch.Stop();
  12063. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  12064. }
  12065. #endregion
  12066. #region 报批行程
  12067. /// <summary>
  12068. /// 报批行程初始化
  12069. /// </summary>
  12070. /// <param name="dto"></param>
  12071. /// <returns></returns>
  12072. [HttpPost]
  12073. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  12074. {
  12075. const int chiNumber = 5;
  12076. var jw = JsonView(false);
  12077. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  12078. var group = groupList.First();
  12079. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  12080. group = groupList.First(x => x.Id == diid);
  12081. if (group == null)
  12082. {
  12083. jw.Msg = "暂无团组!";
  12084. return Ok(jw);
  12085. }
  12086. var data = new
  12087. {
  12088. groupList = groupList.Select(x => new
  12089. {
  12090. x.TeamName,
  12091. x.Id
  12092. }),
  12093. content = new ArrayList(),
  12094. groupInfo = new
  12095. {
  12096. group.VisitDays,
  12097. group.TourCode,
  12098. group.VisitPNumber,
  12099. group.TeamName,
  12100. group.Id,
  12101. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  12102. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  12103. },
  12104. };
  12105. var resultArr = new ArrayList();
  12106. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  12107. if (content.Count == 0)
  12108. {
  12109. var stay = "-";
  12110. var cityPath = "-";
  12111. //添加城市路径以及住宿地
  12112. //黑屏代码数据
  12113. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12114. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12115. {
  12116. jw = JsonView(true, "黑屏代码有误!", data);
  12117. return Ok(jw);
  12118. }
  12119. foreach (DataRow row in dtBlack.Rows)
  12120. {
  12121. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12122. {
  12123. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  12124. return Ok(jw);
  12125. }
  12126. }
  12127. //黑屏代码获取时间区间
  12128. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12129. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12130. _sqlSugar.BeginTran();
  12131. for (int i = 0; i < timeArr.Count; i++)
  12132. {
  12133. stay = "-";
  12134. cityPath = "-";
  12135. DateTime NewData = DateTime.Parse(timeArr[i]);
  12136. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12137. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12138. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12139. if (tbSelect.Length > 0)
  12140. {
  12141. List<string> threeCodeStr = new List<string>();
  12142. foreach (var item in tbSelect)
  12143. {
  12144. var threeCode = item["Three"].ToString() ?? "";
  12145. if (threeCode.Length == 6)
  12146. {
  12147. var start = threeCode.Substring(0, 3);
  12148. var end = threeCode.Substring(3, 3);
  12149. if (threeCodeStr.Count == 0)
  12150. {
  12151. threeCodeStr.Add(start);
  12152. threeCodeStr.Add(end);
  12153. }
  12154. else
  12155. {
  12156. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12157. {
  12158. threeCodeStr.Add(end);
  12159. }
  12160. else
  12161. {
  12162. threeCodeStr.Add(start);
  12163. threeCodeStr.Add(end);
  12164. }
  12165. }
  12166. }
  12167. }
  12168. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12169. var last = threeCodeStr.Last();
  12170. foreach (var item in threeCodeStr)
  12171. {
  12172. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12173. if (item.Equals(last))
  12174. {
  12175. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12176. }
  12177. }
  12178. cityPath = cityPath.Trim('-');
  12179. }
  12180. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12181. appro.Diid = diid ?? -1;
  12182. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12183. appro.Id = thisId;
  12184. appro.CreateUserId = dto.UserId;
  12185. appro.CreateTime = DateTime.Now;
  12186. content.Add(appro);
  12187. }
  12188. _sqlSugar.CommitTran();
  12189. }
  12190. foreach (var x in content)
  12191. {
  12192. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12193. if (chiList.Count < chiNumber)
  12194. {
  12195. for (int i = chiList.Count; i < chiNumber; i++)
  12196. {
  12197. chiList.Add(new Grp_ApprovalTravelDetails());
  12198. }
  12199. }
  12200. resultArr.Add(new
  12201. {
  12202. x.Id,
  12203. x.Date,
  12204. x.Diid,
  12205. chiList = chiList.Select(x1 => new
  12206. {
  12207. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12208. x1.Details,
  12209. x1.ParentId,
  12210. x1.Id
  12211. })
  12212. });
  12213. }
  12214. data = data with
  12215. {
  12216. content = resultArr,
  12217. };
  12218. jw = JsonView(true, "获取成功!", data);
  12219. return Ok(jw);
  12220. }
  12221. /// <summary>
  12222. /// 报批行程删除
  12223. /// </summary>
  12224. /// <param name="dto"></param>
  12225. /// <returns></returns>
  12226. [HttpPost]
  12227. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12228. {
  12229. var jw = JsonView(false);
  12230. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12231. if (group == null)
  12232. {
  12233. jw.Msg = "团组参数有误!";
  12234. return Ok(jw);
  12235. }
  12236. try
  12237. {
  12238. _sqlSugar.BeginTran();
  12239. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12240. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12241. {
  12242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12243. DeleteUserId = dto.uesrId,
  12244. IsDel = 1
  12245. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12246. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12247. {
  12248. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12249. DeleteUserId = dto.uesrId,
  12250. IsDel = 1
  12251. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12252. _sqlSugar.CommitTran();
  12253. jw = JsonView(true, "删除成功");
  12254. }
  12255. catch (Exception ex)
  12256. {
  12257. jw = JsonView(false, ex.Message);
  12258. }
  12259. return Ok(jw);
  12260. }
  12261. /// <summary>
  12262. /// 报批行程保存
  12263. /// </summary>
  12264. /// <param name="dto"></param>
  12265. /// <returns></returns>
  12266. [HttpPost]
  12267. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12268. {
  12269. var jw = JsonView(false);
  12270. var Find = dto.Arr.Find(x => x.id == 0);
  12271. if (Find != null)
  12272. {
  12273. jw.Msg = "生成的ID为0!";
  12274. return Ok(jw);
  12275. }
  12276. foreach (var item in dto.Arr)
  12277. {
  12278. foreach (var chi in item.chiList)
  12279. {
  12280. if (chi.parentId == 0)
  12281. {
  12282. chi.parentId = item.id;
  12283. }
  12284. }
  12285. }
  12286. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12287. _sqlSugar.BeginTran();
  12288. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12289. {
  12290. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12291. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12292. {
  12293. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12294. DeleteUserId = dto.UserId,
  12295. IsDel = 1
  12296. }).ExecuteCommand();
  12297. }
  12298. try
  12299. {
  12300. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12301. {
  12302. CreateTime = DateTime.Now,
  12303. CreateUserId = dto.UserId,
  12304. Details = x.details,
  12305. ParentId = x.parentId,
  12306. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12307. Remark = "",
  12308. IsDel = 0
  12309. }).ToList()).ExecuteCommand();
  12310. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12311. {
  12312. Id = x.id,
  12313. Details = x.details,
  12314. ParentId = x.parentId,
  12315. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12316. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12317. {
  12318. Details = x.Details,
  12319. ParentId = x.ParentId,
  12320. Time = x.Time
  12321. }).ExecuteCommand();
  12322. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12323. {
  12324. Id = x.id,
  12325. Date = x.date,
  12326. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12327. {
  12328. Date = x.Date
  12329. }).ExecuteCommand();
  12330. _sqlSugar.CommitTran();
  12331. jw = JsonView(true, "保存成功!");
  12332. }
  12333. catch (Exception ex)
  12334. {
  12335. _sqlSugar.RollbackTran();
  12336. jw = JsonView(false, "保存失败!" + ex.Message);
  12337. }
  12338. return Ok(jw);
  12339. }
  12340. /// <summary>
  12341. /// 报批行程生成
  12342. /// </summary>
  12343. /// <param name="dto"></param>
  12344. /// <returns></returns>
  12345. [HttpPost]
  12346. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12347. {
  12348. var jw = JsonView(false);
  12349. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12350. if (group == null)
  12351. {
  12352. jw.Msg = "暂无该团组!";
  12353. return Ok(jw);
  12354. }
  12355. //黑屏代码数据
  12356. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12357. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12358. {
  12359. jw.Msg = "黑屏代码有误!";
  12360. return Ok(jw);
  12361. }
  12362. foreach (DataRow row in dtBlack.Rows)
  12363. {
  12364. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12365. {
  12366. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12367. return Ok(jw);
  12368. }
  12369. }
  12370. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12371. var resultArr = new ArrayList();
  12372. if (officialActivitiesArr.Count == 0)
  12373. {
  12374. jw.Msg = "暂无公务出访信息!";
  12375. return Ok(jw);
  12376. }
  12377. try
  12378. {
  12379. _sqlSugar.BeginTran();
  12380. DeleteApprovalJourney(new
  12381. Domain.Dtos.Groups.DeleteApprovalJourney
  12382. {
  12383. Diid = dto.Diid,
  12384. uesrId = dto.Userid
  12385. });
  12386. var stay = "-";
  12387. var cityPath = "-";
  12388. //添加城市路径以及住宿地
  12389. //黑屏代码获取时间区间
  12390. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12391. var empty = "【未收入该三字码!请机票同事录入】";
  12392. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12393. for (int i = 0; i < timeArr.Count; i++)
  12394. {
  12395. stay = "-";
  12396. cityPath = "-";
  12397. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12398. DateTime NewData = DateTime.Parse(timeArr[i]);
  12399. var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
  12400. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12401. if (tbSelect.Length > 0)
  12402. {
  12403. List<string> threeCodeStr = new List<string>();
  12404. bool isTrade = false;
  12405. string trip = string.Empty;
  12406. var rowLast = tbSelect.Last();
  12407. var rowFirst = tbSelect.First();
  12408. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12409. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12410. var takeOffTime = DateTime.Parse(timeArr[i]);
  12411. var fallToTime = DateTime.Parse(timeArr[i]);
  12412. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12413. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12414. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12415. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12416. foreach (var item in tbSelect)
  12417. {
  12418. var start = string.Empty;
  12419. var end = string.Empty;
  12420. var threeCode = item["Three"].ToString() ?? "";
  12421. if (threeCode.Length == 6)
  12422. {
  12423. start = threeCode.Substring(0, 3);
  12424. end = threeCode.Substring(3, 3);
  12425. if (threeCodeStr.Count == 0)
  12426. {
  12427. threeCodeStr.Add(start);
  12428. threeCodeStr.Add(end);
  12429. }
  12430. else
  12431. {
  12432. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12433. {
  12434. threeCodeStr.Add(end);
  12435. }
  12436. else
  12437. {
  12438. threeCodeStr.Add(start);
  12439. threeCodeStr.Add(end);
  12440. }
  12441. }
  12442. }
  12443. //处理机票信息
  12444. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12445. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12446. if (start_Object == null)
  12447. {
  12448. start_Object = new Res_ThreeCode()
  12449. {
  12450. AirPort = empty,
  12451. AirPort_En = empty,
  12452. City = empty,
  12453. Country = empty,
  12454. Four = empty,
  12455. Three = empty,
  12456. };
  12457. }
  12458. if (end_Object == null)
  12459. {
  12460. end_Object = new Res_ThreeCode()
  12461. {
  12462. AirPort = empty,
  12463. AirPort_En = empty,
  12464. City = empty,
  12465. Country = empty,
  12466. Four = empty,
  12467. Three = empty,
  12468. };
  12469. }
  12470. //机型判断
  12471. string airModel = item["AirModel"].ToString();
  12472. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12473. string flightTime = item["FlightTime"].ToString();
  12474. if (flightTime!.Contains(":"))
  12475. {
  12476. flightTime = flightTime.Replace(":", "小时");
  12477. flightTime += "分钟";
  12478. }
  12479. if (flightTime.Contains("H"))
  12480. {
  12481. flightTime = flightTime.Replace("H", "小时");
  12482. }
  12483. if (flightTime.Contains("M"))
  12484. {
  12485. flightTime = flightTime.Replace("M", "分钟");
  12486. }
  12487. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12488. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12489. {
  12490. flightTime = flightDataTime.Hour > 0
  12491. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12492. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12493. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12494. }
  12495. //航班号
  12496. string flightcode = item["Fliagtcode"].ToString();
  12497. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12498. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12499. if (aircompany == null)
  12500. {
  12501. aircompany = new Res_AirCompany
  12502. {
  12503. CnName = hsEmpty,
  12504. EnName = hsEmpty,
  12505. ShortCode = hsEmpty,
  12506. };
  12507. }
  12508. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12509. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12510. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12511. if (isTrade)
  12512. {
  12513. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12514. }
  12515. else
  12516. {
  12517. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12518. }
  12519. }
  12520. chiarr.Add(new Grp_ApprovalTravelDetails
  12521. {
  12522. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12523. CreateTime = DateTime.Now,
  12524. CreateUserId = dto.Userid,
  12525. ParentId = 0,
  12526. Details = trip
  12527. });
  12528. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12529. var last = threeCodeStr.Last();
  12530. foreach (var item in threeCodeStr)
  12531. {
  12532. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12533. if (item.Equals(last))
  12534. {
  12535. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12536. }
  12537. }
  12538. cityPath = cityPath.Trim('-');
  12539. }
  12540. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12541. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12542. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12543. appro.Diid = dto.Diid;
  12544. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12545. appro.Id = thisId;
  12546. appro.CreateUserId = dto.Userid;
  12547. appro.CreateTime = DateTime.Now;
  12548. foreach (var item in gwinfo)
  12549. {
  12550. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12551. chi.Details = "拜访" + item.Client;
  12552. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12553. {
  12554. chi.Details += "," + item.ReqSample;
  12555. }
  12556. chi.ParentId = thisId;
  12557. chi.Time = item.Time;
  12558. chiarr.Add(chi);
  12559. }
  12560. if (chiarr.Count < 5)
  12561. {
  12562. for (int j = chiarr.Count; j < 5; j++)
  12563. {
  12564. chiarr.Add(new
  12565. Grp_ApprovalTravelDetails());
  12566. }
  12567. }
  12568. resultArr.Add(new
  12569. {
  12570. appro.Id,
  12571. appro.Date,
  12572. appro.Diid,
  12573. chiList = chiarr.Select(x1 => new
  12574. {
  12575. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12576. x1.Details,
  12577. x1.ParentId,
  12578. x1.Id
  12579. })
  12580. });
  12581. }
  12582. _sqlSugar.CommitTran();
  12583. jw = JsonView(true, "生成成功!", resultArr);
  12584. }
  12585. catch (Exception ex)
  12586. {
  12587. jw.Code = 400;
  12588. jw.Msg = "生成失败!" + ex.Message;
  12589. }
  12590. return Ok(jw);
  12591. }
  12592. /// <summary>
  12593. /// 报批行程word导出
  12594. /// </summary>
  12595. /// <param name="dto"></param>
  12596. /// <returns></returns>
  12597. [HttpPost]
  12598. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12599. {
  12600. var jw = JsonView(false);
  12601. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12602. if (group == null)
  12603. {
  12604. jw.Msg = "暂无该团组!";
  12605. return Ok(jw);
  12606. }
  12607. //模板路径
  12608. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12609. //载入模板
  12610. Document doc = new Document(tempPath);
  12611. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12612. //获取所填表格的序数
  12613. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12614. Aspose.Words.Tables.Row titleRowClone = null;
  12615. Aspose.Words.Tables.Row CenterRowClone = null;
  12616. int index = 0;
  12617. int indexChi = 0;
  12618. int SetIndex = 0;
  12619. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12620. //获取数据,放到datatable
  12621. foreach (var item in ApprovalTravelArr)
  12622. {
  12623. if (index > 0)
  12624. {
  12625. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12626. tableOne.AppendChild(titleRowClone);
  12627. }
  12628. var textTime = item.Date;
  12629. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12630. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12631. SetIndex++;
  12632. if (ChiRep.Count > 0)
  12633. {
  12634. foreach (var itemChi in ChiRep)
  12635. {
  12636. var txtTime = itemChi.Time;
  12637. var txtDetail = itemChi.Details;
  12638. if (indexChi > 0)
  12639. {
  12640. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12641. tableOne.AppendChild(CenterRowClone);
  12642. }
  12643. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12644. {
  12645. SetCells(tableOne, doc, SetIndex, 0, "");
  12646. SetCells(tableOne, doc, SetIndex, 1, "");
  12647. indexChi++;
  12648. SetIndex++;
  12649. break;
  12650. }
  12651. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12652. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12653. indexChi++;
  12654. SetIndex++;
  12655. }
  12656. }
  12657. else
  12658. {
  12659. if (indexChi > 0)
  12660. {
  12661. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12662. tableOne.AppendChild(CenterRowClone);
  12663. }
  12664. SetCells(tableOne, doc, SetIndex, 0, "");
  12665. SetCells(tableOne, doc, SetIndex, 1, "");
  12666. indexChi++;
  12667. SetIndex++;
  12668. }
  12669. index++;
  12670. }
  12671. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12672. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12673. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12674. jw.Code = 200;
  12675. jw.Msg = "";
  12676. return Ok(jw);
  12677. }
  12678. private string intToString(int numberVal)
  12679. {
  12680. string numberval = numberVal.ToString();
  12681. Dictionary<char, string> Number = new Dictionary<char, string>();
  12682. Number.Add('1', "一");
  12683. Number.Add('2', "二");
  12684. Number.Add('3', "三");
  12685. Number.Add('4', "四");
  12686. Number.Add('5', "五");
  12687. Number.Add('6', "六");
  12688. Number.Add('7', "七");
  12689. Number.Add('8', "八");
  12690. Number.Add('9', "九");
  12691. string stringNumberVal = string.Empty;
  12692. for (int i = 0; i < numberval.Length; i++)
  12693. {
  12694. if (i == 0)
  12695. {
  12696. stringNumberVal += Number[numberval[i]];
  12697. }
  12698. else if (i >= 1)
  12699. {
  12700. if (numberval[i] == '0')
  12701. {
  12702. stringNumberVal = "十";
  12703. }
  12704. else
  12705. {
  12706. stringNumberVal += "十" + Number[numberval[i]];
  12707. }
  12708. }
  12709. }
  12710. return stringNumberVal;
  12711. }
  12712. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12713. {
  12714. //获取table中的某个单元格,从0开始
  12715. Cell lshCell = table.Rows[rows].Cells[cells];
  12716. //将单元格中段落移除
  12717. foreach (Node item in lshCell.Paragraphs)
  12718. {
  12719. lshCell.Paragraphs.Remove(item);
  12720. }
  12721. if (val.Contains("\r\n"))
  12722. {
  12723. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12724. foreach (var item in spArr)
  12725. {
  12726. //新建一个段落
  12727. Paragraph p = new Paragraph(doc);
  12728. var r = new Run(doc, item);
  12729. //把设置的值赋给之前新建的段落
  12730. p.AppendChild(r);
  12731. //将此段落加到单元格内
  12732. lshCell.AppendChild(p);
  12733. }
  12734. }
  12735. else
  12736. {
  12737. //新建一个段落
  12738. Paragraph p = new Paragraph(doc);
  12739. var r = new Run(doc, val);
  12740. //把设置的值赋给之前新建的段落
  12741. p.AppendChild(r);
  12742. //将此段落加到单元格内
  12743. lshCell.AppendChild(p);
  12744. }
  12745. }
  12746. [HttpPost]
  12747. public async Task<IActionResult> ServerHttp(string paramStr)
  12748. {
  12749. paramStr = paramStr.TrimEnd('\'');
  12750. paramStr = paramStr.TrimStart('\'');
  12751. JsonView jw = JsonView(false);
  12752. JObject param = JObject.Parse(paramStr);
  12753. if (!param.ContainsKey("url"))
  12754. {
  12755. jw.Msg = "url null";
  12756. return Ok(jw);
  12757. }
  12758. string url = param["url"]!.ToString();
  12759. var methon = "get";
  12760. Dictionary<string, string> bodyValues = null;
  12761. Dictionary<string, string> headValues = null;
  12762. if (param.ContainsKey("methon"))
  12763. {
  12764. methon = param["methon"]!.ToString();
  12765. }
  12766. if (param.ContainsKey("header"))
  12767. {
  12768. var header = param["header"]!.ToString();
  12769. JObject headerJobject = JObject.Parse(header);
  12770. headValues = new Dictionary<string, string>();
  12771. foreach (JProperty item in headerJobject.Properties())
  12772. {
  12773. var value = item.Value.ToString();
  12774. var head = item.Path;
  12775. headValues.Add(head, value);
  12776. }
  12777. }
  12778. if (param.ContainsKey("body"))
  12779. {
  12780. var body = param["body"]!.ToString();
  12781. bodyValues = new Dictionary<string, string>();
  12782. JObject bodyJobject = JObject.Parse(body);
  12783. foreach (JProperty item in bodyJobject.Properties())
  12784. {
  12785. var value = item.Value.ToString();
  12786. var head = item.Path;
  12787. bodyValues.Add(head, value);
  12788. }
  12789. }
  12790. HttpClient client = new HttpClient();
  12791. string responseString = string.Empty;
  12792. if (param.ContainsKey("isJson"))
  12793. {
  12794. }
  12795. if (headValues != null)
  12796. {
  12797. foreach (var item in headValues.Keys)
  12798. {
  12799. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12800. }
  12801. }
  12802. try
  12803. {
  12804. if (methon == "get")
  12805. {
  12806. responseString = await client.GetStringAsync(url);
  12807. }
  12808. else if (methon == "post")
  12809. {
  12810. if (bodyValues == null)
  12811. {
  12812. jw.Msg = "methon post body null";
  12813. return Ok(jw);
  12814. }
  12815. // 数据转化为 key=val 格式
  12816. var content = new FormUrlEncodedContent(bodyValues);
  12817. var response = await client.PostAsync(url, content);
  12818. // 获取数据
  12819. responseString = await response.Content.ReadAsStringAsync();
  12820. }
  12821. else
  12822. {
  12823. jw.Msg = "methon error";
  12824. }
  12825. jw = JsonView(true, "success", responseString);
  12826. }
  12827. catch (Exception ex)
  12828. {
  12829. jw.Msg = "error " + ex.Message;
  12830. jw.Data = ex.StackTrace;
  12831. }
  12832. finally
  12833. {
  12834. client.Dispose();
  12835. }
  12836. return Ok(jw);
  12837. }
  12838. #endregion
  12839. // /// <summary>
  12840. // ///
  12841. // /// </summary>
  12842. // /// <param name="_dto"></param>
  12843. // /// <returns></returns>
  12844. // [HttpPost]
  12845. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12846. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12847. // {
  12848. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12849. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12850. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12851. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12852. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  12853. // dic_psg.Add("客人", 974);
  12854. // dic_psg.Add("司机", 975);
  12855. // dic_psg.Add("导游", 976);
  12856. // dic_psg.Add("公司内部人员", 977);
  12857. // dic_psg.Add("司机/导游/公司内部人员", 978);
  12858. // foreach (var item in list_visa)
  12859. // {
  12860. // Grp_VisaInfo temp = new Grp_VisaInfo();
  12861. // temp.Id = item.Id;
  12862. // temp.DIId = item.DIId;
  12863. // temp.VisaClient = item.VisaClient;
  12864. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  12865. // temp.VisaCurrency = item.VisaCurrency;
  12866. // temp.IsThird = item.IsThird;
  12867. // if (dic_psg.ContainsKey(item.PassengerType))
  12868. // {
  12869. // temp.PassengerType = dic_psg[item.PassengerType];
  12870. // }
  12871. // else {
  12872. // temp.PassengerType = -1;
  12873. // }
  12874. // temp.VisaNumber = item.VisaNumber;
  12875. // temp.VisaFreeNumber = item.VisaFreeNumber;
  12876. // temp.CreateUserId = item.Operators;
  12877. // DateTime dt_ct;
  12878. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  12879. // if (b_ct)
  12880. // {
  12881. // temp.CreateTime = dt_ct;
  12882. // }
  12883. // else
  12884. // {
  12885. // temp.CreateTime = DateTime.Now;
  12886. // }
  12887. // temp.DeleteTime = "";
  12888. // temp.DeleteUserId = 0;
  12889. // temp.Remark = item.Remark;
  12890. // if (string.IsNullOrEmpty(temp.Remark)) {
  12891. // temp.Remark = "";
  12892. // }
  12893. // temp.IsDel = item.IsDel;
  12894. // temp.VisaDescription = item.VisaAttachment;
  12895. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  12896. //([Id]
  12897. // ,[DIId]
  12898. // ,[VisaClient]
  12899. // ,[VisaPrice]
  12900. // ,[VisaCurrency]
  12901. // ,[IsThird]
  12902. // ,[PassengerType]
  12903. // ,[VisaNumber]
  12904. // ,[VisaFreeNumber]
  12905. // ,[CreateUserId]
  12906. // ,[CreateTime]
  12907. // ,[DeleteTime]
  12908. // ,[DeleteUserId]
  12909. // ,[Remark]
  12910. // ,[IsDel]
  12911. // ,[visaDescription])
  12912. // VALUES
  12913. // ({0},{1},'{2}',{3},{4}
  12914. //,{5},{6},{7},{8},{9}
  12915. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  12916. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  12917. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  12918. //);
  12919. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  12920. // }
  12921. // return Ok(JsonView(true, "操作成功!"));
  12922. // }
  12923. /// <summary>
  12924. /// 123132123
  12925. /// </summary>
  12926. /// <param name="_dto"></param>
  12927. /// <returns></returns>
  12928. [HttpPost]
  12929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12930. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12931. {
  12932. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12933. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  12934. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  12935. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12936. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  12937. dicDetail.Add(789, 1034);
  12938. dicDetail.Add(790, 1035);
  12939. dicDetail.Add(791, 1036);
  12940. dicDetail.Add(792, 1037);
  12941. dicDetail.Add(793, 1038);
  12942. dicDetail.Add(794, 1039);
  12943. dicDetail.Add(795, 1040);
  12944. dicDetail.Add(796, 1041);
  12945. dicDetail.Add(797, 1042);
  12946. dicDetail.Add(798, 1043);
  12947. dicDetail.Add(801, 1044);
  12948. dicDetail.Add(802, 1045);
  12949. dicDetail.Add(803, 1046);
  12950. Dictionary<int, int> dic = new Dictionary<int, int>();
  12951. dic.Add(806, 1027);
  12952. dic.Add(807, 1028);
  12953. dic.Add(808, 1029);
  12954. dic.Add(809, 1030);
  12955. dic.Add(810, 1031);
  12956. dic.Add(811, 1032);
  12957. dic.Add(812, 1033);
  12958. foreach (var item in list_visa)
  12959. {
  12960. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  12961. temp.Coefficient = item.coefficient;
  12962. DateTime dtCrt;
  12963. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  12964. if (b1)
  12965. {
  12966. temp.CreateTime = dtCrt;
  12967. }
  12968. else
  12969. {
  12970. temp.CreateTime = DateTime.Now;
  12971. }
  12972. temp.CreateUserId = item.Operators;
  12973. temp.DeleteTime = "";
  12974. temp.DeleteUserId = 0;
  12975. temp.DiId = int.Parse(item.DIID);
  12976. temp.FilePath = item.FilePath;
  12977. temp.IsDel = item.IsDel;
  12978. temp.Price = item.Price;
  12979. temp.PriceCount = 1;
  12980. temp.PriceCurrency = item.Currency;
  12981. int detailId = 0;
  12982. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  12983. {
  12984. detailId = dicDetail[item.PriceTypeDetail];
  12985. }
  12986. temp.PriceDetailType = detailId;
  12987. temp.PriceDt = DateTime.Now;
  12988. temp.PriceName = item.PriceName;
  12989. temp.PriceSum = item.Price;
  12990. int tid = 0;
  12991. if (dic.ContainsKey(item.PriceType))
  12992. {
  12993. tid = dic[item.PriceType];
  12994. }
  12995. temp.PriceType = tid;
  12996. temp.Remark = item.Remark;
  12997. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  12998. }
  12999. return Ok(JsonView(true, "操作成功!"));
  13000. }
  13001. }
  13002. }