12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155 |
- using Aspose.Cells;
- using Aspose.Cells.Drawing.Texts;
- using Aspose.Words;
- using Aspose.Words.Tables;
- using NPOI.Util;
- using OASystem.API.OAMethodLib;
- using OASystem.API.OAMethodLib.File;
- using OASystem.Domain.Dtos.Groups;
- using OASystem.Domain.Entities.Groups;
- using OASystem.Domain.ViewModels.Groups;
- using OASystem.Infrastructure.Repositories.Groups;
- using TencentCloud.Ocr.V20181119.Models;
- using OASystem.Infrastructure.Tools;
- using System.Web;
- using System.Data;
- using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
- using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
- using Cell = Aspose.Words.Tables.Cell;
- using Row = Aspose.Words.Tables.Row;
- using System.Runtime.Intrinsics.Arm;
- using Microsoft.AspNetCore.Mvc.Filters;
- using OASystem.Domain.Entities.Customer;
- using NPOI.SS.Formula.Functions;
- using OASystem.Domain.Dtos.CRM;
- using System.Diagnostics;
- using MathNet.Numerics.Statistics.Mcmc;
- using AlibabaCloud.OpenApiClient.Models;
- using System;
- using NPOI.HPSF;
- using SqlSugar;
- using System.Collections;
- using Org.BouncyCastle.Ocsp;
- using System.Globalization;
- using static QRCoder.PayloadGenerator;
- using Bookmark = Aspose.Words.Bookmark;
- using Aspose.Words.Fields;
- using NPOI.POIFS.FileSystem;
- using Microsoft.AspNetCore.Mvc.ViewEngines;
- using OASystem.Domain.ViewModels.QiYeWeChat;
- using OASystem.Domain.Entities.Financial;
- using NPOI.POIFS.Crypt.Dsig;
- using System.Diagnostics.Eventing.Reader;
- using System.IO;
- using StackExchange.Redis;
- using Org.BouncyCastle.Utilities;
- using Aspose.Words.Drawing;
- using Aspose.Cells.Charts;
- using static NPOI.HSSF.Util.HSSFColor;
- using Quartz.Util;
- using Google.Protobuf.WellKnownTypes;
- using Microsoft.AspNetCore.SignalR;
- using OASystem.API.OAMethodLib.Hub.HubClients;
- using OASystem.API.OAMethodLib.Hub.Hubs;
- using System.Collections.Generic;
- using OASystem.API.OAMethodLib.JuHeAPI;
- using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
- using SixLabors.Fonts.Tables.AdvancedTypographic;
- using Microsoft.EntityFrameworkCore;
- using System.Security.Cryptography.Xml;
- using MathNet.Numerics;
- using System.Security.Policy;
- using System.Xml;
- using OASystem.Domain.Dtos.QiYeWeChat;
- using static NPOI.POIFS.Crypt.CryptoFunctions;
- using Aspose.Words.Lists;
- namespace OASystem.API.Controllers
- {
- /// <summary>
- /// 团组相关
- /// </summary>
- //[Authorize]
- [Route("api/[controller]/[action]")]
- public class GroupsController : ControllerBase
- {
- private readonly GrpScheduleRepository _grpScheduleRep;
- private readonly IMapper _mapper;
- private readonly DelegationInfoRepository _groupRepository;
- private readonly TaskAssignmentRepository _taskAssignmentRep;
- private readonly AirTicketResRepository _airTicketResRep;
- private readonly DecreasePaymentsRepository _decreasePaymentsRep;
- private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
- private readonly DelegationEnDataRepository _delegationEnDataRep;
- private readonly DelegationVisaRepository _delegationVisaRep;
- private readonly VisaPriceRepository _visaPriceRep;
- private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
- private readonly HotelPriceRepository _hotelPriceRep;
- private readonly CustomersRepository _customersRep;
- private readonly MessageRepository _message;
- private readonly SqlSugarClient _sqlSugar;
- private readonly TourClientListRepository _tourClientListRep;
- private readonly TeamRateRepository _teamRateRep;
- #region 成本相关
- private readonly CheckBoxsRepository _checkBoxs;
- private readonly GroupCostRepository _GroupCostRepository;
- private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
- private readonly GroupCostParameterRepository _GroupCostParameterRepository;
- #endregion
- private readonly SetDataRepository _setDataRep;
- private string url;
- private string path;
- private readonly EnterExitCostRepository _enterExitCostRep;
- private readonly IHubContext<ChatHub, IChatClient> _hubContext;
- private readonly UsersRepository _usersRep;
- private readonly IJuHeApiService _juHeApi;
- private readonly InvertedListRepository _invertedListRep;
- public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
- TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
- InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
- , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
- CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
- GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
- TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
- InvertedListRepository invertedListRep)
- {
- _mapper = mapper;
- _grpScheduleRep = grpScheduleRep;
- _groupRepository = groupRepository;
- _taskAssignmentRep = taskAssignmentRep;
- _airTicketResRep = airTicketResRep;
- _sqlSugar = sqlSugar;
- url = AppSettingsHelper.Get("ExcelBaseUrl");
- path = AppSettingsHelper.Get("ExcelBasePath");
- if (!System.IO.Directory.Exists(path))
- {
- System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
- }
- _decreasePaymentsRep = decreasePaymentsRep;
- _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
- _delegationEnDataRep = delegationEnDataRep;
- _enterExitCostRep = enterExitCostRep;
- _delegationVisaRep = delegationVisaRep;
- _message = message;
- _visaPriceRep = visaPriceRep;
- _carTouristGuideGroundRep = carTouristGuideGroundRep;
- _checkBoxs = checkBoxs;
- _GroupCostRepository = GroupCostRepository;
- _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
- _GroupCostParameterRepository = GroupCostParameterRepository;
- _hotelPriceRep = hotelPriceRep;
- _customersRep = customersRep;
- _setDataRep = setDataRep;
- _tourClientListRep = tourClientListRep;
- _teamRateRep = teamRateRep;
- _hubContext = hubContext;
- _usersRep = usersRep;
- _juHeApi = juHeApi;
- _invertedListRep = invertedListRep;
- }
- #region 流程管控
- /// <summary>
- /// 获取团组流程管控信息
- /// </summary>
- /// <param name="paras">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
- {
- if (string.IsNullOrEmpty(_jsonDto.Paras))
- {
- return Ok(JsonView(false, "参数为空"));
- }
- Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
- if (_ScheduleDto != null)
- {
- if (_ScheduleDto.SearchType == 2)//获取列表
- {
- List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
- return Ok(JsonView(_grpScheduleViewList));
- }
- else//获取对象
- {
- Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
- if (_grpScheduleView != null)
- {
- return Ok(JsonView(_grpScheduleView));
- }
- }
- }
- else
- {
- return Ok(JsonView(false, "参数反序列化失败"));
- }
- return Ok(JsonView(false, "暂无数据!"));
- }
- /// <summary>
- /// 修改团组流程管控详细表数据
- /// </summary>
- /// <param name="paras"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
- .SetColumns(it => it.Duty == _detail.Duty)
- .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
- .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
- .SetColumns(it => it.JobContent == _detail.JobContent)
- .SetColumns(it => it.Remark == _detail.Remark)
- .SetColumns(it => it.StepStatus == _detail.StepStatus)
- .Where(s => s.Id == dto.Id)
- //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "保存成功!"));
- }
- return Ok(JsonView(false, "保存失败!"));
- }
- /// <summary>
- /// 删除团组流程管控详细表数据,删除人Id请放在Duty
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- _detail.IsDel = 1;
- _detail.DeleteUserId = dto.Duty;
- _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
- .SetColumns(it => it.IsDel == _detail.IsDel)
- .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
- .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
- .Where(it => it.Id == dto.Id)
- //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
- //.WhereColumns(s => s.Id == dto.Id)
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "删除成功!"));
- }
- return Ok(JsonView(false, "删除失败!"));
- }
- /// <summary>
- /// 增加团组流程管控详细表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
- {
- Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
- if (DateTime.Now < _detail.ExpectBeginDt)
- {
- _detail.StepStatus = 0;
- }
- else
- {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
- _detail.StepStatus = 1;
- }
- var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
- if (result > 0)
- {
- Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
- return Ok(JsonView(true, "添加成功!", _result));
- }
- return Ok(JsonView(false, "添加失败!"));
- }
- #endregion
- #region 团组基本信息
- /// <summary>
- /// 接团信息列表
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupList(GroupListDto dto)
- {
- var groupData = await _groupRepository.GetGroupList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 接团信息列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType == 1 || dto.PortType == 2) // web/Android
- {
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(dto.SearchCriteria))
- {
- string tj = dto.SearchCriteria;
- 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}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToList();
- foreach (var item in _DelegationList)
- {
- item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- }
- #endregion
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 团组列表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (dto.PortType != 1 && dto.PortType != 2)
- {
- return Ok(JsonView(false, "查询失败!"));
- }
- string orderbyStr = "order by gdi.CreateTime Desc";
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- //团组类型
- if (dto.TeamDid > 0)
- {
- sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
- }
- //团组名称
- if (!string.IsNullOrEmpty(dto.TeamName))
- {
- sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
- }
- //客户名称
- if (!string.IsNullOrEmpty(dto.ClientName))
- {
- sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
- }
- //客户单位
- if (!string.IsNullOrEmpty(dto.ClientUnit))
- {
- sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
- }
- //出访时间
- if (!string.IsNullOrEmpty(dto.visitDataTime))
- {
- sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
- orderbyStr = "order by gdi.VisitDate";
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
- JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over({0}) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
- su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {1}
- ) temp ", orderbyStr, sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- #region 处理所属部门
- /*
- * 1.sq 和 gyy 等显示 市场部
- * 2.王鸽和主管及张总还有管理员号统一国交部
- * 2-1. 4 管理员 ,21 张海麟
- */
- List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
- List<int> userIds1 = new List<int>() { 4, 21 };
- var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
- .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
- .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
- .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
- .ToList();
- foreach (var item in _DelegationList)
- {
- item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
- }
- #endregion
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- /// <summary>
- /// 接团信息详情
- /// </summary>
- /// <param name="dto">团组info请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
- {
- var groupData = await _groupRepository.GetGroupInfo(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 接团信息 编辑添加
- /// 基础信息数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
- {
- var groupData = await _groupRepository.GroupEditBasicSource(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// 接团信息 操作(增改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
- {
- try
- {
- var groupData = await _groupRepository.GroupOperation(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- int diId = 0;
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号
- List<int> _managerIds = new List<int>() { 22, 32 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- //默认创建倒推表
- await _invertedListRep._Create(dto.UserId, diId);
- }
- else if (dto.Status == 2)
- {
- diId = dto.Id;
- }
- return Ok(JsonView(true, "操作成功!", diId));
- }
- catch (Exception ex)
- {
- Logs("[response]" + JsonConvert.SerializeObject(dto));
- Logs(ex.Message);
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团流程操作(增改)
- /// 安卓端使用 建团时添加客户名单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
- //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
- #endregion
- #endregion
- _sqlSugar.BeginTran();
- var _dto = new GroupOperationDto();
- _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
- var groupData = await _groupRepository.GroupOperation(_dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
- }
- int diId = 0;
- //添加时 默认加入团组汇率
- if (dto.Status == 1) //添加
- {
- diId = groupData.Data;
- //添加默认币种
- await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
- //默认分配权限
- await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
- //消息提示 王鸽 主管号
- List<int> _managerIds = new List<int>() { 22, 32 };
- var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
- if (userIds.Count > 0)
- {
- userIds.Add(208);
- //创建团组管控
- GroupStepForDelegation.CreateWorkStep(diId);
- //发送消息
- string groupName = dto.TeamName;
- string createGroupUser = string.Empty;
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null) createGroupUser = userInfo.CnName;
- string title = $"系统通知";
- string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
- await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
- }
- }
- if (dto.Status == 2)
- {
- diId = dto.Id;
- if (diId == 0)
- {
- return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
- }
- }
- var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
- if (viewData.Code != 0)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
- }
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "添加成功"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 接团信息 操作(删除)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GroupDel(GroupDelDto dto)
- {
- try
- {
- var groupData = await _groupRepository.GroupDel(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true));
- }
- catch (Exception ex)
- {
- Logs("[response]" + JsonConvert.SerializeObject(dto));
- Logs(ex.Message);
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 获取团组销售报价号
- /// 团组添加时 使用
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupSalesQuoteNo()
- {
- var groupData = await _groupRepository.GetGroupSalesQuoteNo();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- object salesQuoteNo = new
- {
- SalesQuoteNo = groupData.Data
- };
- return Ok(JsonView(salesQuoteNo));
- }
- /// <summary>
- /// 设置确认出团
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
- {
- var groupData = await _groupRepository.ConfirmationGroup(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
- return Ok(JsonView(true, "操作成功!", groupData.Data));
- }
- /// <summary>
- /// 获取团组名称data And 签证国别Data
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
- {
- var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
-
- /// <summary>
- /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
- {
- try
- {
- Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 团组&签证
- /// <summary>
- /// 根据团组Id获取签证客户信息List
- /// </summary>
- /// <param name="dto">请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
- {
- var groupData = await _groupRepository.GetCrmByGroupId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(groupData.Data));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度01(团组列表)
- /// </summary>
- /// <param name="dto">请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "参数为空"));
- }
- DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
- return Ok(JsonView(visaList));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
- return Ok(JsonView(list));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度03(相册)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
- string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
- list.ForEach(s => s.url = url);
- return Ok(JsonView(list));
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度04(图片上传)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
- {
- //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
- //if (!string.IsNullOrEmpty(result))
- //{
- //}
- //else {
- // return Ok(JsonView(false, "上传失败"));
- //}
- DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
- int sucNum = 0;
- try
- {
- foreach (var item in dto.base64DataList)
- {
- string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
- string result = decodeBase64ToImage(item, imageName);
- if (!string.IsNullOrEmpty(result))
- {
- Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
- pic.CreateUserId = dto.CreateUserId;
- pic.PicName = imageName;
- pic.PicPath = result;
- pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
- int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
- if (insertResult > 0)
- {
- sucNum++;
- }
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- string msg = string.Format(@"成功上传{0}张", sucNum);
- return Ok(JsonView(true, msg));
- }
- private string decodeBase64ToImage(string base64DataURL, string imgName)
- {
- string filename = "";//声明一个string类型的相对路径
- String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
- System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
- try//会有异常抛出,try,catch一下
- {
- byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
- System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
- bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
- var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
- //文件名称
- filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + filename;
- //string url = HttpRuntime.AppDomainAppPath.ToString();
- //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
- //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
- bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
- //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
- //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
- //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
- ms.Close();//关闭当前流,并释放所有与之关联的资源
- bitmap.Dispose();
- }
- catch (Exception e)
- {
- string massage = e.Message;
- Logs("IOS图片上传Error:" + massage);
- //filename = e.Message;
- }
- return filename;//返回相对路径
- }
- /// <summary>
- /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
- {
- if (dto == null)
- {
- return Ok(JsonView(false, "请求错误:"));
- }
- string msg = "参数错误";
- if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
- {
- try
- {
- //_delegationVisaRep.BeginTran();
- var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
- .SetColumns(it => it.WorkStatus == dto.visaStatus)
- .Where(s => s.Id == dto.visaProgressCustomerId)
- .ExecuteCommandAsync();
- if (updCount > 0 && dto.publishCode == 1)
- {
- _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
- string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
- OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
- //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
- //var groupData = await _groupRepository.GetGroupInfo(grpDto);
- _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
- if (groupData == null)
- {
- _delegationVisaRep.RollbackTran();
- }
- string title = string.Format(@"[签证进度更新]");
- string content = string.Format(@"测试文本");
- bool rst = await _message.AddMsg(new MessageDto()
- {
- Type = MessageTypeEnum.GroupVisaProgressUpdate,
- IssuerId = dto.publisher,
- Title = title,
- Content = content,
- ReleaseTime = DateTime.Now,
- UIdList = new List<int> {
- 234
- }
- });
- if (rst)
- {
- return Ok(JsonView(true, "发送通知成功"));
- }
- }
- //_delegationVisaRep.CommitTran();
- }
- catch (Exception)
- {
- //_delegationVisaRep.RollbackTran();
- }
- }
- return Ok(JsonView(true, msg));
- }
- #endregion
- #region 团组任务分配
- /// <summary>
- /// 团组任务分配初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetTaskAssignmen()
- {
- var groupData = await _taskAssignmentRep.GetTaskAssignmen();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 团组任务分配查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
- {
- var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- /// <summary>
- /// 团组任务分配操作
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
- {
- Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- #endregion
- #region 团组费用审核
- /// <summary>
- /// 费用审核
- /// 团组列表 Page
- /// </summary>
- /// <param name="_dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
- {
- string sqlWhere = string.Empty;
- if (_dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (_dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(_dto.SearchCriteria))
- {
- string tj = _dto.SearchCriteria;
- 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}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
- VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
- ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
- VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp ", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
- var _view = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _DelegationList
- };
- return Ok(JsonView(true, "查询成功!", _view, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 获取团组费用审核
- /// </summary>
- /// <param name="paras">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
- #endregion
- #endregion
- Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
- List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
- #region 费用清单
- var exp = Expressionable.Create<Grp_CreditCardPayment>();
- exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
- exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
- List<Grp_CreditCardPayment> entityList = _groupRepository
- .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
- .Where(exp.ToExpression())
- .ToList();
- List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
- List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
- /*
- * 76://酒店预订
- */
- List<Grp_HotelReservations> _HotelReservations = await _groupRepository
- .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 79://车/导游地接
- */
- List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
- .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
- .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 80: //签证
- */
- List<Grp_VisaInfo> _VisaInfos = await _groupRepository
- .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
-
- /*
- *81: //邀请/公务活动
- */
- List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
- .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 82: //团组客户保险
- */
- List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
-
- /*
- * Lable = 85 机票预订
- */
- List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
- .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 85 机票预定
- */
- List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 98 其他款项
- */
- List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
- .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 285:收款退还
- */
- List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
- .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
- .ToListAsync();
- /*
- * 1015: //超支费用
- */
- List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
- /*
- * 币种信息
- */
- var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
- /*
- * 车/导游地接 费用类型
- */
- var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
- /*
- * 用户信息
- */
- var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
- /*
- * 费用模块
- */
- Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
- string priceModule = string.Empty;
- if (sdPriceName != null)
- {
- priceModule = sdPriceName.Name;
- }
- /*
- * 处理详情数据
- */
- foreach (var entity in entityList)
- {
- Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
- _detail.Id = entity.Id;
- _detail.PriceName = priceModule;
- /*
- * 应付款金额
- */
- Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
- string PaymentCurrency_WaitPay = "Unknown";
- string hotelCurrncyCode = "Unknown";
- string hotelCurrncyName = "Unknown";
- if (sdPaymentCurrency_WaitPay != null)
- {
- PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
- hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
- hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
- if (hotelCurrncyCode.Equals("CNY"))
- {
- entity.DayRate = 1.0000M;
- }
- }
- _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
- /*
- * 此次付款金额
- */
- decimal CurrPayStr = 0;
- if (entity.PayPercentage == 0)
- {
- if (entity.PayThenMoney != 0)
- CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
- }
- else
- {
- CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
- }
- _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
- /*
- * 剩余尾款
- */
- decimal BalanceStr = 0;
- if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
- BalanceStr = 0;
- else
- BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
- _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
- /*
- * Bus名称
- */
- _detail.BusName = "待增加";
- /*
- *费用所属
- */
- switch (entity.CTable)
- {
- case 76://酒店预订
- Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (hotelReservations != null)
- {
- string GovernmentRentCode = "", GovernmentRentName = "", CityTaxCode = "", CityTaxName = "", BreakfastCode = "", BreakfastName = "";
- Sys_SetData sdPaymentCurrency_GovernmentRent = currencyItems.Where(s => s.Id == hotelReservations.GovernmentRentCurrency).FirstOrDefault();
- if (sdPaymentCurrency_GovernmentRent != null)
- {
- GovernmentRentCode = sdPaymentCurrency_GovernmentRent.Name;
- GovernmentRentName = sdPaymentCurrency_GovernmentRent.Remark;
- }
- Sys_SetData sdPaymentCurrency_CityTax = currencyItems.Where(s => s.Id == hotelReservations.CityTaxCurrency).FirstOrDefault();
- if (sdPaymentCurrency_CityTax != null)
- {
- CityTaxCode = sdPaymentCurrency_CityTax.Name;
- CityTaxName = sdPaymentCurrency_CityTax.Remark;
- }
- Sys_SetData sdPaymentCurrency_Breakfast = currencyItems.Where(s => s.Id == hotelReservations.BreakfastCurrency).FirstOrDefault();
- if (sdPaymentCurrency_Breakfast != null)
- {
- BreakfastCode = sdPaymentCurrency_Breakfast.Name;
- BreakfastName = sdPaymentCurrency_Breakfast.Remark;
- }
- string isoppayStr = hotelReservations.Isoppay == 0 ? "是" : "否";
- _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
- $"房间说明: {hotelReservations.Remark} <br/>" +
- $"地税: {hotelReservations.GovernmentRent.ToString("#0.00")} {GovernmentRentCode} ({GovernmentRentName})<br/>" +
- $"城市税: {hotelReservations.CityTax.ToString("#0.00")} {CityTaxCode} ({CityTaxName})<br/>" +
- $"酒店早餐: {hotelReservations.BreakfastPrice.ToString("#0.00")} {BreakfastCode} ({BreakfastName})<br/>" +
- $"酒店早餐是否由地接代付: {isoppayStr}";
- _detail.PriceNameContent = hotelReservations.HotelName;
- }
- break;
- case 79://车/导游地接
- Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (touristGuideGroundReservations != null)
- {
- if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
- {
- _detail.BusName = touristGuideGroundReservations.BusName;
- }
- _detail.PriceNameContent = touristGuideGroundReservations.Area;
- List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
- .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
- string priceMsg = string.Empty;
- foreach (var item in touristGuideGroundReservationsContents)
- {
- string typeName = "Unknown";
- string carCurrencyCode = "Unknown";
- string carCurrencyName = "Unknown";
- var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
- if (carTypeData != null) typeName = carTypeData.Name;
- var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
- if (currencyData != null) {
- carCurrencyCode = currencyData.Name;
- carCurrencyName = currencyData.Remark;
- }
- priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
- "明细:" + item.PriceContent + "<br/>" +
- "备注:" + item.Remark + "<br/><br/>";
- }
- _detail.PriceMsgContent = priceMsg;
- }
- break;
- case 80: //签证
- Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (visaInfo != null)
- {
- _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
- _detail.PriceMsgContent = "备注:" + visaInfo.Remark;
- }
- break;
- case 81: //邀请/公务活动
- Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (_ioa != null)
- {
- string inviteCurrName = "Unknown", //邀请费用币种 Name
- inviteCurrCode = "Unknown", //邀请费用币种 Code
- sendCurrName = "Unknown", //快递费用币种 Name
- sendCurrCode = "Unknown", //快递费用币种 Code
- eventsCurrName = "Unknown", //公务活动费币种 Name
- eventsCurrCode = "Unknown", //公务活动费币种 Code
- translateCurrName = "Unknown", //公务翻译费 Name
- translateCurrCode = "Unknown"; //公务翻译费 Code
- #region 处理费用币种
- var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
- if (inviteCurrData != null)
- {
- inviteCurrName = inviteCurrData.Remark;
- inviteCurrCode = inviteCurrData.Name;
- }
- var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
- if (sendCurrData != null)
- {
- sendCurrName = sendCurrData.Remark;
- sendCurrCode = sendCurrData.Name;
- }
- var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
- if (eventsCurrData != null)
- {
- eventsCurrName = eventsCurrData.Remark;
- eventsCurrCode = eventsCurrData.Name;
- }
- var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
- if (translateCurrData != null)
- {
- translateCurrName = translateCurrData.Remark;
- translateCurrCode = translateCurrData.Name;
- }
- #endregion
- _detail.PriceNameContent = _ioa.InviterArea;
- _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
- $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
- $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
- $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
- $@"备注:" + _ioa.Remark + "<br/>";
- }
- break;
- case 82: //团组客户保险
- Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
- if (customers != null)
- {
- _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
- _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
- }
- break;
- case 85: //机票预订
- Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (jpRes != null)
- {
- string FlightsDescription = jpRes.FlightsDescription;
- string PriceDescription = jpRes.PriceDescription;
- _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
- _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
- }
- break;
- case 98://其他款项
- Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (gdpRes != null)
- {
- _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
- _detail.PriceNameContent = gdpRes.PriceName;
- }
- break;
- case 285://收款退还
- Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (refundAndOtherMoney != null)
- {
- _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
- _detail.PriceNameContent = refundAndOtherMoney.PriceName;
- }
- break;
- case 751://酒店早餐
- break;
- case 1015://超支费用
- Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
- if (groupExtraCost != null) {
- _detail.PriceNameContent = groupExtraCost.PriceName;
- _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
- }
- break;
- default:
- break;
- }
- /*
- * 申请人
- */
- string operatorName = " - ";
- Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
- if (_opUser != null)
- {
- operatorName = _opUser.CnName;
- }
- _detail.OperatorName = operatorName;
- /*
- * 审核人
- */
- string auditOperatorName = "Unknown";
- if (entity.AuditGMOperate == 0)
- auditOperatorName = " - ";
- else if (entity.AuditGMOperate == 4)
- auditOperatorName = "自动审核";
- else
- {
- Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
- if (_adUser != null)
- {
- auditOperatorName = _adUser.CnName;
- }
- }
- _detail.AuditOperatorName = auditOperatorName;
- /*
- * 超预算比例
- */
- string overBudgetStr = "";
- if (entity.ExceedBudget == -1)
- overBudgetStr = sdPriceName.Name + "尚无预算";
- else if (entity.ExceedBudget == 0)
- overBudgetStr = "未超预算";
- else
- overBudgetStr = entity.ExceedBudget.ToString("P");
- _detail.OverBudget = overBudgetStr;
- /*
- * 费用总计
- */
- ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
- {
- CurrencyId = entity.PaymentCurrency,
- CurrencyName = PaymentCurrency_WaitPay,
- AmountPayable = entity.PayMoney,
- ThisPayment = CurrPayStr,
- BalancePayment = BalanceStr,
- AuditedFunds = CurrPayStr
- });
- _detail.IsAuditGM = entity.IsAuditGM;
- detailList.Add(_detail);
- }
- #endregion
- _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
- /*
- * 下方描述处理
- */
- List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
- CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
- if (ccpCurrencyPrice != null)
- {
- int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
- nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
- }
- else
- {
- nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
- }
- string amountPayableStr = string.Format(@"应付款总金额: ");
- string thisPaymentStr = string.Format(@"此次付款总金额: ");
- string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
- string auditedFundsStr = string.Format(@"已审费用总额: ");
- foreach (var item in nonDuplicat)
- {
- var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
- if (strs.Count > 0)
- {
- decimal amountPayable = strs.Sum(it => it.AmountPayable);
- decimal balancePayment = strs.Sum(it => it.BalancePayment);
- amountPayableStr += string.Format(@"{0}{1} |", amountPayable.ToString("#0.00"), item.CurrencyName);
- //单独处理此次付款金额
- if (item.CurrencyId == 836) //人民币
- {
- decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
- thisPaymentStr += string.Format(@"{0}{1} |", thisPayment.ToString("#0.00"), item.CurrencyName);
- }
- else
- {
- thisPaymentStr += string.Format(@"{0}{1} |", "0.00", item.CurrencyName);
- }
- balancePaymentStr += string.Format(@"{0}{1} |", balancePayment.ToString("#0.00"), item.CurrencyName);
- //单独处理已审核费用
- if (item.CurrencyId == 836) //人民币
- {
- decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
- auditedFundsStr += string.Format(@"{0}{1} |", auditedFunds.ToString("#0.00"), item.CurrencyName);
- }
- else
- {
- auditedFundsStr += string.Format(@"{0}{1} |", "0.00", item.CurrencyName);
- }
- }
- }
- _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
- _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
- _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
- _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
- var _view1 = new
- {
- PageFuncAuth = pageFunAuthView,
- Data = _view
- };
- return Ok(JsonView(_view1));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 费用审核
- /// 修改团组费用审核状态
- /// </summary>
- /// <param name="_dto">参数Json字符串</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
- #endregion
- #region 页面操作权限验证
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
- #endregion
- List<string> idList = _dto.CreditIdStr.Split(',').ToList();
- Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
- DateTime dtNow = DateTime.Now;
- _groupRepository.BeginTran();
- int rst = 0;
- var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
- var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
- var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
- List<dynamic> msgDatas = new List<dynamic>();
- foreach (var item in idList)
- {
- int CreditId = int.Parse(item);
- var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
- .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
- .SetColumns(it => it.AuditGMOperate == _dto.UserId)
- .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
- .Where(s => s.Id == CreditId)
- .ExecuteCommandAsync();
- if (result < 1)
- {
- rst = -1;
- _groupRepository.RollbackTran();
- return Ok(JsonView(false, "操作失败并回滚!"));
- }
- var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
- if (creditData != null)
- {
- string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
- string groupNameStr = string.Empty;
- var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
- if (groupData != null) groupNameStr = groupData.TeamName;
- string creditTypeStr = string.Empty;
- var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
- if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
- string creditCurrency = string.Empty;
- var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
- if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
- if (creditCurrency.Equals("CNY"))
- {
- creditData.DayRate = 1.0000M;
- }
- if (creditData.PayPercentage == 0.00M)
- {
- creditData.PayPercentage = 100M;
- }
- decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
- string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
- string msgContent = "";
- if (creditCurrency.Equals("CNY"))
- {
- msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
- }
- else
- {
- msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
- }
- msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
- }
- }
- if (rst == 0)
- {
- _groupRepository.CommitTran();
- foreach (var item in msgDatas)
- {
- //发送消息
- GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
- }
- return Ok(JsonView(true, "操作成功!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- #endregion
- #region 机票费用录入
- /// <summary>
- /// 机票录入当前登录人可操作团组
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机票费用录入列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据id查询费用录入信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.AirTicketResById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 机票费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
-
- /// <summary>
- /// 根据舱位类型查询接团客户名单信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
- {
- try
- {
- List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
- if (crm_Groups.Count != 0)
- {
- List<dynamic> Customer = new List<dynamic>();
- foreach (var item in crm_Groups)
- {
- var data = new
- {
- Id = item.Id,
- Pinyin = item.Pinyin,
- Name = item.LastName + item.FirstName
- };
- Customer.Add(data);
- }
- return Ok(JsonView(true, "查询成功!", Customer));
- }
- return Ok(JsonView(true, "暂无数据", crm_Groups));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据团号获取客户信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
- {
- var jw = JsonView(false);
- if (dto.DIID < 1)
- {
- jw.Msg += "请输入正确的diid";
- return Ok(jw);
- }
- var arr = getSimplClientList(dto.DIID);
- jw = JsonView(true, "获取成功!", arr);
- return Ok(jw);
- }
- private List<SimplClientInfo> getSimplClientList(int diId) {
- 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);
- List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
- return arr;
- }
- private string getClientNameStr(List<SimplClientInfo> list, string origin) {
- string result = origin;
- if (Regex.Match(origin, @"\d+,?").Value.Length > 0) {
- string[] temparr = origin.Split(',');
- string fistrStr = temparr[0];
- int count = temparr.Count();
- int tempId;
- bool success = int.TryParse(fistrStr, out tempId);
- if (success) {
- SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
- if (tempInfo != null) {
- if (count > 1)
- {
- result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
- }
- else {
- result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
- }
- }
- }
- }
- return result;
- }
- /// <summary>
- /// 机票费用录入,删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
- {
- try
- {
- var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (res)
- {
- var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- return Ok(JsonView(false, "删除失败!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 导出机票录入报表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- else
- {
- List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
- if (AirTicketReservations.Count != 0)
- {
- Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
- Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
- string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
- string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
- decimal countCost = 0;
- foreach (var item in AirTicketReservations)
- {
- if (item.BankType == "其他")
- {
- item.BankNo = "--";
- }
- else
- {
- item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
- }
- item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
- item.Price = System.Decimal.Round(item.Price, 2);
- countCost += Convert.ToDecimal(item.Price);
- }
- designer.SetDataSource("Export", AirTicketReservations);
- designer.SetDataSource("ExportDiCode", diCode);
- designer.SetDataSource("ExportDiName", diName);
- designer.SetDataSource("ExportOpUserName", _Users.CnName);
- designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
- designer.Process();
- string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
- designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
- string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
- return Ok(JsonView(true, "成功", url = rst));
- }
- else
- {
- return Ok(JsonView(false, "暂无数据!"));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- Dictionary<string, string> transDic = new Dictionary<string, string>();
- /// <summary>
- /// 行程单导出
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
- {
- try
- {
- Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- else
- {
- List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
- if (dto.Language == "CN")
- {
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- int tableIndex = 0;//表格索引
- //得到文档中的第一个表格
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
- foreach (var item in _AirTicketReservations)
- {
- #region 处理固定数据
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- if (!name.Contains(clientName))
- {
- name += clientName + ",";
- }
- }
- if (!string.IsNullOrWhiteSpace(name))
- {
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- #endregion
- #region 循环数据处理
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- string starCity = "";
- if (star_Three != null)
- {
- starCity = star_Three.AirPort;
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- string EndCity = "";
- if (End_Three != null)
- {
- EndCity = End_Three.AirPort;
- }
- air.Destination = starCity + "/" + EndCity;
- air.Flight = FlightsCode[i];
- air.SeatingClass = item.CTypeName;
- string dateTime = tempstr[2];
- string DateTemp = dateTime.Substring(2, 5).ToUpper();
- air.FlightDate = DateTemp;
- air.DepartureTime = tempstr[5];
- air.LandingTime = tempstr[6];
- air.ValidityPeriod = DateTemp + "/" + DateTemp;
- air.TicketStatus = "--";
- air.Luggage = "--";
- air.DepartureTerminal = "--";
- air.LandingTerminal = "--";
- airs.Add(air);
- }
- int row = 13;
- for (int i = 0; i < airs.Count; i++)
- {
- if (airs.Count > 2)
- {
- for (int j = 0; j < airs.Count - 2; j++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.Add(CopyRow);
- }
- }
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
- int index = 0;
- foreach (PropertyInfo property in properties)
- {
- string value = property.GetValue(airs[i]).ToString();
- Cell ishcel0 = table.Rows[row].Cells[index];
- Paragraph p = new Paragraph(doc);
- string s = value;
- p.AppendChild(new Run(doc, s));
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
- ishcel0.AppendChild(p);
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
- index++;
- }
- row++;
- }
- #endregion
- Paragraph lastParagraph = new Paragraph(doc);
- //第一个表格末尾加段落
- table.ParentNode.InsertAfter(lastParagraph, table);
- //复制第一个表格
- Table cloneTable = (Table)table.Clone(true);
- //在文档末尾段落后面加入复制的表格
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
- {
- int rownewsIndex = 13;
- for (int i = 0; i < 2; i++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.RemoveAt(13);
- table.Rows.Add(CopyRow);
- rownewsIndex++;
- }
- }
- else
- {
- table.Rows.RemoveAt(12);
- }
- cloneTable.Rows.RemoveAt(12);
- }
- if (_AirTicketReservations.Count != 0)
- {
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- if (!name.Contains(clientName))
- {
- name += clientName + ",";
- }
- }
- if (!string.IsNullOrWhiteSpace(name))
- {
- table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- }
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
- //保存合并后的文档
- string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
- return Ok(JsonView(true, "成功!", rst));
- }
- else
- {
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- int tableIndex = 0;//表格索引
- //得到文档中的第一个表格
- Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
- List<string> texts = new List<string>();
- foreach (var item in _AirTicketReservations)
- {
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- if (!transDic.ContainsKey(_AirCompany.CnName))
- {
- transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
- }
- }
- else
- {
- if (!transDic.ContainsKey("--"))
- {
- transDic.Add("--", "--");
- }
- }
- }
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string name = "";
- foreach (string clientName in nameArray)
- {
- name += clientName + ",";
- }
- if (!texts.Contains(name))
- {
- texts.Add(name);
- }
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- if (star_Three != null)
- {
- if (!transDic.ContainsKey(star_Three.AirPort))
- {
- transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
- }
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- if (End_Three != null)
- {
- if (!transDic.ContainsKey(End_Three.AirPort))
- {
- transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
- }
- }
- if (!texts.Contains(item.CTypeName))
- {
- texts.Add(item.CTypeName);
- }
- }
- }
- List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
- if (transData.Count > 0)
- {
- foreach (TranslateResult item in transData)
- {
- if (!transDic.ContainsKey(item.Query))
- {
- transDic.Add(item.Query, item.Translation);
- }
- }
- }
- foreach (var item in _AirTicketReservations)
- {
- #region 处理固定数据
- string[] FlightsCode = item.FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["AirlineCompany"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string names = "";
- foreach (string clientName in nameArray)
- {
- names += clientName + ",";
- }
- if (!string.IsNullOrWhiteSpace(names))
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["ClientName"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- #endregion
- #region 循环数据处理
- List<AirInfo> airs = new List<AirInfo>();
- string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
- DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
- for (int i = 0; i < FlightsCode.Length; i++)
- {
- AirInfo air = new AirInfo();
- string[] tempstr = DayArray[i]
- .Replace("\r\n", string.Empty)
- .Replace("\\r\\n", string.Empty)
- .TrimStart().TrimEnd()
- .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
- Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
- string starCity = "";
- if (star_Three != null)
- {
- string str2 = "--";
- string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult2))
- {
- str2 = translateResult2;
- str2 = _airTicketResRep.Processing(str2);
- }
- starCity = str2;
- }
- Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
- string EndCity = "";
- if (End_Three != null)
- {
- string str1 = "--";
- string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult1))
- {
- str1 = translateResult1;
- str1 = _airTicketResRep.Processing(str1);
- }
- EndCity = str1;
- }
- air.Destination = starCity + "/" + EndCity;
- air.Flight = FlightsCode[i];
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- air.SeatingClass = str;
- string dateTime = tempstr[2];
- string DateTemp = dateTime.Substring(2, 5).ToUpper();
- air.FlightDate = DateTemp;
- air.DepartureTime = tempstr[5];
- air.LandingTime = tempstr[6];
- air.ValidityPeriod = DateTemp + "/" + DateTemp;
- air.TicketStatus = "--";
- air.Luggage = "--";
- air.DepartureTerminal = "--";
- air.LandingTerminal = "--";
- airs.Add(air);
- }
- int row = 13;
- for (int i = 0; i < airs.Count; i++)
- {
- if (airs.Count > 2)
- {
- for (int j = 0; j < airs.Count - 2; j++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.Add(CopyRow);
- }
- }
- PropertyInfo[] properties = airs[i].GetType().GetProperties();
- int index = 0;
- foreach (PropertyInfo property in properties)
- {
- string value = property.GetValue(airs[i]).ToString();
- Cell ishcel0 = table.Rows[row].Cells[index];
- Paragraph p = new Paragraph(doc);
- string s = value;
- p.AppendChild(new Run(doc, s));
- p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
- ishcel0.AppendChild(p);
- ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
- //ishcel0.CellFormat.VerticalAlignment=
- index++;
- }
- row++;
- }
- #endregion
- Paragraph lastParagraph = new Paragraph(doc);
- //第一个表格末尾加段落
- table.ParentNode.InsertAfter(lastParagraph, table);
- //复制第一个表格
- Table cloneTable = (Table)table.Clone(true);
- //在文档末尾段落后面加入复制的表格
- table.ParentNode.InsertAfter(cloneTable, lastParagraph);
- if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
- {
- int rownewsIndex = 13;
- for (int i = 0; i < 2; i++)
- {
- var CopyRow = table.Rows[12].Clone(true);
- table.Rows.RemoveAt(13);
- table.Rows.Add(CopyRow);
- rownewsIndex++;
- }
- }
- else
- {
- table.Rows.RemoveAt(12);
- }
- cloneTable.Rows.RemoveAt(12);
- }
- if (_AirTicketReservations.Count != 0)
- {
- string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
- if (FlightsCode.Length != 0)
- {
- Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
- if (_AirCompany != null)
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["AirlineCompany"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["AirlineCompany"].Text = "--";
- }
- }
- table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
- table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
- string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
- nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
- string names = "";
- foreach (string clientName in nameArray)
- {
- names += clientName + ",";
- }
- if (!string.IsNullOrWhiteSpace(names))
- {
- string str = "--";
- string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
- if (!string.IsNullOrEmpty(translateResult))
- {
- str = translateResult;
- str = _airTicketResRep.Processing(str);
- }
- table.Range.Bookmarks["ClientName"].Text = str;
- }
- else
- {
- table.Range.Bookmarks["ClientName"].Text = "--";
- }
- table.Range.Bookmarks["TicketNumber"].Text = "--";
- table.Range.Bookmarks["IdentificationCode"].Text = "--";
- table.Range.Bookmarks["JointTicket"].Text = "--";
- table.Range.Bookmarks["TimeIssue"].Text = "--";
- table.Range.Bookmarks["DrawingAgent"].Text = "--";
- table.Range.Bookmarks["NavigationCode"].Text = "--";
- table.Range.Bookmarks["AgentsAddress"].Text = "--";
- table.Range.Bookmarks["AgentPhone"].Text = "--";
- table.Range.Bookmarks["AgentFacsimile"].Text = "--";
- }
- doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
- //保存合并后的文档
- string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
- string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
- doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
- return Ok(JsonView(true, "成功!", rst));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 团组增减款项 --> 其他款项
- /// <summary>
- /// 团组增减款项下拉框绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
- #endregion
- //var groupData = await GeneralMethod.PostOperationAuthReturnGroupInfosAsync(dto.UserId, dto.CTId);
- ////支付方式
- //List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
- //List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
- //var data = new
- //{
- // Payment = _Payment,
- // GroupName = groupData,
- //};
- var res = await _decreasePaymentsRep.DecreasePaymentsSelect(dto);
- if (res.Code != 0)
- {
- return Ok(JsonView(false, res.Msg));
- }
- return Ok(JsonView(true, "操作成功!", res.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据团组Id查询团组增减款项
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
- #endregion
- Result groupData = await _decreasePaymentsRep.DecreasePaymentsList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- /// <summary>
- /// 团组增减款项操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
- {
- try
- {
- Result groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组增减款项操作 删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
- {
- try
- {
- var res = await _decreasePaymentsRep.SoftDeleteByIdAsync<Grp_DecreasePayments>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 98).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 根据团组增减款项Id查询
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
- {
- try
- {
- Result groupData = await _decreasePaymentsRep.QueryDecreasePaymentsById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 文件上传、删除
- /// <summary>
- /// region 文件上传 可以带参数
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadProject(IFormFile file)
- {
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = "";
- if (TypeName == "A")//A代表团组增减款项
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
- }
- else if (TypeName == "B")//B代表商邀相关文件
- {
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
- }
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 删除指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFile(DelFileDto dto)
- {
- try
- {
- var TypeName = Request.Headers["TypeName"].ToString();
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- int id = 0;
- if (TypeName == "A")
- {
- filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
- }
- else if (TypeName == "B")
- {
- filePath = fileDir + "/商邀相关文件/" + dto.fileName;
- // 删除该文件
- System.IO.File.Delete(filePath);
- id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
- }
- if (id != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 商邀费用录入
- /// <summary>
- /// 根据团组Id查询商邀费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- //
- /// <summary>
- /// 商邀费用 Info Page 基础数据源
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, "操作成功", groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 根据商邀费用ID查询C表和商邀费用数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
-
- /// <summary>
- /// 商邀费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
- {
- try
- {
- Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto,_setDataRep.PostCurrencyByDiid);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 商邀删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
- {
- try
- {
- _sqlSugar.BeginTran();
- var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
- .SetColumns(it => new Grp_InvitationOfficialActivities()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(it => it.Id == dto.Id)
- .ExecuteCommand();
- if (res1 > 0)
- {
- int _diId = 0;
- var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
- if (_ioaInfo!=null)
- {
- _diId = _ioaInfo.DiId;
- }
- var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
- .SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- })
- .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81 )
- .ExecuteCommand();
- if (res2 > 0)
- {
- _sqlSugar.CommitTran();
- return Ok(JsonView(true, "删除成功!"));
- }
- }
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, "删除失败"));
- }
- catch (Exception ex)
- {
- _sqlSugar.RollbackTran();
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 团组英文资料
- /// <summary>
- /// 查询团组英文所有资料
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
- {
- try
- {
- Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组英文资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
- {
- try
- {
- Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组英文资料Id查询数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
- {
- try
- {
- Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
- if (_DelegationEnData != null)
- {
- return Ok(JsonView(true, "查询成功!", _DelegationEnData));
- }
- return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 团组英文资料删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
- {
- try
- {
- var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 导出邀请函
- /// <summary>
- /// 导出邀请函页面初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
- {
- try
- {
- List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
- List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
- if (dto.DiId == 0)
- {
- crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
- }
- else
- {
- crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
- }
- return Ok(JsonView(true, "查询成功!", new
- {
- deleClient = crm_Deles,
- delegations = grp_Delegations
- }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 导出邀请函
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
- {
- #region 参数验证
- //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
- if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
- #endregion
- try
- {
- Dictionary<string, string> transDic = new Dictionary<string, string>();
- string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
- tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
- From Grp_TourClientList tcl
- Left Join
- (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
- cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
- cc2.Area,cc2.IssueDt,cc2.ExpiryDt
- From Crm_DeleClient dc
- Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
- Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
- Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
- Where dc.IsDel = 0) temp
- On temp.DcId =tcl.ClientId
- Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
- var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
- List<string> texts = new List<string>();
- if (datas.Count != 0)
- {
- foreach (TourClientListDetailsView item in datas)
- {
- if (!string.IsNullOrWhiteSpace(item.Pinyin))
- {
- transDic.Add(item.LastName + item.FirstName, item.Pinyin);
- }
- else
- {
- string name = item.LastName + item.FirstName;
- texts.Add(name);
- }
- if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
- {
- if (!transDic.ContainsKey(item.Job))
- {
- texts.Add(item.Job);
- }
- }
- if (!string.IsNullOrEmpty(item.CompanyFullName))
- {
- texts.Add(item.CompanyFullName);
- }
- }
- List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
- if (transData.Count > 0)
- {
- foreach (TranslateResult item in transData)
- {
- if (!transDic.ContainsKey(item.Query))
- {
- transDic.Add(item.Query, item.Translation);
- }
- }
- }
- List<GuestList> list = new List<GuestList>();
- foreach (TourClientListDetailsView dele in datas)
- {
- GuestList guestList = new GuestList();
- if (!string.IsNullOrWhiteSpace(dele.Pinyin))
- {
- guestList.Name = dele.Pinyin;
- }
- else
- {
- string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
- guestList.Name = Name;
- }
- if (dele.Sex == 0)
- {
- guestList.Sex = "Male";
- }
- else if (dele.Sex == 1)
- {
- guestList.Sex = "Female";
- }
- guestList.DOB = dele.BirthDay.Replace('-', '.');
- if (!string.IsNullOrEmpty(dele.Job))
- {
- guestList.Job = dele.Job;
- }
- list.Add(guestList);
- }
- //载入模板
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < list.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(list[i].Name.ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(list[i].Sex.ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(list[i].DOB.ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(list[i].Job.ToString());
- }
- //删除多余行
- while (tableOne.Rows.Count > list.Count + 1)
- {
- tableOne.Rows.RemoveAt(list.Count + 1);
- }
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
- string filePath = fileDir + $@"商邀相关文件/{fileName}";
- doc.Save(filePath);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else
- {
- return Ok(JsonView(false, "该团组客户名单暂未录入!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- #endregion
- #region 团组经理模块 出入境费用
- ///// <summary>
- ///// 团组模块 - 出入境费用
- ///// </summary>
- ///// <returns></returns>
- //[HttpPost]
- //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
- //{
- // try
- // {
- // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
- // if (data.Code != 0)
- // {
- // return Ok(JsonView(false, data.Msg));
- // }
- // return Ok(JsonView(true, "查询成功!"));
- // }
- // catch (Exception ex)
- // {
- // return Ok(JsonView(false, ex.Message));
- // throw;
- // }
- //}
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> SetDayAndCostAreaChange()
- {
- try
- {
- var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
- var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
- var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
- var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
- foreach (var item in unite) //处理交集数据
- {
- dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
- }
- foreach (var item in merge) //处理差集数据
- {
- int nationalTravelFeeId = 0;
- var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
- if (cityData != null) nationalTravelFeeId = cityData.Id;
- else
- {
- var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
- if (countryData != null) nationalTravelFeeId = countryData.Id;
- }
- dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
- }
- //只更新dayAndCost 的 nationalTravelFeeId;
- var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
- if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
- else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
- {
- try
- {
- var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
- string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
- //SetDataInfoView
- var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
- var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
- List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
- var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
- List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
- var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
- List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
- //默认币种显示
- List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
- {
- new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 0.0000M },
- new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 0.0000M },
- new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 0.0000M },
- new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0000M },
- new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.0000M },
- };
- var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
- if (_currencyRate.Count > 0)
- {
- foreach (var item in _currencyInfos)
- {
- var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
- if (rateInfo != null)
- {
- item.Rate = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
- }
- }
- }
- return Ok(JsonView(true, "查询成功!", new
- {
- GroupNameData = groupNameData.Data,
- CurrencyData = _CurrencyData,
- WordTypeData = _WordTypeData,
- ExcelTypeData = _ExcelTypeData,
- CurrencyInit = _currencyInfos
- }));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Info
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "查询成功!", data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - Add And Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - File downlaod
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
- {
- try
- {
- if (dto.DiId < 1)
- {
- return Ok(JsonView(false, "请传入有效的DiId参数;"));
- }
- if (dto.ExportType <1)
- {
- return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
- }
- if (dto.SubTypeId < 1)
- {
- return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
- 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
- 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
- 3 团组成员名单 1 团组成员名单"));
- }
- var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
- var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_EnterExitCosts == null)
- {
- return Ok(JsonView(false, "该团组未填写出入境费用;"));
- }
- //数据源
- List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
- List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
- List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
- List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
- var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
- var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
- var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
- .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
- .LeftJoin<Crm_CustomerCompany>((tcl, dc,cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
- .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
- .Select((tcl, dc, cc) => new
- {
- Name = dc.LastName + dc.FirstName,
- Sex = dc.Sex,
- Birthday = dc.BirthDay,
- Company = cc.CompanyFullName,
- Job = dc.Job
- })
- .ToList();
- var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
- var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
- var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
- var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
- if (dto.ExportType == 1) //明细表
- {
- if (dto.SubTypeId == 1005) //1005(默认明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
- decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
- decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
- decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
- decimal insidePayTotal = _EnterExitCosts.InsidePay;
- string row1_1 = "";
- if (_EnterExitCosts.Visa > 0)
- {
- //insidePayTotal += _EnterExitCosts.Visa;
- row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
- if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
- {
- row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
- }
- }
- string row1_2 = "";
- if (_EnterExitCosts.YiMiao > 0)
- {
- //insidePayTotal += _EnterExitCosts.YiMiao;
- row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.HeSuan > 0)
- {
- //insidePayTotal += _EnterExitCosts.HeSuan;
- row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Service > 0)
- {
- //insidePayTotal += _EnterExitCosts.Service;
- row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
- }
- string row1_3 = "";
- if (_EnterExitCosts.Safe > 0)
- {
- //insidePayTotal += _EnterExitCosts.Safe;
- row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
- }
- if (_EnterExitCosts.Ticket > 0)
- {
- //insidePayTotal += _EnterExitCosts.Ticket;
- row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
- }
- string row1 = "";
- if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
- if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
- if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
- dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
- dic.Add("Row1Str", row1);
- dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
- dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
- dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
- dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
- dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
- string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
- dic.Add("SubGZF", miscellaneousFeeTotalStr);
- //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
- decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
- decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
- dic.Add("SubJJC", subJJC.ToString("#0.00"));
- dic.Add("SubGWC", subGWC.ToString("#0.00"));
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- #region 填充word表格内容
- ////获读取指定表格方法二
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- for (int i = 0; i < dac1.Count; i++)
- {
- Grp_DayAndCost dac = dac1[i];
- if (dac == null) continue;
- builder.MoveToCell(0, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "晚:");
- builder.MoveToCell(0, i, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- builder.Write(dac.Place == null ? "" : dac.Place);
- builder.MoveToCell(0, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(0, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(0, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(0, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table1.Rows.Count > dac1.Count)
- {
- table1.Rows.RemoveAt(dac1.Count);
- }
- Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
- for (int i = 0; i < dac2.Count; i++)
- {
- Grp_DayAndCost dac = dac2[i];
- if (dac == null) continue;
- builder.MoveToCell(1, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(1, i, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- builder.MoveToCell(1, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(1, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(1, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(1, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table2.Rows.Count > dac2.Count)
- {
- table2.Rows.RemoveAt(dac2.Count);
- }
- Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
- for (int i = 0; i < dac3.Count; i++)
- {
- Grp_DayAndCost dac = dac3[i];
- if (dac == null) continue;
- builder.MoveToCell(2, i, 0, 0);
- builder.Write("第" + dac.Days.ToString() + "天:");
- builder.MoveToCell(2, i, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
- builder.MoveToCell(2, i, 2, 0);
- builder.Write("费用标准:");
- string curr = "";
- var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
- if (currData != null)
- {
- curr = currData.Name;
- }
- builder.MoveToCell(2, i, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00") + curr);
- builder.MoveToCell(2, i, 4, 0);
- builder.Write("费用小计:");
- builder.MoveToCell(2, i, 5, 0);
- builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
- }
- //删除多余行
- while (table3.Rows.Count > dac3.Count)
- {
- table3.Rows.RemoveAt(dac3.Count);
- }
- #endregion
- //文件名
- string strFileName = _DelegationInfo.TeamName + "出入境费用.docx";
- //文件流下载
- //byte[] bytes = null;
- //using (MemoryStream stream = new MemoryStream())
- //{
- // doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- // bytes = stream.ToArray();
- //}
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- return Ok(JsonView(true, "成功", new { Url = url }));
- }
- else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- {
- List<string> list = new List<string>();
- try
- {
- var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- foreach (var item in spilitArr)
- {
- var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var depCode = spDotandEmpty[2].Substring(0, 3);
- var arrCode = spDotandEmpty[2].Substring(3, 3);
- string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
- arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
- list.Add(depName);
- list.Add(arrName);
- }
- list = list.Distinct().ToList();
- dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- }
- catch (Exception)
- {
- dic.Add("ReturnCode", "行程录入不正确!");
- }
- }
- else
- {
- dic.Add("ReturnCode", "未录入行程!");
- }
- dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- {
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- }
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- dic.Add("Names", Names);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal dac1totalPrice = 0.00M;
- int accommodationStartIndex = 6, foodandotherStartIndex = 22;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0.00M)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- foodandotherStartIndex--;
- }
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknown" ;
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = 0.00M;
- rate = rateDatas.Find(it => it.CurrencyCode.Equals(currency))?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
- for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
- {
- table1.Rows.RemoveAt(i - 1);
- }
- dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
- dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
- dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
- dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- return Ok(JsonView(true, "成功", new { Url = url }));
- }
- else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
- //载入模板
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(tempPath);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
- {
- List<string> list = new List<string>();
- try
- {
- var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
- foreach (var item in spilitArr)
- {
- var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var depCode = spDotandEmpty[2].Substring(0, 3);
- var arrCode = spDotandEmpty[2].Substring(3, 3);
- string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
- arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
- list.Add(depName);
- list.Add(arrName);
- }
- list = list.Distinct().ToList();
- dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
- }
- catch (Exception)
- {
- dic.Add("ReturnCode", "行程录入不正确!");
- }
- }
- else
- {
- dic.Add("ReturnCode", "未录入行程!");
- }
- dic.Add("ReturnCodeAir", dic["ReturnCode"]);
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
- {
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- }
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
- designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
- designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
- designer.SetDataSource("Group", _DelegationInfo.TeamName);
- designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
- designer.SetDataSource("Name", Names);
- designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
- designer.SetDataSource("Day", dic["Day"] + "天");
- designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
- designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
- int startIndex = 10;
- const int startIndexcopy = 10;
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- DataTable dtdac1 = new DataTable();
- List<string> place = new List<string>();
- dtdac1.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB"},
- });
- DataTable dtdac2 = new DataTable();
- dtdac2.Columns.AddRange(new DataColumn[] {
- new DataColumn(){ ColumnName = "city"},
- new DataColumn(){ ColumnName = "curr"},
- new DataColumn(){ ColumnName = "criterion"},
- new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
- new DataColumn(){ ColumnName = "cost", DataType = typeof(float)},
- new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
- new DataColumn(){ ColumnName = "costRMB"},
- });
- dtdac1.TableName = "tb1";
- dtdac2.TableName = "tb2";
- decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
- foreach (var item in dac1)
- {
- item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac1.NewRow();
- row["city"] = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate;
- row["criterion"] = item.Cost;
- row["number"] = 1;
- row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
- //row["costRMB"] = rbmPrice;
- dtdac1.Rows.Add(row);
- place.Add(item.Place);
- }
- place = new List<string>();
- foreach (var item in dac2)
- {
- item.Place = placeData.Find(it => it.Id == item.NationalTravelFeeId)?.Country ?? "Unknown";
- if (place.Contains(item.Place))
- {
- continue;
- }
- DataRow row = dtdac2.NewRow();
- row["city"] = item.Place;
- string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Name ?? "Unknwon";
- decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
- row["curr"] = currency;
- row["rate"] = rate;
- row["criterion"] = item.Cost;
- row["number"] = 1;
- row["day"] = dac2.FindAll(x => x.Place == item.Place).Count;
- //row["cost"] = item.SubTotal;
- //row["costRMB"] = rbmPrice;
- dtdac2.Rows.Add(row);
- place.Add(item.Place);
- //dac2totalPrice += rbmPrice;
- }
- dac1totalPrice = dac1.Sum(it => it.SubTotal);
- dac2totalPrice = dac2.Sum(it => it.SubTotal);
- designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
- designer.SetDataSource("dac2totalPrice", dac2totalPrice);
- string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元,公务舱:{_EnterExitCosts.OutsaideGWPay.ToString("#0.00")}元";
- string cellStr = $" 5.其他费用(签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,保险费 :{_EnterExitCosts.Safe.ToString("#0.00")}元)";
- decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + _EnterExitCosts.Visa + _EnterExitCosts.Safe;
- string celllastStr = $" 经审核,住宿费 {dac1totalPrice.ToString("#0.00")} 元,伙食费和公杂费 {dac2totalPrice.ToString(".00")} 元,培训费 元,国际旅费 {(_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00")} 元,其他费用 {(_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00")} 元,本次出国经费预算合计为 {s.ToString("#0.00")} 元。其中:市本级安排 。";
- designer.SetDataSource("cell4Str", cell4Str);
- designer.SetDataSource("cellStr", cellStr);
- designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
- designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
- designer.SetDataSource("celllastStr", celllastStr);
- Workbook wb = designer.Workbook;
- var sheet = wb.Worksheets[0];
- //绑定datatable数据集
- designer.SetDataSource(dtdac1);
- designer.SetDataSource(dtdac2);
- designer.Process();
- var rowStart = dtdac1.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
- startIndex += 1; //总计行
- rowStart = dtdac2.Rows.Count;
- while (rowStart > 0)
- {
- sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
- sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
- startIndex++;
- rowStart--;
- }
- sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
- wb.CalculateFormula(true);
- //模板文件名
- string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
- designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- return Ok(JsonView(true, "成功", new { Url = url }));
- }
- }
- else if (dto.ExportType == 2) //表格
- {
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
- dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
- TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
- dic.Add("Day", sp.Days.ToString());
- dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
- if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- dic.Add("TeamName", _DelegationInfo.TeamName);
- dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
- dic.Add("TellPhone", _DelegationInfo.TellPhone);
- dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
- dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- int rowCount = 10;//总人数行
- int startRowIndex = 7; //起始行
- for (int i = 0; i < DeleClientList.Count; i++)
- {
- builder.MoveToCell(0, startRowIndex, 0, 0);
- builder.Write(DeleClientList[i].Name); //出国人员姓名
- builder.MoveToCell(0, startRowIndex, 1, 0);
- string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
- builder.Write(sex);//性别
- builder.MoveToCell(0, startRowIndex, 2, 0);
- builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
- builder.MoveToCell(0, startRowIndex, 3, 0);
- builder.Write(DeleClientList[i].Company);//工作单位
- builder.MoveToCell(0, startRowIndex, 4, 0);
- builder.Write(DeleClientList[i].Job);//职务及级别
- builder.MoveToCell(0, startRowIndex, 5, 0);
- builder.Write("");//人员属性
- builder.MoveToCell(0, startRowIndex, 6, 0);
- builder.Write("");//上次出国时间
- startRowIndex++;
- }
- int nullRow = rowCount - DeleClientList.Count;//空行
- for (int i = 0; i < nullRow; i++)
- {
- table1.Rows.Remove(table1.Rows[startRowIndex]);
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- return Ok(JsonView(true, "成功", new { Url = url }));
- }
- else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
- {
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
- dic.Add("Names", Names);
- int accommodationStartIndex = 6;
- int foodandotherStartIndex = 19;//
- int accommodationRows = 12, foodandotherRows = 12;
- var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
- var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
- decimal dac1totalPrice = 0.00M;
- foreach (var dac in dac1)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
- //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
- builder.MoveToCell(0, accommodationStartIndex, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
- builder.MoveToCell(0, accommodationStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
- builder.Write(currency);//币种
- builder.MoveToCell(0, accommodationStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, accommodationStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, accommodationStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, accommodationStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, accommodationStartIndex, 7, 0);
- decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
- builder.Write(rate.ToString("#0.0000"));//汇率
- builder.MoveToCell(0, accommodationStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- accommodationStartIndex++;
- dac1totalPrice += rbmPrice;
- }
- dic.Add("dac1totalPrice", dac1totalPrice.ToString());
- if (dac2.Count == dac3.Count)//国家 币种 金额
- {
- for (int i = 0; i < dac2.Count; i++)
- {
- dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
- dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
- }
- }
- decimal dac2totalPrice = 0.00M;
- foreach (var dac in dac2)
- {
- if (dac.SubTotal == 0)
- {
- continue;
- }
- builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
- builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");//城市
- builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
- string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Name ?? "Unknwon";
- builder.Write(currency);//币种
- builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
- builder.Write(dac.Cost.ToString("#0.00"));//标准
- builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
- builder.Write("");//人数
- builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
- builder.Write("");//天数
- builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
- builder.Write(dac.SubTotal.ToString("#0.00"));//小计
- builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
- decimal rate = rateDatas.Find(it => it.CurrencyCode == currency)?.Rate ?? 0.00M;
- builder.Write(rate.ToString());//汇率
- builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
- decimal rbmPrice = rate * dac.SubTotal;
- builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
- foodandotherStartIndex++;
- dac2totalPrice += rbmPrice;
- }
- dic.Add("dac2totalPrice", dac2totalPrice.ToString());
- //删除空行
- if (dac1.Count < accommodationRows)
- {
- int nullRow = accommodationRows - dac1.Count;
- }
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //模板文件名
- string strFileName = $"省级单位出(境)经费报销单.docx";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- return Ok(JsonView(true, "成功", new { Url = url }));
- }
- }
- else if (dto.ExportType == 3)
- {
- if (dto.SubTypeId == 1) //团组成员名单
- {
- if (DeleClientList.Count < 1)
- {
- return Ok(JsonView(false, "团组成员暂未录入!!!"));
- }
- //获取模板
- string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
- //载入模板
- Document doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < DeleClientList.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(DeleClientList[i].Name);
- builder.MoveToCell(0, i + 1, 1, 0);
- string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
- builder.Write(sex);
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(DeleClientList[i].Company);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(DeleClientList[i].Job);
- }
- //删除多余行
- while (tableOne.Rows.Count > DeleClientList.Count + 1)
- {
- tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
- }
- string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
- return Ok(JsonView(true, "成功", new { Url = url }));
- }
- }
- return Ok(JsonView(false,"操作失败!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 明细表导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境费用 - 子项删除
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
- {
- try
- {
- Stopwatch sw = new Stopwatch();
- sw.Start();
- string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0");
- var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
- //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
- //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
- //foreach (var item in nationalTravel)
- //{
- // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
- // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
- // if (otherData != null)
- // {
- // cityData.Remove(otherData);
- // cityData.Add(otherData);
- // }
- // nationalTravelFeeData1.Add(new
- // {
- // Country = item.Country,
- // CityData = cityData
- // });
- //}
- sw.Stop();
- return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- throw;
- }
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 Page List Data Source
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetNationalTravelFeePageDataSource()
- {
- string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
- List<string> countryData = new List<string>();
- countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
- countryData = countryData.Distinct().ToList();
- List<dynamic> dataSource = new List<dynamic>();
- foreach (var item in countryData)
- {
- List<string> cityData1 = new List<string>();
- cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
- var countryData2 = new
- {
- CountryName = item,
- CityData = cityData1
- };
- dataSource.Add(countryData2);
- }
- return Ok(JsonView(true, "查询成功!", dataSource));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 Page List
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
- {
- int portId = dto.PortType;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
- if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
- string whereSql = string.Empty;
- if (!string.IsNullOrEmpty(dto.Country))
- {
- whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
- }
- if (!string.IsNullOrEmpty(dto.City))
- {
- whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
- }
- string pageSql = string.Format(@"Select * From (
- Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
- ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
- From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0 {0} ) temp ", whereSql);
- RefAsync<int> total = 0;
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
- return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 根据城市查询
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请传入参数!"));
- int portId = dto.PortType;
- if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
- string whereSql = string.Empty;
- if (!string.IsNullOrEmpty(dto.Country))
- {
- whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
- }
- if (!string.IsNullOrEmpty(dto.City))
- {
- whereSql = string.Format(@"And City = '{0}' ", dto.City);
- }
- string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
- ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
- gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
- From Grp_NationalTravelFee gntf
- Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
- Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
- Where gntf.Isdel = 0 {0} ", whereSql);
- var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
- return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - Add Or Update
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
- {
- try
- {
- var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, "操作成功!", data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 团组模块 - 出入境国家费用标准 - Del
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
- {
- try
- {
- Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
- {
- Id = dto.Id,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
- IsDel = 1
- };
- var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
- .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
- .WhereColumns(it => new { it.Id })
- .ExecuteCommandAsync();
- if (delStatus <= 0)
- {
- return Ok(JsonView(false, "删除失败!"));
- }
- return Ok(JsonView(true, "操作成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 签证费用录入
- /// <summary>
- /// 根据diid查询签证费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
- {
- try
- {
- Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据签证费用Id查询单条数据及c表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
- {
- try
- {
- Result groupData = await _visaPriceRep.PostVisaById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 签证费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
- {
- try
- {
- var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 签证费用录入下拉框初始化
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> VisaPriceAddSelect()
- {
- try
- {
- //支付方式
- List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
- //币种
- List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
- //乘客类型
- List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
- //卡类型
- List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
- List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
- var data = new
- {
- Payment = _Payment,
- CurrencyList = _CurrencyList,
- PassengerType = _PassengerType,
- BankCard = _BankCard
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 签证费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
- {
- try
- {
- Result groupData = await _visaPriceRep.OpVisaPrice(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region op费用录入
- /// <summary>
- /// 根据diid查询op费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
- {
- try
- {
- Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据op费用Id查询单条数据及c表数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
- {
- try
- {
- Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
- Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
- var data = new
- {
- CarTouristGuideGround = _groupData,
- CreditCardPayment = _creditCardPayment
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- }
- }
- /// <summary>
- /// op费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
- {
- try
- {
- var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// op费用录入操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
- {
- try
- {
- Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 填写费用详细页面初始化绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
- {
- try
- {
- Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据op费用Id查询详细数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
- {
- try
- {
- Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// OP费用录入填写详情
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
- {
- try
- {
- Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 获取三公详细所有城市
- /// </summary>
- /// <returns></returns>
- [HttpGet]
- public IActionResult OpCarCityResult()
- {
- var jw = JsonView(false);
- var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x=>x.IsDel == 0).Select(x => new
- {
- x.Id,
- x.Country,
- x.City,
- }).ToList();
- if (data.Count > 0)
- {
- jw = JsonView(true, "获取成功!", data);
- }
- else
- {
- jw.Msg = "城市数据未空!";
- jw.Data = new string[0];
- }
- return Ok(jw);
- }
- #endregion
- #region 团组成本
- /// <summary>
- /// 团组成本数据初始化
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
- {
- var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
- Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
- WHEN COUNT(*) >= 0 THEN 'True'
- ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
- Where TeamName != '' And IsDel = 0 Order By a.Id Desc
- ").ToList(); //团组列表
- int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
- var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
- List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
- var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
- if (groupinfoValue != null)
- {
- var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
- var spArr = new string[1] { countryArr };
- if (countryArr.Contains("|"))
- {
- spArr = countryArr.Split("|");
- }
- else if (countryArr.Contains("、"))
- {
- spArr = countryArr.Split("、");
- }
- foreach (var item in spArr.Where(x=>!string.IsNullOrWhiteSpace(x)).ToList())
- {
- var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
- if (dbQueryCountry != null)
- {
- visaCountryInfoArr.Add(dbQueryCountry);
- }
- }
- }
- var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
- var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
- var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
- var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
- var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
- //GroupCostParameter.Add(new
- // Grp_GroupCostParameter());
- var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
- return Ok(JsonView(new
- {
- groupList,
- groupInfo,
- groupChecks,
- groupCost = groupCostMap,
- hotelNumber,
- GroupCostParameter = GroupCostParameterMap,
- visaCountryInfoArr = visaCountryInfoArr.Select(x => new
- {
- x.VisaCountry,
- x.VisaPrice,
- x.Id,
- }).ToList(),
- baoPi = _GroupCostParameterRepository.GetBaoPi(diid)
- }));
- }
- /// <summary>
- /// 团组成本信息保存
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
- {
- if (dto.Diid <= 0 || dto.Userid <= 0)
- {
- return Ok(JsonView(false));
- }
- JsonView jw = null;
- bool isTrue = false;
- var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
- Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
- var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
- Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
- var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
- var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
- try
- {
- _sqlSugar.BeginTran();
- isTrue = await _GroupCostRepository.
- SaveGroupCostList(Grp_groups, dto.Diid); //列表
- isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
- isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
- isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
- _sqlSugar.CommitTran();
- jw = JsonView(true, "保存成功!", isTrue);
- }
- catch (Exception)
- {
- _sqlSugar.RollbackTran();
- jw = JsonView(false);
- }
- return Ok(jw);
- }
- /// <summary>
- /// 司兼导数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetCarGuides(CarGuidesDto dto)
- {
- JsonView jw = null;
- var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 导游数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetGuidesInfo(CarGuidesDto dto)
- {
- JsonView jw = null;
- //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
- // 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
- // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
- var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 成本车数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetCarInfo(CarGuidesDto dto)
- {
- JsonView jw = null;
- var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
- jw = JsonView(true, "获取成功!", Data);
- return Ok(jw);
- }
- /// <summary>
- /// 景点数据
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
- {
- var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
- return Ok(JsonView(true, "获取成功!", Data));
- }
- /// <summary>
- /// 成本通知
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
- {
- if (dto.Diid < 0)
- {
- return Ok(JsonView(false));
- }
- JsonView jw = null;
- var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
- if (GroupCostParameter != null)
- {
- int IsShare = 0;
- if (GroupCostParameter.IsShare == 0) IsShare = 1;
- else if (GroupCostParameter.IsShare == 1) IsShare = 0;
- bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id,IsShare);
- string msg = string.Empty;
- if (isTrue)
- {
- if (IsShare == 0)
- {
- msg = "禁止通知,其他模块操作人员不可见此成本信息!";
- }
- else
- {
- msg = "通知成功,其他模块操作人员可见此成本信息!";
- }
- jw = JsonView(isTrue, msg);
- }
- else
- {
- msg = "修改失败!";
- jw = JsonView(isTrue, msg);
- }
- }
- else
- {
- jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
- }
- return Ok(jw);
- }
- /// <summary>
- /// 导出收款账单
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
- {
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di != null)
- {
- //文件名
- string strFileName = di.TeamName + "-收款账单.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
- //载入模板
- Document doc = new Document(tmppath);
- decimal TotalPrice = 0.00M;
- string itemStr = string.Empty;
- Dictionary<string, string> airSouer = new Dictionary<string, string>();
- //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
- airSouer.Add("JJCTBR", "经济舱及酒店双人间");
- airSouer.Add("JJCSGR", "经济舱及酒店单人间");
- airSouer.Add("GWCSGR", "公务舱及酒店单人间");
- airSouer.Add("GWCJSES", "公务舱及酒店小套房");
- airSouer.Add("GWCSUITE", "公务舱及酒店套房");
- airSouer.Add("JJCSUITE", "经济舱及酒店套房");
- var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x=>x.Key);
- foreach(var cost in groupCostType)
- {
- var List = cost.ToList();
- if (cost.Key == "A")
- {
- foreach (var ListItem in List)
- {
- if (ListItem.number > 0)
- {
- if (ListItem.code.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- TotalPrice += (ListItem.number * ListItem.price);
- }
- }
- }
- else
- {
- itemStr = itemStr.Insert(0, "A段\r\n");
- itemStr += "B段\r\n";
- foreach (var ListItem in List)
- {
- if (ListItem.number > 0)
- {
- if (ListItem.code.Contains("TBR"))
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- else
- {
- itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
- }
- TotalPrice += (ListItem.number * ListItem.price);
- }
- }
- }
- }
-
- #region 替换Word模板书签内容
- Dictionary<string, string> marks = new Dictionary<string, string>();
- marks.Add("To", di.ClientUnit);//付款方
- marks.Add("ToTel", di.TellPhone);//付款方电话
- marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
- marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
- marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
- marks.Add("PayDay", (di.PayDay).ToString());//付款预期
- marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
- marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
- marks.Add("PayItemContent", itemStr);//详细信息
- marks.Add("Total", TotalPrice.ToString("F2"));//合计
- #endregion
- ////注
- //if (doc.Range.Bookmarks["Attention"] != null)
- //{
- // Bookmark mark = doc.Range.Bookmarks["Attention"];
- // mark.Text = frList[0].Attention;
- //}
- foreach (var item in marks.Keys)
- {
- if (doc.Range.Bookmarks[item] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[item];
- mark.Text = marks[item];
- }
- }
- byte[] bytes = null;
- using (MemoryStream stream = new MemoryStream())
- {
- doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- bytes = stream.ToArray();
- }
- //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
- return Ok(JsonView(true,"",new
- {
- Data = bytes,
- strFileName,
- }));
- }
- else
- {
- return Ok(JsonView(false,"团组信息不存在!"));
- }
- }
- /// <summary>
- /// 导出团组成本
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
- {
- var jw = JsonView(false);
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di == null)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
- WorkbookDesigner designer = new WorkbookDesigner();
- designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
- var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
- for (int i = 0; i < List_GC.Count; i++)
- {
- GroupCost_Excel gc = new GroupCost_Excel();
- gc.Id = List_GC[i].Id;
- gc.Diid = List_GC[i].Diid.ToString();
- gc.DAY = List_GC[i].DAY;
- string week = "";
- if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
- week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
- gc.Date = (List_GC[i].Date + "\n" + week).ToString();
- gc.ITIN = List_GC[i].ITIN;
- gc.CarType = List_GC[i].CarType;
- gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
- gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
- gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
- gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
- gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
- gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
- gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
- gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
- gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
- gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
- gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
- gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
- gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
- gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
- gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
- gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
- gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
- gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
- gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
- gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
- gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
- gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
- gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
- gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
- gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
- gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
- gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
- gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
- gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
- gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
- gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
- gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
- gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
- List_GC1.Add(gc);
- }
- var dt = CommonFun.GetDataTableFromIList(List_GC1);
- dt.TableName = "TB";
- //报表标题等不用dt的值
- designer.SetDataSource("TeamName", dto.title.TeamName);
- designer.SetDataSource("Pnumber", dto.title.GroupNumber);
- designer.SetDataSource("Tax", dto.title.Tax);
- //designer.SetDataSource("FFYS", lblHotelCB.Text);
- designer.SetDataSource("Currency", dto.title.Currency);
- //designer.SetDataSource("HotelXS", txtHotelXS.Text);
- designer.SetDataSource("Rate", dto.title.Rate);
- var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
- var Aparams = hotels.Find(x => x.Type == "Default");
- if (Aparams == null)
- {
- return Ok(jw);
- }
- //酒店数量
- var txtSGRNumber = Aparams.SGR.ToString();
- var txtTBRNumber = Aparams.TBR.ToString();
- var txtJSESNumber = Aparams.JSES.ToString();
- var txtSUITENumbe = Aparams.SUITE.ToString();
- if (dto.costType == "B")
- {
- Aparams = hotels.Find(x => x.Type == "A");
- var Bparams = hotels.Find(x => x.Type == "B");
- if (Aparams == null || Bparams == null)
- {
- return Ok(jw);
- }
- txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
- txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
- txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
- txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
- }
- designer.SetDataSource("SGRNumber", txtSGRNumber);
- designer.SetDataSource("TBRNumber", txtTBRNumber);
- designer.SetDataSource("JSESNumber", txtJSESNumber);
- designer.SetDataSource("SUITENumber", txtSUITENumbe);
- var ws = designer.Workbook.Worksheets[0];
- int Row = List_GC.Count;
- int startIndex = 11;
- int HideRows = 0;
- List<int> hideRowsList = new List<int>();
- decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
-
- #region A段left数据
- var left = dto.leftInfo.Find(x => x.Type == "A");
- if (left == null)
- {
- return Ok(jw);
- }
- var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
- if (leftBindData != null)
- {
-
- designer.SetDataSource("VisaDRCB", leftBindData.cb);
- designer.SetDataSource("VisaRS", leftBindData.rs);
- designer.SetDataSource("VisaXS", leftBindData.xs);
- designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
- if (leftBindData != null)
- {
-
- designer.SetDataSource("BXDRCB", leftBindData.cb);
- designer.SetDataSource("BXRS", leftBindData.rs);
- designer.SetDataSource("BXXS", leftBindData.xs);
- designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
- if (leftBindData != null)
- {
- designer.SetDataSource("HSDRCB", leftBindData.cb);
- designer.SetDataSource("HSRS", leftBindData.rs);
- designer.SetDataSource("HSXS", leftBindData.xs);
- designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
- if (leftBindData != null)
- {
-
- designer.SetDataSource("JPJJCCB", leftBindData.cb);
- designer.SetDataSource("JPJJCPnum", leftBindData.rs);
- designer.SetDataSource("JPJJCXS", leftBindData.xs);
- designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
- if (leftBindData != null)
- {
-
- designer.SetDataSource("JPGWCCB", leftBindData.cb);
- designer.SetDataSource("JPGWCPNum", leftBindData.rs);
- designer.SetDataSource("JPGWCXS", leftBindData.xs);
- designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
- if (leftBindData != null)
- {
- ////TBR
- designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
- designer.SetDataSource("HotelTBRRS", leftBindData.rs);
- designer.SetDataSource("HotelTBRXS", leftBindData.xs);
- designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
- if (leftBindData != null)
- {
- ////SGR
- designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
- designer.SetDataSource("HotelSGRRS", leftBindData.rs);
- designer.SetDataSource("HotelSGRXS", leftBindData.xs);
- designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
- if (leftBindData != null)
- {
- ////JS/ES
- designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
- designer.SetDataSource("HotelJSESRS", leftBindData.rs);
- designer.SetDataSource("HotelJSESXS", leftBindData.xs);
- designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
- if (leftBindData != null)
- {
- ////SUITE
- designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
- designer.SetDataSource("HotelSUITERS", leftBindData.rs);
- designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
- designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
- if (leftBindData != null)
- {
- designer.SetDataSource("DJDRCB", leftBindData.cb);
- designer.SetDataSource("DJRS", leftBindData.rs);
- designer.SetDataSource("DJXS", leftBindData.xs);
- designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("HCPCB", leftBindData.cb);
- designer.SetDataSource("HCPRS", leftBindData.rs);
- designer.SetDataSource("HCPXS", leftBindData.xs);
- designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("CPCB", leftBindData.cb);
- designer.SetDataSource("CPRS", leftBindData.rs);
- designer.SetDataSource("CPXS", leftBindData.xs);
- designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
-
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
- if (leftBindData != null)
- {
- designer.SetDataSource("GWDRCD", leftBindData.cb);
- designer.SetDataSource("GWRS", leftBindData.rs);
- designer.SetDataSource("GWXS", leftBindData.xs);
- designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- HideRows += 2;
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
- if (leftBindData != null)
- {
- designer.SetDataSource("LYJDRCB", leftBindData.cb);
- designer.SetDataSource("LYJRS", leftBindData.rs);
- designer.SetDataSource("LYJXS", leftBindData.xs);
- designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
- }
- #endregion
- #region A段Right信息
- var right = dto.rightInfo.Find(x => x.Type == "A");
- if (right == null)
- {
- return Ok(jw);
- }
- HideRows += 4;
- var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
- if (rightBindData!= null)
- {
- //经济舱 + 双人间 TBR
- designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
- designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
- if (rightBindData != null)
- {
- //经济舱 + 单人间 SGR
- designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
- designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
- if (rightBindData != null)
- {
- //公务舱 + 单人间 SGR
- designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
- designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
- designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
- designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- HideRows += 2;
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
- if (rightBindData != null)
- {
- //经济舱 + 大套房
- designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
- designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- else
- {
- hideRowsList.Add(Row + startIndex + HideRows);
- }
- #endregion
- #region B段标题清空
- designer.SetDataSource("CostBDRCB", "");
- designer.SetDataSource("CostBRS", "");
- designer.SetDataSource("CostBXS", "");
- designer.SetDataSource("CostBZCB", "");
- designer.SetDataSource("CostBDRBJ", "");
- designer.SetDataSource("CostBZBJ", "");
- designer.SetDataSource("CostBDRLR", "");
- designer.SetDataSource("CostBZLR", "");
- designer.SetDataSource("CostBDRCBOM", "");
- designer.SetDataSource("CostBRSOM", "");
- designer.SetDataSource("CostBZCBOM", "");
- designer.SetDataSource("CostBDRBJOM", "");
- designer.SetDataSource("CostBZBJOM", "");
- designer.SetDataSource("CostBDRLROM", "");
- designer.SetDataSource("CostBZLROM", "");
- #endregion
- designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
- designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
- designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
- designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
- designer.SetDataSource("DJName", "地接(CNY)");
- designer.SetDataSource("HCPName", "地接-火车票(CNY)");
- designer.SetDataSource("CPName", "地接-船票(CNY)");
- designer.SetDataSource("GWName", "公务(CNY)");
- designer.SetDataSource("YQHName", "邀请函(CNY)");
- designer.SetDataSource("LYJName", "零用金(CNY)");
- designer.SetDataSource("HSName", "核酸检测(CNY)");
- designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
- designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
- designer.SetDataSource("BXName", "保险(CNY)");
- designer.SetDataSource("VisaName", "签证(CNY)");
- #region B段基本数据
- if (dto.costType == "B")
- {
- left = dto.leftInfo.Find(x => x.Type == "B");
- if (left == null)
- {
- return Ok(jw);
- }
- #region B段left数据
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHSDRCB", leftBindData.cb);
- designer.SetDataSource("BHSRS", leftBindData.rs);
- designer.SetDataSource("BHSXS", leftBindData.xs);
- designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
- if (leftBindData != null)
- {
-
- designer.SetDataSource("BJPJJCCB", leftBindData.cb);
- designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
- designer.SetDataSource("BJPJJCXS", leftBindData.xs);
- designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BJPGWCCB", leftBindData.cb);
- designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
- designer.SetDataSource("BJPGWCXS", leftBindData.xs);
- designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHCPCB", leftBindData.cb);
- designer.SetDataSource("BHCPRS", leftBindData.rs);
- designer.SetDataSource("BHCPXS", leftBindData.xs);
- designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BCPCB", leftBindData.cb);
- designer.SetDataSource("BCPRS", leftBindData.rs);
- designer.SetDataSource("BCPXS", leftBindData.xs);
- designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //TBR
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
- designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
- designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //SGR
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
- designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
- designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //JS/ES
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
- designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
- designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- //SUITE
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
- designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
- designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
- designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BDJDRCB", leftBindData.cb);
- designer.SetDataSource("BDJRS", leftBindData.rs);
- designer.SetDataSource("BDJXS", leftBindData.xs);
- designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BGWDRCD", leftBindData.cb);
- designer.SetDataSource("BGWRS", leftBindData.rs);
- designer.SetDataSource("BGWXS", leftBindData.xs);
- designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
-
- #region 优化方案
- //Dictionary<string, object> excelBind = new Dictionary<string, object>();
- //excelBind.Add("零用金", new {
- //cb="",
- //rs="",
- //xs ="",
- //zcb = "",
- //});
- #endregion
- leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
- if (leftBindData != null)
- {
- designer.SetDataSource("BLYJDRCB", leftBindData.cb);
- designer.SetDataSource("BLYJRS", leftBindData.rs);
- designer.SetDataSource("BLYJXS", leftBindData.xs);
- designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
- designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
- designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
- designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
- }
- #endregion
- #region B段Right信息
- right = dto.rightInfo.Find(x => x.Type == "B");
- if (right == null)
- {
- return Ok(jw);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
- if (rightBindData!= null)
- {
- //经济舱 + 双人间 TBR
- designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
- designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
- if (rightBindData != null)
- {
- //经济舱 + 单人间 SGR
- designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
- designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
- if (rightBindData != null)
- {
- //公务舱 + 单人间 SGR
- designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
- designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
- designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
- designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
- if (rightBindData != null)
- {
- //公务舱 + 小套房 JSES
- designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
- if (rightBindData != null)
- {
- //经济舱 + 大套房
- designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
- designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
- designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
- designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
- designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
- designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
- TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
- TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
- TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
- }
- #endregion
- #region 标题
- designer.SetDataSource("CostBDRCB", "单人成本");
- designer.SetDataSource("CostBRS", "人数");
- designer.SetDataSource("CostBXS", "系数");
- designer.SetDataSource("CostBZCB", "总成本");
- designer.SetDataSource("CostBDRBJ", "单人报价");
- designer.SetDataSource("CostBZBJ", "总报价");
- designer.SetDataSource("CostBDRLR", "单人利润");
- designer.SetDataSource("CostBZLR", "总利润");
- designer.SetDataSource("CostBDRCBOM", "单人成本");
- designer.SetDataSource("CostBRSOM", "人数");
- designer.SetDataSource("CostBZCBOM", "总成本");
- designer.SetDataSource("CostBDRBJOM", "单人报价");
- designer.SetDataSource("CostBZBJOM", "总报价");
- designer.SetDataSource("CostBDRLROM", "单人利润");
- designer.SetDataSource("CostBZLROM", "总利润");
- #endregion
- }
- #endregion
- designer.SetDataSource("TzZCB2", TzZCB2);
- designer.SetDataSource("TzZBJ2", TzZBJ2);
- designer.SetDataSource("TzZLR2", TzZLR2);
- string[] dataSourceKeys = new string[]
- {
- "VF",
- "TGS",
- "TGOF",
- "TGM",
- "TGA",
- "TGTF",
- "TGEF",
- "CFM",
- "CFOF",
- "B",
- "L",
- "D",
- "TBR",
- "SGR",
- "JSES",
- "Suite",
- "TV",
- "1L",
- "IF",
- "EF",
- "BRF",
- "TE",
- "TGT",
- "DRVT",
- "PC",
- "TLF",
- "ECT"
- };
- foreach (var item in dataSourceKeys)
- {
- var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
- if (find != null)
- {
- designer.SetDataSource(item, find.text);
- }
- else
- {
- designer.SetDataSource(item, 0);
- }
- }
- designer.SetDataSource(dt);
- //根据数据源处理生成报表内容
- designer.Process();
- designer.Workbook.Worksheets[0].Name = "清单";
- Worksheet sheet = designer.Workbook.Worksheets[0];
- foreach (var Rowindex in hideRowsList)
- {
- ws.Cells.HideRows(Rowindex, 2);
- }
- byte[] bytes = null;
- string strFileName = di.TeamName + "-团组-成本.xls";
- using (MemoryStream stream = new MemoryStream())
- {
- designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
- bytes = stream.ToArray();
- }
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- /// <summary>
- /// 导出客户报表
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
- {
- var jw = JsonView(false);
- if (dto.Diid == 0)
- {
- return Ok(JsonView(false, "请传递团组id"));
- }
- var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
- if (deleInfo.Code != 0)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- var di = deleInfo.Data as DelegationInfoWebView;
- if (di == null)
- {
- return Ok(JsonView(false, "团组信息查询失败!"));
- }
- //文件名
- //string strFileName = di.TeamName + "-团组-客户报价.doc";
- //获取模板
- string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
- //载入模板
- Document doc = new Document(tmppath);
- Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
- Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
- DickeyValue.Add("DickeyValue", di.TeamName); //团组名
- var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
- var AParameter = ParameterList.Find(x => x.CostType == "A");
- var BParameter = ParameterList.Find(x => x.CostType == "B");
- if (AParameter == null)
- {
- return Ok(JsonView(false, "系数不存在!"));
- }
- string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
- , TzAirDesc, TzZCost;
- CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
- = TzAirDesc = TzZCost = string.Empty;
- TzNumber = AParameter.CostTypenumber.ToString();
- CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
- CarGuides1 = dto.CarGuides1;
- Meal = dto.Meal;
- SubsidizedMeals = dto.SubsidizedMeals;
- NightRepair = dto.NightRepair;
- AttractionsTickets = dto.AttractionsTickets;
- MiscellaneousFees = dto.MiscellaneousFees;
- ATip = dto.ATip;
- TzHotelDesc = "";
- Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
- PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
- Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
- TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
- TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
- TzAirDesc = "";
- TzZCost = dto.TzZCost;
- var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
- var TzAirDescArr = new string[] { "经济舱", "公务舱" };
- var index = 1;
- var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
- foreach (var item in TzHotelDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- var hotelText = string.Empty;
- switch (item)
- {
- case "SGR":
- hotelText = "单人间";
- break;
- case "JSES":
- hotelText = "小套房";
- break;
- case "SUITE":
- hotelText = "套房";
- break;
- case "TBR":
- hotelText = "双人间";
- break;
- }
- if (item != "TBR")
- {
- 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";
- }
- else
- {
- 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";
- }
- index++;
- }
- }
- }
- index = 1;
- foreach (var item in TzAirDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- 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";
- index++;
- }
- }
- }
- if (dto.costType == "B")
- {
- if (BParameter == null)
- {
- return Ok(JsonView(false, "B段系数不存在!"));
- }
- CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
- Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
- PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
- Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
- TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
- TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
- AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
- foreach (var item in TzHotelDescArr)
- {
- if (AinfoArr != null)
- {
- TzHotelDesc += "B段信息 \r\n";
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- var hotelText = string.Empty;
- switch (item)
- {
- case "SGR":
- hotelText = "单人间";
- break;
- case "JSES":
- hotelText = "小套房";
- break;
- case "SUITE":
- hotelText = "套房";
- break;
- case "TBR":
- hotelText = "双人间";
- break;
- }
- if (item != "TBR")
- {
- 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";
- }
- else
- {
- 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";
- }
- index++;
- }
- TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
- }
- }
- index = 1;
- foreach (var item in TzAirDescArr)
- {
- if (AinfoArr != null)
- {
- var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
- if (Ainfo != null)
- {
- if (int.Parse(Ainfo.rs) <= 0)
- {
- continue;
- }
- 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";
- index++;
- }
- }
- }
- }
- Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
- DickeyValue.Add("TzNumber", TzNumber); //团组人数
- DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
- DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
- DickeyValue.Add("Meal", Meal); // 地接 - 餐费
- DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
- DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
- DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
- DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
- DickeyValue.Add("ATip", ATip); // 地接 - 小费
- DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
- DickeyValue.Add("Offcial", Offcial); // 公务单人报价
- DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
- DickeyValue.Add("Visa", Visa); // 签证单人报价
- DickeyValue.Add("TrainTicket", TrainTicket); //火车票
- DickeyValue.Add("TicketPrice", TicketPrice); //船票
- DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
- DickeyValue.Add("TzZCost", TzZCost);
- foreach (var key in DickeyValue.Keys)
- {
- if (doc.Range.Bookmarks[key] != null)
- {
- Bookmark mark = doc.Range.Bookmarks[key];
- mark.Text = DickeyValue[key];
- }
- }
- byte[] bytes = null;
- string strFileName = di.TeamName + "-客户报价.doc";
- using (MemoryStream stream = new MemoryStream())
- {
- doc.Save(stream, Aspose.Words.SaveFormat.Doc);
- bytes = stream.ToArray();
- }
- return Ok(JsonView(true, "", new
- {
- Data = bytes,
- strFileName,
- }));
- }
- /// <summary>
- /// 团组成本 各模块(酒店,地接,机票)成本提示
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
- {
- try
- {
- #region 参数验证
- if (dto.DiId < 0)
- {
- return Ok(JsonView(false, "请传入有效的DiId参数!"));
- }
- List<int> cTableIds = new List<int>() {
- 76 ,//酒店预订
- 77 ,//行程
- 79 ,//车/导游地接
- 80 ,//签证
- 81 ,//邀请/公务活
- 82 ,//团组客户保险
- 85 ,//机票预订
- 98 ,//其他款项
- 285 ,//收款退还
- 751 ,//酒店早餐
- 1015 // 超支费用
- };
- if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
- {
- return Ok(JsonView(false, "请传入有效的CTable参数!"));
- }
- #endregion
- //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
- var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
- if (_GroupCostParameters.Count <= 0)
- {
- return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
- }
- if (_GroupCostParameters[0].IsShare == 0)
- {
- return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
- }
- var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
- //处理date为空问题
- if (_GroupCosts.Count > 0)
- {
- for (int i = 0; i < _GroupCosts.Count; i++)
- {
- if (string.IsNullOrEmpty(_GroupCosts[i].Date))
- {
- if (i > 0)
- {
- _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
- }
- }
- }
- }
-
- GroupCostModulePromptView _view = new GroupCostModulePromptView();
- ;
- List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
- //op,酒店单段模式存储
- GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
- {
- CurrencyCode = _GroupCostParameters[0].Currency,
- Rate = _GroupCostParameters[0].Rate,
- CostType = _GroupCostParameters[0].CostType,
- CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
- CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
- CostTypeNumber = _GroupCostParameters[0].CostTypenumber
- };
- List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
- if (_GroupCostParameters.Count == 2)
- {
- _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
- }
- foreach (var item in _GroupCostParameters)
- {
- decimal _rate = item.Rate;
- decimal _scale = 0.95M;
- #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
- var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
- if (userInfo != null)
- {
- if (userInfo.DepId == 1 || userInfo.DepId == 7)
- {
- if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
- {
- _scale = 1.00M;
- }
- }
- }
- #endregion
- GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
- {
- CurrencyCode = item.Currency,
- Rate = _rate,
- CostType = item.CostType,
- CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
- CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
- CostTypeNumber = item.CostTypenumber
- };
- if (_GroupCostParameters.Count > 1)
- {
- modulePromptInfo.CostTypeNumber = item.CostTypenumber;
-
- }
- else
- {
- modulePromptInfo.CostTypeNumber = item.LYJRS;
- }
- if (dto.CTable == 79)//
- {
- modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
- modulePromptInfo.TotalCost = item.DJCB;
- }
- List<string> costTypes = new List<string>() { "A","B" };
- List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
- var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
- if (_GroupCostsDuplicates.Count() == 1)
- {
- _GroupCostsTypeData = _GroupCosts;
-
- }
- else
- {
- _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
- Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
- }
- /*
- * 76 酒店预订
- * 77 行程
- * 79 车/导游地接
- * 80 签证
- * 81 邀请/公务活动
- * 82 团组客户保险
- * 85 机票预订
- * 98 其他款项
- * 285 收款退还
- * 751 酒店早餐
- * 1015 超支费用
- */
- switch (dto.CTable)
- {
- case 76: // 酒店预订
- _ModuleSubPromptInfo.AddRange(
- _GroupCostsTypeData.Select(it => new
- {
- it.DAY,
- it.Date,
- it.ACCON,
- it.ITIN,
- it.SGR,
- it.TBR,
- it.JS_ES,
- it.Suite
- })
- );
- break;
- case 79: // 车/导游地接
- _ModuleSubPromptInfo.AddRange(
- _GroupCostsTypeData.Select(it => new
- {
- Date = it.Date, //日期
- CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
- GuideFee = (it.TGS + it.TGOF + it.TGM+ it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
- MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
- TicketFee = it.EF * _rate * _scale, //门票费
- TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
- AirportTransferFee = 0.00M,
- DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
- TravelSupplies = it.TE * _rate * _scale, //出行物资
- LeadersFee = it.TLF * _rate * _scale, //领队费
- CarFee1 = it.CarCost * _rate * _scale,
- CarType = it.CarType, //车型
- SpentCash = it.PC * _rate * _scale, //零用金
- })
- );
- break;
- case 85: // 机票
- List<dynamic> datas = new List<dynamic>();
- datas.Add(
- new
- {
- AirType = "经济舱",
- AirNum = item.JJCRS,
- AirDRCB = item.JJCCB,
- AirZCB = (item.JJCRS * item.JJCCB)
- }
- );
- datas.Add(
- new
- {
- AirType = "公务舱",
- AirNum = item.GWCRS,
- AirDRCB = item.GWCCB,
- AirZCB = (item.GWCRS * item.GWCCB)
- }
- );
- modulePromptInfo.Data = datas;
- _ModulePromptInfos.Add(modulePromptInfo);
- break;
- default:
- break;
- }
- }
- if (dto.CTable != 85)
- {
- _ModulePromptInfo.Data = _ModuleSubPromptInfo;
- _ModulePromptInfos.Add(_ModulePromptInfo);
- }
-
- _view.ModulePromptInfos = _ModulePromptInfos;
- return Ok(JsonView(true,"操作成功!", _view));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 酒店预定 保留
- /// <summary>
- /// 酒店预订页面初始化绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> HotelReservationsInitialize(HotelReservationsDto dto)
- {
- try
- {
- Result groupData = await _hotelPriceRep.HotelReservationsInitialize(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据团组Id查询酒店费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
- {
- try
- {
- Result groupData = await _hotelPriceRep.HotelReservationsByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据酒店费用Id查询酒店费用详细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> HotelReservationsById(HotelReservationsByIdDto dto)
- {
- try
- {
- Result groupData = await _hotelPriceRep.HotelReservationsById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 计算酒店付款总金额
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> HotelConversionAmounts(HotelReservationsCNYDto dto)
- {
- try
- {
- Result groupData = await _hotelPriceRep.HotelConversionAmounts(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店费用操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpHotelReservations(OpHotelReservationsData dto)
- {
- try
- {
- Result groupData = await _hotelPriceRep.OpHotelReservations(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 文件上传
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadHotel(IFormFile file)
- {
- try
- {
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\酒店费用录入相关文件\{projectFileName}";
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 删除指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFileHotel(DelFileDto dto)
- {
- try
- {
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- //int id = 0;
- filePath = fileDir + "/酒店费用录入相关文件/" + dto.fileName;
- // 删除该文件
- try
- {
- System.IO.File.Delete(filePath);
- var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception)
- {
- var result = await _sqlSugar.Updateable<Grp_HotelReservations>().Where(a => a.Id == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_HotelReservations()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- throw;
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 生成VOUCHER
- /// </summary>
- /// <param name=""></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> HotelGenerate(HotelReservationsByIdDto dto)
- {
- Grp_HotelReservations h = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.Id == dto.Id && a.IsDel == 0);
- //判断数据是否完整
- if (h != null)
- {
- if (!string.IsNullOrEmpty(h.DetermineNo))
- {
- string strFileName = "HotelStatement/";
- Grp_DelegationInfo dele = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == h.DiId && a.IsDel == 0);
- if (dele != null)
- strFileName += dele.TourCode;
- //载入模板
- string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
- Document doc = new Document(sss);
- DocumentBuilder builder = new DocumentBuilder(doc);
- try
- {
- #region 替换Word模板书签内容
- //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
- //入住卷预定号码
- if (doc.Range.Bookmarks["VNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VNO"];
- mark.Text = h.CheckNumber;
- }
- //酒店时间
- if (doc.Range.Bookmarks["Date"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Date"];
- mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
- }
- //团号
- if (doc.Range.Bookmarks["TNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TNo"];
- mark.Text = dele.TourCode;
- }
- //预定号码
- if (doc.Range.Bookmarks["BookingId"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["BookingId"];
- mark.Text = h.ReservationsNo;
- }
- if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
- mark.Text = h.DetermineNo;
- }
- //酒店城市
- if (doc.Range.Bookmarks["City"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["City"];
- mark.Text = h.City;
- }
- //酒店名称
- if (doc.Range.Bookmarks["HName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HName"];
- mark.Text = h.HotelName;
- }
- //酒店地址
- if (doc.Range.Bookmarks["Address"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Address"];
- mark.Text = h.HotelAddress;
- }
- //酒店电话
- if (doc.Range.Bookmarks["Tel"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Tel"];
- mark.Text = h.HotelTel;
- }
- //酒店传真
- if (doc.Range.Bookmarks["Fax"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Fax"];
- if (!string.IsNullOrWhiteSpace(h.HotelFax))
- {
- mark.Text = h.HotelFax;
- }
- }
- //入住时间
- if (doc.Range.Bookmarks["CIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
- }
- //退房时间
- if (doc.Range.Bookmarks["COut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["COut"];
- mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //客户名称
- if (doc.Range.Bookmarks["GName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["GName"];
- mark.Text = h.GuestName;
- }
- //房间介绍
- if (doc.Range.Bookmarks["ROOM"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ROOM"];
- mark.Text = h.RoomExplanation;
- }
- //报价描述
- if (doc.Range.Bookmarks["NOTE"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["NOTE"];
- Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == h.ReservationsWebsite);
- if (ss != null)
- mark.Text = ss.Name;
- }
- //入住时间
- if (doc.Range.Bookmarks["CheckIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(h.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CheckIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
- }
- //退房时间
- if (doc.Range.Bookmarks["CheckOut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(h.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["CheckOut"];
- mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //日期
- if (doc.Range.Bookmarks["DT"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["DT"];
- mark.Text = Convert.ToDateTime(h.CreateTime).ToString("yyyy-MM-dd");
- }
- //名称
- if (doc.Range.Bookmarks["VName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VName"];
- mark.Text = h.HotelName;
- }
- //号码
- if (doc.Range.Bookmarks["VOUCHERNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
- mark.Text = h.CheckNumber;
- }
- #endregion
- //string fileName = "HotelStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
- strFileName += "VOUCHER.doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "成功!", Url));
- }
- catch (Exception ex)
- {
- throw;
- }
- }
- else
- {
- return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
- }
- }
- else
- {
- return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
- }
- }
- /// <summary>
- /// 导出确认单
- /// </summary>
- /// <param name=""></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> ConfirmWord(HotelReservationsByIdDto dto)
- {
- //团组信息
- Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == dto.Id);
- //酒店数据
- List<Grp_HotelReservations> listhoteldata = _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == dto.Id && a.IsDel == 0).ToList();
- //利datatable存储
- DataTable dt = new DataTable();
- dt.Columns.Add("CheckInDate", typeof(string));
- dt.Columns.Add("City", typeof(string));
- dt.Columns.Add("Hotel", typeof(string));
- dt.Columns.Add("Room", typeof(string));
- for (int i = 0; i < listhoteldata.Count; i++)
- {
- DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
- DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
- while (dayStart < dayEnd)
- {
- string temp = "";
- DataRow row = dt.NewRow();
- row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
- row["City"] = listhoteldata[i].City;
- row["Hotel"] = listhoteldata[i].HotelName;
- if (listhoteldata[i].SingleRoomCount > 0)
- {
- temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
- }
- if (listhoteldata[i].DoubleRoomCount > 0)
- {
- temp = temp + listhoteldata[i].DoubleRoomCount + "个表间" + "\r\n";
- }
- if (listhoteldata[i].SuiteRoomCount > 0)
- {
- temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
- }
- if (listhoteldata[i].OtherRoomCount > 0)
- {
- temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
- }
- row["Room"] = temp;
- dt.Rows.Add(row);
- dayStart = dayStart.AddDays(1);
- }
- }
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Dele", di.TeamName);
- dic.Add("City", di.VisitCountry);
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- try
- {
- //循环赋值
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(dt.Rows[i]["CheckInDate"].ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(dt.Rows[i]["City"].ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(dt.Rows[i]["Hotel"].ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(dt.Rows[i]["Room"].ToString());
- }
- }
- catch
- {
- }
- //删除多余行
- while (tableOne.Rows.Count > dt.Rows.Count + 1)
- {
- tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
- }
- string strFileName = di.TeamName + "酒店确认单.doc";
- try
- {
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
- return Ok(JsonView(true, "成功", Url));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "当前文档已打开,请先关闭!"));
- throw;
- }
- }
- /// <summary>
- /// 酒店费用删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelHotelPrice(DelBaseDto dto)
- {
- try
- {
- var res = await _hotelPriceRep.SoftDeleteByIdAsync<Grp_HotelReservations>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 酒店预订 新 雷怡 2023-12-28 17:45
- /// <summary>
- /// 酒店预订
- /// 酒店费用列表 根据团组Id查询
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- Result _view = await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId);
- if (_view.Code != 0)
- {
- return Ok(JsonView(false, _view.Msg));
- }
-
- return Ok(JsonView(true, _view.Msg, _view.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// 基础数据
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "Catch:"+ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// 创建 入住卷号码
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// 详情
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._Details(_dto.PortType,_dto.Id);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (_dto.Id == 0) // Add
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- else if (_dto.Id > 0) // Edit
- if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
- else return Ok(JsonView(false, "请输入正确的数据Id!"));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._AddOrEdit(_dto);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
- #endregion
- #endregion
- Result data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
- if (data.Code != 0)
- {
- return Ok(JsonView(false, data.Msg));
- }
- return Ok(JsonView(true, data.Msg, data.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 酒店预订
- /// 生成VOUCHER
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
- //判断数据是否完整
- if (hr != null)
- {
- if (!string.IsNullOrEmpty(hr.DetermineNo))
- {
- string strFileName = "HotelStatement/";
- Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
- if (dele != null)
- strFileName += dele.TourCode;
- //载入模板
- string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
- Document doc = new Document(sss);
- DocumentBuilder builder = new DocumentBuilder(doc);
- #region 替换Word模板书签内容
- //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
- //入住卷预定号码
- if (doc.Range.Bookmarks["VNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VNO"];
- mark.Text = hr.CheckNumber;
- }
- //酒店时间
- if (doc.Range.Bookmarks["Date"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Date"];
- mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
- }
- //团号
- if (doc.Range.Bookmarks["TNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["TNo"];
- mark.Text = dele.TourCode;
- }
- //预定号码
- if (doc.Range.Bookmarks["BookingId"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["BookingId"];
- mark.Text = hr.ReservationsNo;
- }
- if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
- mark.Text = hr.DetermineNo;
- }
- //酒店城市
- if (doc.Range.Bookmarks["City"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["City"];
- mark.Text = hr.City;
- }
- //酒店名称
- if (doc.Range.Bookmarks["HName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["HName"];
- mark.Text = hr.HotelName;
- }
- //酒店地址
- if (doc.Range.Bookmarks["Address"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Address"];
- mark.Text = hr.HotelAddress;
- }
- //酒店电话
- if (doc.Range.Bookmarks["Tel"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Tel"];
- mark.Text = hr.HotelTel;
- }
- //酒店传真
- if (doc.Range.Bookmarks["Fax"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["Fax"];
- if (!string.IsNullOrWhiteSpace(hr.HotelFax))
- {
- mark.Text = hr.HotelFax;
- }
- }
- //入住时间
- if (doc.Range.Bookmarks["CIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
- }
- //退房时间
- if (doc.Range.Bookmarks["COut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["COut"];
- mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //客户名称
- if (doc.Range.Bookmarks["GName"] != null)
- {
- string guestName = "";
- string[] clients = new string[] { };
- if (hr.GuestName.Contains(","))
- {
- clients = hr.GuestName.Split(",");
- }
- else
- {
- clients = new string[] { hr.GuestName };
- }
- List<int> clientIds_int = new List<int>();
- if (clients.Length > 0)
- {
- foreach (var item in clients)
- {
- if (item.IsNumeric())
- {
- clientIds_int.Add(int.Parse(item));
- }
- }
- }
- if (clientIds_int.Count > 0)
- {
- var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
- foreach (var client in _clientDatas)
- {
- //男
- if (client.Sex == 0) guestName += $"Mr.";
- //女
- else if (client.Sex == 1) guestName += $"Ms.";
- if (!String.IsNullOrEmpty(client.FirstName+ client.LastName))
- {
- guestName += $"{string.Join("",client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
- }
- //guestName += $"{client.Pinyin},";
- }
- if (guestName.Length > 0)
- {
- guestName = guestName.Substring(0, guestName.Length - 1);
- }
- }
- else
- {
- guestName = hr.GuestName;
- }
- Bookmark mark = doc.Range.Bookmarks["GName"];
- mark.Text = guestName;
- }
- //房间介绍
- if (doc.Range.Bookmarks["ROOM"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["ROOM"];
- mark.Text = hr.RoomExplanation;
- }
- //报价描述
- if (doc.Range.Bookmarks["NOTE"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["NOTE"];
- Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
- if (ss != null)
- mark.Text = ss.Name;
- }
- //入住时间
- if (doc.Range.Bookmarks["CheckIn"] != null)
- {
- DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
- Bookmark mark = doc.Range.Bookmarks["CheckIn"];
- mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
- }
- //退房时间
- if (doc.Range.Bookmarks["CheckOut"] != null)
- {
- DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
- Bookmark mark = doc.Range.Bookmarks["CheckOut"];
- mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
- }
- //日期
- if (doc.Range.Bookmarks["DT"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["DT"];
- mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
- }
- //名称
- if (doc.Range.Bookmarks["VName"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VName"];
- mark.Text = hr.HotelName;
- }
- //号码
- if (doc.Range.Bookmarks["VOUCHERNO"] != null)
- {
- Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
- mark.Text = hr.CheckNumber;
- }
- #endregion
- strFileName += "VOUCHER.doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- else
- {
- return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
- }
- }
- else
- {
- return Ok(JsonView(false, "该条数据已删除或不存在!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
-
- }
- /// <summary>
- /// 酒店预订
- /// 确认单
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
- {
- try
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
- if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
- if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
- #region 团组操作权限验证 76 酒店预定模块
- var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
- if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
- #endregion
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- //团组信息
- Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
- //酒店数据
- List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
- if (listhoteldata.Count < 0)
- {
- return Ok(JsonView(false, "当前团组暂无酒店预订信息!"));
- }
- //利datatable存储
- DataTable dt = new DataTable();
- dt.Columns.Add("CheckInDate", typeof(string));
- dt.Columns.Add("City", typeof(string));
- dt.Columns.Add("Hotel", typeof(string));
- dt.Columns.Add("Room", typeof(string));
- for (int i = 0; i < listhoteldata.Count; i++)
- {
- DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
- DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
- while (dayStart < dayEnd)
- {
- string temp = "";
- DataRow row = dt.NewRow();
- row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
- row["City"] = listhoteldata[i].City;
- row["Hotel"] = listhoteldata[i].HotelName;
- if (listhoteldata[i].SingleRoomCount > 0)
- {
- temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
- }
- if (listhoteldata[i].DoubleRoomCount > 0)
- {
- temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
- }
- if (listhoteldata[i].SuiteRoomCount > 0)
- {
- temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
- }
- if (listhoteldata[i].OtherRoomCount > 0)
- {
- temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
- }
- row["Room"] = temp;
- dt.Rows.Add(row);
- dayStart = dayStart.AddDays(1);
- }
- }
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Dele", di.TeamName);
- dic.Add("City", di.VisitCountry);
- //模板路径
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
- //载入模板
- Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(dt.Rows[i]["CheckInDate"].ToString());
- builder.MoveToCell(0, i + 1, 1, 0);
- builder.Write(dt.Rows[i]["City"].ToString());
- builder.MoveToCell(0, i + 1, 2, 0);
- builder.Write(dt.Rows[i]["Hotel"].ToString());
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(dt.Rows[i]["Room"].ToString());
- }
- //删除多余行
- while (tableOne.Rows.Count > dt.Rows.Count + 1)
- {
- tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
- }
- string strFileName = di.TeamName + "酒店确认单.doc";
-
- doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
- string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
- return Ok(JsonView(true, "成功", url));
-
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- #endregion
- #region 团组状态
- /// <summary>
- /// 团组状态列表 Page
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
- if (dto.PortType == 1 || dto.PortType == 2) // web/Android
- {
- string sqlWhere = string.Empty;
- if (dto.IsSure == 0) //未完成
- {
- sqlWhere += string.Format(@" And IsSure = 0");
- }
- else if (dto.IsSure == 1) //已完成
- {
- sqlWhere += string.Format(@" And IsSure = 1");
- }
- if (!string.IsNullOrEmpty(dto.SearchCriteria))
- {
- string tj = dto.SearchCriteria;
- 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}%')",
- tj, tj, tj, tj, tj);
- }
- string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
- TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
- From (
- Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
- gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
- ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
- VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
- From Grp_DelegationInfo gdi
- Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
- Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
- Left Join Sys_Users su On gdi.JietuanOperator = su.Id
- Where gdi.IsDel = 0 {0}
- ) temp ", sqlWhere);
- RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
- var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
- return Ok(JsonView(true, "查询成功!", _DelegationList, total));
- }
- else
- {
- return Ok(JsonView(false, "查询失败"));
- }
- }
- /// <summary>
- /// 团组状态
- /// 设置操作完成
- /// </summary>
- /// <param name="dto">团组列表请求dto</param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
- {
- if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
- Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
- {
- Id = dto.Id,
- IsSure = 1
- };
- var result = await _sqlSugar.Updateable(_DelegationInfo)
- .UpdateColumns(it => new { it.IsSure })
- .WhereColumns(it => new { it.Id })
- .ExecuteCommandAsync();
- if (result > 0)
- {
- return Ok(JsonView(true, "操作完成!"));
- }
- return Ok(JsonView(false, "操作失败!"));
- }
- #endregion
- #region 保险费用录入
- /// <summary>
- /// 根据团组Id查询保险费用列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersByDiId(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 根据保险费用Id查询保险费用详细
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersById(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 保险费用录入页面初始化绑定
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
- {
- try
- {
- Result groupData = await _customersRep.CustomersInitialize(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 保险费用操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
- {
- try
- {
- Result groupData = await _customersRep.OpCustomers(dto);
- if (groupData.Code != 0)
- {
- return Ok(JsonView(false, groupData.Msg));
- }
- return Ok(JsonView(true, groupData.Msg, groupData.Data));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, ex.Message));
- }
- }
- /// <summary>
- /// 保险文件上传
- /// </summary>
- /// <param name="file"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> UploadCus(IFormFile file)
- {
- try
- {
- if (file != null)
- {
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- //文件名称
- string projectFileName = file.FileName;
- //上传的文件的路径
- string filePath = "";
- if (!Directory.Exists(fileDir))
- {
- Directory.CreateDirectory(fileDir);
- }
- //上传的文件的路径
- filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
- using (FileStream fs = System.IO.File.Create(filePath))
- {
- file.CopyTo(fs);
- fs.Flush();
- }
- return Ok(JsonView(true, "上传成功!", projectFileName));
- }
- else
- {
- return Ok(JsonView(false, "上传失败!"));
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 保险删除指定文件
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelFileCus(DelFileDto dto)
- {
- try
- {
- string filePath = "";
- var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
- // 返回与指定虚拟路径相对应的物理路径即绝对路径
- //int id = 0;
- filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
- // 删除该文件
- try
- {
- System.IO.File.Delete(filePath);
- 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()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- catch (Exception)
- {
- 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()
- {
- Attachment = "",
- }).ExecuteCommandAsync();
- if (result != 0)
- {
- return Ok(JsonView(true, "成功!"));
- }
- else
- {
- return Ok(JsonView(false, "失败!"));
- }
- }
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 保险费用操作(删除)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCustomers(DelBaseDto dto)
- {
- try
- {
- var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
- {
- IsDel = 1,
- DeleteUserId = dto.DeleteUserId,
- DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- }).ExecuteCommandAsync();
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- #endregion
- #region 接团客户名单 PageId 104
- /// <summary>
- /// 接团客户名单
- /// 根据团组Id查询List
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType,_dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// 基础数据 Init
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// 根据 Id查询 Details
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 接团客户名单
- /// Add Or Edit
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (_dto.Id == 0) //添加
- {
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
- }else if (_dto.Id >= 0) //修改
- {
- if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
- }
- #endregion
- #endregion
- var viewData = await _tourClientListRep._AddOrEdit(_dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// AddMultiple(添加多个)
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
-
- if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
-
- #endregion
- #endregion
- var viewData = await _tourClientListRep._AddMultiple(_dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// Del
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
- #endregion
- #endregion
- var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(true));
- }
- /// <summary>
- /// 接团客户名单
- /// 文件下载 客户名单
- /// </summary>
- /// <param name="_dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
- {
- #region 参数验证
- if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
- if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
- if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
- PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
- #region 页面操作权限验证
- pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
- if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
- #endregion
- #endregion
- string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
- tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
- From Grp_TourClientList tcl
- Left Join
- (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
- cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
- cc2.Area,cc2.IssueDt,cc2.ExpiryDt
- From Crm_DeleClient dc
- Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
- Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
- Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
- Where dc.IsDel = 0) temp
- On temp.DcId =tcl.ClientId
- Where tcl.IsDel = 0 And tcl.DiId = {0}",_dto.DiId);
- List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
- if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
- //载入模板
- string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
- //载入模板
- var doc = new Document(tempPath);
- DocumentBuilder builder = new DocumentBuilder(doc);
- //获取word里所有表格
- NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
- //获取所填表格的序数
- Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
- var rowStart = tableOne.Rows[0]; //获取第1行
- //循环赋值
- for (int i = 0; i < DcList.Count; i++)
- {
- builder.MoveToCell(0, i + 1, 0, 0);
- builder.Write(DcList[i].LastName + DcList[i].FirstName);
- builder.MoveToCell(0, i + 1, 1, 0);
- int sex = DcList[i].Sex;
- string sexStr = string.Empty;
- if (sex == 0) sexStr = "男";
- else if (sex == 1) sexStr = "女";
- else sexStr = "未设置";
- builder.Write(sexStr);
- builder.MoveToCell(0, i + 1, 2, 0);
- string birthDay = DcList[i].BirthDay;
- string birthDayStr = string.Empty;
- if (!string.IsNullOrEmpty(birthDay))
- {
- birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
- }
- builder.Write(birthDayStr);
- builder.MoveToCell(0, i + 1, 3, 0);
- builder.Write(DcList[i].CompanyFullName);
- builder.MoveToCell(0, i + 1, 4, 0);
- builder.Write(DcList[i].Job);
- }
- //删除多余行
- while (tableOne.Rows.Count > DcList.Count + 1)
- {
- tableOne.Rows.RemoveAt(DcList.Count + 1);
- }
- string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
- var fileDir = AppSettingsHelper.Get("WordBasePath") + fileName;
- doc.Save(fileDir);
- string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + fileName;
- return Ok(JsonView(true, "操作成功!", Url));
- }
- #endregion
- #region 团组倒推表
- /// <summary>
- /// 倒推表基础数据
- /// Init
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListInit()
- {
- var viewData = await _invertedListRep._Init();
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Info
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
- {
- var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Create
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
- {
- var viewData = await _invertedListRep._Create(dto.PortType,dto.DiId);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// Update
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
- {
- var viewData = await _invertedListRep._Update(dto);
- if (viewData.Code != 0)
- {
- return Ok(JsonView(false, viewData.Msg));
- }
- return Ok(JsonView(viewData.Data));
- }
- /// <summary>
- /// 倒推表
- /// File Download
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
- {
- var info1 = await _invertedListRep._sqlSugar.Queryable<Grp_InvertedList>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).FirstAsync();
- if (info1 == null)
- {
- return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
- }
- var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
- string teamName = "";
- if (info != null) teamName = info.TeamName;
- //载入模板
- Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
- DocumentBuilder builder = new DocumentBuilder(doc);
- //利用键值对存放数据
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("TeamName", teamName);
- dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime());
- dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
- dic.Add("BPRemark", info1.ApprovalDataRemark);
- dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
- dic.Add("SQRemark", info1.ApprovalRemark);
- dic.Add("CPJtime", info1.ApprovalDt.ConvertToDatetime());
- dic.Add("CPJRemark", info1.ApprovalRemark);
- dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
- dic.Add("HZRemark", info1.ApplyPassportRemark);
- dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
- dic.Add("QZRemark", info1.VisaInformationRemark);
- dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
- dic.Add("SQQZRemark", info1.SendVisaRemark);
- dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
- dic.Add("CQRemark", info1.IssueVisaRemark);
- dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
- dic.Add("XQHRemark", info1.PreTripMeetingRemark);
- dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
- dic.Add("SJRemark", info1.AirportdDropOffRemark);
- #region 填充word模板书签内容
- foreach (var key in dic.Keys)
- {
- builder.MoveToBookmark(key);
- builder.Write(dic[key]);
- }
- #endregion
- var fileDir = AppSettingsHelper.Get("WordBasePath");
- string fileName = $"{teamName}团出行准备流程表.doc";
- string filePath = fileDir + $@"InvertedList/{fileName}";
- doc.Save(filePath);
- string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
- return Ok(JsonView(true, "操作成功!", Url));
- }
- #endregion
- }
- }
|