GroupsController.cs 686 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using Microsoft.AspNetCore.SignalR;
  6. using NPOI.HSSF.UserModel;
  7. using NPOI.SS.UserModel;
  8. using NPOI.SS.Util;
  9. using NPOI.XSSF.UserModel;
  10. using OASystem.API.OAMethodLib;
  11. using OASystem.API.OAMethodLib.File;
  12. using OASystem.API.OAMethodLib.Hub.HubClients;
  13. using OASystem.API.OAMethodLib.Hub.Hubs;
  14. using OASystem.API.OAMethodLib.JuHeAPI;
  15. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  16. using OASystem.Domain.Dtos.CRM;
  17. using OASystem.Domain.Dtos.FileDto;
  18. using OASystem.Domain.Dtos.Groups;
  19. using OASystem.Domain.Entities.Customer;
  20. using OASystem.Domain.Entities.Financial;
  21. using OASystem.Domain.Entities.Groups;
  22. using OASystem.Domain.ViewModels.Groups;
  23. using OASystem.Infrastructure.Repositories.Groups;
  24. using Quartz.Util;
  25. using SqlSugar.Extensions;
  26. using System.Collections;
  27. using System.Data;
  28. using System.Diagnostics;
  29. using System.Globalization;
  30. using System.Reflection.PortableExecutable;
  31. using Ubiety.Dns.Core;
  32. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  33. using Bookmark = Aspose.Words.Bookmark;
  34. using Cell = Aspose.Words.Tables.Cell;
  35. using Table = Aspose.Words.Tables.Table;
  36. namespace OASystem.API.Controllers
  37. {
  38. /// <summary>
  39. /// 团组相关
  40. /// </summary>
  41. //[Authorize]
  42. [Route("api/[controller]/[action]")]
  43. public class GroupsController : ControllerBase
  44. {
  45. private readonly ILogger<GroupsController> _logger;
  46. private readonly GrpScheduleRepository _grpScheduleRep;
  47. private readonly IMapper _mapper;
  48. private readonly DelegationInfoRepository _groupRepository;
  49. private readonly TaskAssignmentRepository _taskAssignmentRep;
  50. private readonly AirTicketResRepository _airTicketResRep;
  51. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  52. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  53. private readonly DelegationEnDataRepository _delegationEnDataRep;
  54. private readonly DelegationVisaRepository _delegationVisaRep;
  55. private readonly VisaPriceRepository _visaPriceRep;
  56. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  57. private readonly HotelPriceRepository _hotelPriceRep;
  58. private readonly CustomersRepository _customersRep;
  59. private readonly MessageRepository _message;
  60. private readonly SqlSugarClient _sqlSugar;
  61. private readonly TourClientListRepository _tourClientListRep;
  62. private readonly TeamRateRepository _teamRateRep;
  63. #region 成本相关
  64. private readonly CheckBoxsRepository _checkBoxs;
  65. private readonly GroupCostRepository _GroupCostRepository;
  66. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  67. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  68. #endregion
  69. private readonly SetDataRepository _setDataRep;
  70. private string url;
  71. private string path;
  72. private readonly EnterExitCostRepository _enterExitCostRep;
  73. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  74. private readonly UsersRepository _usersRep;
  75. private readonly IJuHeApiService _juHeApi;
  76. private readonly InvertedListRepository _invertedListRep;
  77. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  78. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  79. private readonly ThreeCodeRepository _threeCodeRepository;
  80. private readonly HotelInquiryRepository _hotelInquiryRep;
  81. private readonly FeeAuditRepository _feeAuditRep;
  82. private readonly VisaCommissionRepository _visaCommissionRep;
  83. public GroupsController(ILogger<GroupsController> logger, IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  84. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  85. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  86. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  87. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  88. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  89. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  90. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  91. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep, VisaCommissionRepository visaCommissionRep)
  92. {
  93. _logger = logger;
  94. _mapper = mapper;
  95. _grpScheduleRep = grpScheduleRep;
  96. _groupRepository = groupRepository;
  97. _taskAssignmentRep = taskAssignmentRep;
  98. _airTicketResRep = airTicketResRep;
  99. _sqlSugar = sqlSugar;
  100. url = AppSettingsHelper.Get("ExcelBaseUrl");
  101. path = AppSettingsHelper.Get("ExcelBasePath");
  102. if (!System.IO.Directory.Exists(path))
  103. {
  104. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  105. }
  106. _decreasePaymentsRep = decreasePaymentsRep;
  107. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  108. _delegationEnDataRep = delegationEnDataRep;
  109. _enterExitCostRep = enterExitCostRep;
  110. _delegationVisaRep = delegationVisaRep;
  111. _message = message;
  112. _visaPriceRep = visaPriceRep;
  113. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  114. _checkBoxs = checkBoxs;
  115. _GroupCostRepository = GroupCostRepository;
  116. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  117. _GroupCostParameterRepository = GroupCostParameterRepository;
  118. _hotelPriceRep = hotelPriceRep;
  119. _customersRep = customersRep;
  120. _setDataRep = setDataRep;
  121. _tourClientListRep = tourClientListRep;
  122. _teamRateRep = teamRateRep;
  123. _hubContext = hubContext;
  124. _usersRep = usersRep;
  125. _juHeApi = juHeApi;
  126. _invertedListRep = invertedListRep;
  127. _visaFeeInfoRep = visaFeeInfoRep;
  128. _ticketBlackCodeRep = ticketBlackCodeRep;
  129. _hotelInquiryRep = hotelInquiryRep;
  130. _threeCodeRepository = threeCodeRepository;
  131. _feeAuditRep = feeAuditRep;
  132. _visaCommissionRep = visaCommissionRep;
  133. }
  134. #region 流程管控
  135. /// <summary>
  136. /// 获取团组流程管控信息
  137. /// </summary>
  138. /// <param name="paras">参数Json字符串</param>
  139. /// <returns></returns>
  140. [HttpPost]
  141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  142. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  143. {
  144. if (string.IsNullOrEmpty(_jsonDto.Paras))
  145. {
  146. return Ok(JsonView(false, "参数为空"));
  147. }
  148. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  149. if (_ScheduleDto != null)
  150. {
  151. if (_ScheduleDto.SearchType == 2)//获取列表
  152. {
  153. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  154. return Ok(JsonView(_grpScheduleViewList));
  155. }
  156. else//获取对象
  157. {
  158. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  159. if (_grpScheduleView != null)
  160. {
  161. return Ok(JsonView(_grpScheduleView));
  162. }
  163. }
  164. }
  165. else
  166. {
  167. return Ok(JsonView(false, "参数反序列化失败"));
  168. }
  169. return Ok(JsonView(false, "暂无数据!"));
  170. }
  171. /// <summary>
  172. /// 修改团组流程管控详细表数据
  173. /// </summary>
  174. /// <param name="paras"></param>
  175. /// <returns></returns>
  176. [HttpPost]
  177. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  178. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  179. {
  180. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  181. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  182. .SetColumns(it => it.Duty == _detail.Duty)
  183. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  184. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  185. .SetColumns(it => it.JobContent == _detail.JobContent)
  186. .SetColumns(it => it.Remark == _detail.Remark)
  187. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  188. .Where(s => s.Id == dto.Id)
  189. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  190. .ExecuteCommandAsync();
  191. if (result > 0)
  192. {
  193. return Ok(JsonView(true, "保存成功!"));
  194. }
  195. return Ok(JsonView(false, "保存失败!"));
  196. }
  197. /// <summary>
  198. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  199. /// </summary>
  200. /// <param name="dto"></param>
  201. /// <returns></returns>
  202. [HttpPost]
  203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  204. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  205. {
  206. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  207. _detail.IsDel = 1;
  208. _detail.DeleteUserId = dto.Duty;
  209. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  210. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  211. .SetColumns(it => it.IsDel == _detail.IsDel)
  212. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  213. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  214. .Where(it => it.Id == dto.Id)
  215. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  216. //.WhereColumns(s => s.Id == dto.Id)
  217. .ExecuteCommandAsync();
  218. if (result > 0)
  219. {
  220. return Ok(JsonView(true, "删除成功!"));
  221. }
  222. return Ok(JsonView(false, "删除失败!"));
  223. }
  224. /// <summary>
  225. /// 增加团组流程管控详细表数据
  226. /// </summary>
  227. /// <param name="dto"></param>
  228. /// <returns></returns>
  229. [HttpPost]
  230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  231. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  232. {
  233. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  234. if (DateTime.Now < _detail.ExpectBeginDt)
  235. {
  236. _detail.StepStatus = 0;
  237. }
  238. else
  239. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  240. _detail.StepStatus = 1;
  241. }
  242. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  243. if (result > 0)
  244. {
  245. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  246. return Ok(JsonView(true, "添加成功!", _result));
  247. }
  248. return Ok(JsonView(false, "添加失败!"));
  249. }
  250. #endregion
  251. #region 团组基本信息
  252. /// <summary>
  253. /// 接团信息列表
  254. /// </summary>
  255. /// <param name="dto">团组列表请求dto</param>
  256. /// <returns></returns>
  257. [HttpPost]
  258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  259. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  260. {
  261. var groupData = await _groupRepository.GetGroupList(dto);
  262. if (groupData.Code != 0)
  263. {
  264. return Ok(JsonView(false, groupData.Msg));
  265. }
  266. return Ok(JsonView(groupData.Data));
  267. }
  268. /// <summary>
  269. /// 分页查询团组列表
  270. /// </summary>
  271. /// <param name="dto"></param>
  272. /// <returns></returns>
  273. [HttpPost]
  274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  275. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  276. {
  277. var watch = new Stopwatch();
  278. watch.Start();
  279. RefAsync<int> total = 0;
  280. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  281. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  282. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  283. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  284. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName , di.VisitPNumber , di.VisitCountry, di.VisitDays, di.VisitStartDate , di.VisitEndDate, di.TourCode })
  285. .Distinct()
  286. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  287. watch.Stop();
  288. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  289. }
  290. /// <summary>
  291. /// 接团信息列表 Page
  292. /// </summary>
  293. /// <param name="dto">团组列表请求dto</param>
  294. /// <returns></returns>
  295. [HttpPost]
  296. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  297. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  298. {
  299. #region 参数验证
  300. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  301. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  302. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  303. #region 页面操作权限验证
  304. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  305. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  306. #endregion
  307. #endregion
  308. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  309. {
  310. string sqlWhere = string.Empty;
  311. if (dto.IsSure == 0) //未完成
  312. {
  313. sqlWhere += string.Format(@" And IsSure = 0");
  314. }
  315. else if (dto.IsSure == 1) //已完成
  316. {
  317. sqlWhere += string.Format(@" And IsSure = 1");
  318. }
  319. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  320. {
  321. string tj = dto.SearchCriteria;
  322. 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}%')",
  323. tj, tj, tj, tj, tj);
  324. }
  325. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  326. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  327. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  328. JietuanOperator,IsSure,CreateTime,IsBid
  329. From (
  330. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  331. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  332. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  333. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  334. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  335. From Grp_DelegationInfo gdi
  336. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  337. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  338. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  339. Where gdi.IsDel = 0 {0}
  340. ) temp", sqlWhere);
  341. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  342. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  343. #region 处理所属部门
  344. /*
  345. * 1.sq 和 gyy 等显示 市场部
  346. * 2.王鸽和主管及张总还有管理员号统一国交部
  347. * 2-1. 4 管理员 ,21 张海麟
  348. */
  349. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  350. List<int> userIds1 = new List<int>() { 4, 21 };
  351. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  352. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  353. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  354. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  355. .ToList();
  356. foreach (var item in _DelegationList)
  357. {
  358. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  359. }
  360. #endregion
  361. var _view = new
  362. {
  363. PageFuncAuth = pageFunAuthView,
  364. Data = _DelegationList
  365. };
  366. return Ok(JsonView(true, "查询成功!", _view, total));
  367. }
  368. else
  369. {
  370. return Ok(JsonView(false, "查询失败"));
  371. }
  372. }
  373. /// <summary>
  374. /// 团组列表
  375. /// </summary>
  376. /// <returns></returns>
  377. [HttpPost]
  378. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  379. {
  380. #region 参数验证
  381. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  382. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  383. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  384. #region 页面操作权限验证
  385. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  386. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  387. #endregion
  388. #endregion
  389. if (dto.PortType != 1 && dto.PortType != 2)
  390. {
  391. return Ok(JsonView(false, "查询失败!"));
  392. }
  393. string orderbyStr = "order by gdi.CreateTime Desc";
  394. string sqlWhere = string.Empty;
  395. if (dto.IsSure == 0) //未完成
  396. {
  397. sqlWhere += string.Format(@" And IsSure = 0");
  398. }
  399. else if (dto.IsSure == 1) //已完成
  400. {
  401. sqlWhere += string.Format(@" And IsSure = 1");
  402. }
  403. //团组类型
  404. if (dto.TeamDid > 0)
  405. {
  406. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  407. }
  408. //团组名称
  409. if (!string.IsNullOrEmpty(dto.TeamName))
  410. {
  411. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  412. }
  413. //客户名称
  414. if (!string.IsNullOrEmpty(dto.ClientName))
  415. {
  416. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  417. }
  418. //客户单位
  419. if (!string.IsNullOrEmpty(dto.ClientUnit))
  420. {
  421. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  422. }
  423. //出访时间
  424. if (!string.IsNullOrEmpty(dto.visitDataTime))
  425. {
  426. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  427. orderbyStr = "order by gdi.VisitDate";
  428. }
  429. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  430. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  431. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  432. JietuanOperator,IsSure,CreateTime
  433. From (
  434. Select row_number() over({0}) as Row_Number,
  435. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  436. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  437. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  438. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  439. From Grp_DelegationInfo gdi
  440. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  441. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  442. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  443. Where gdi.IsDel = 0 {1}
  444. ) temp ", orderbyStr, sqlWhere);
  445. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  446. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  447. #region 处理所属部门
  448. /*
  449. * 1.sq 和 gyy 等显示 市场部
  450. * 2.王鸽和主管及张总还有管理员号统一国交部
  451. * 2-1. 4 管理员 ,21 张海麟
  452. */
  453. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  454. List<int> userIds1 = new List<int>() { 4, 21 };
  455. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  456. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  457. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  458. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  459. .ToList();
  460. foreach (var item in _DelegationList)
  461. {
  462. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  463. }
  464. #endregion
  465. var _view = new
  466. {
  467. PageFuncAuth = pageFunAuthView,
  468. Data = _DelegationList
  469. };
  470. return Ok(JsonView(true, "查询成功!", _view, total));
  471. }
  472. /// <summary>
  473. /// 接团信息详情
  474. /// </summary>
  475. /// <param name="dto">团组info请求dto</param>
  476. /// <returns></returns>
  477. [HttpPost]
  478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  479. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  480. {
  481. var groupData = await _groupRepository.GetGroupInfo(dto);
  482. if (groupData.Code != 0)
  483. {
  484. return Ok(JsonView(false, groupData.Msg));
  485. }
  486. return Ok(JsonView(groupData.Data));
  487. }
  488. /// <summary>
  489. /// 接团信息 编辑添加
  490. /// 基础信息数据源
  491. /// </summary>
  492. /// <param name="dto"></param>
  493. /// <returns></returns>
  494. [HttpPost]
  495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  496. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  497. {
  498. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  499. if (groupData.Code != 0)
  500. {
  501. return Ok(JsonView(false, groupData.Msg));
  502. }
  503. return Ok(JsonView(groupData.Data));
  504. }
  505. /// <summary>
  506. /// 接团信息 操作(增改)
  507. /// </summary>
  508. /// <param name="dto"></param>
  509. /// <returns></returns>
  510. [HttpPost]
  511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  512. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  513. {
  514. try
  515. {
  516. var groupData = await _groupRepository.GroupOperation(dto);
  517. if (groupData.Code != 0)
  518. {
  519. return Ok(JsonView(false, groupData.Msg));
  520. }
  521. int diId = 0;
  522. //添加时 默认加入团组汇率
  523. if (dto.Status == 1) //添加
  524. {
  525. diId = groupData.Data;
  526. //添加默认币种
  527. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  528. //默认分配权限
  529. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  530. //消息提示 王鸽 主管号
  531. List<int> _managerIds = new List<int>() { 22, 32 };
  532. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  533. if (userIds.Count > 0)
  534. {
  535. userIds.Add(208);
  536. //创建团组管控
  537. GroupStepForDelegation.CreateWorkStep(diId);
  538. //发送消息
  539. string groupName = dto.TeamName;
  540. string createGroupUser = string.Empty;
  541. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  542. if (userInfo != null) createGroupUser = userInfo.CnName;
  543. string title = $"系统通知";
  544. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  545. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  546. }
  547. //默认创建倒推表
  548. await _invertedListRep._Create(dto.UserId, diId);
  549. }
  550. else if (dto.Status == 2)
  551. {
  552. diId = dto.Id;
  553. }
  554. return Ok(JsonView(true, "操作成功!", diId));
  555. }
  556. catch (Exception ex)
  557. {
  558. Logs("[response]" + JsonConvert.SerializeObject(dto));
  559. Logs(ex.Message);
  560. return Ok(JsonView(false, ex.Message));
  561. }
  562. }
  563. /// <summary>
  564. /// 接团流程操作(增改)
  565. /// 安卓端使用 建团时添加客户名单
  566. /// </summary>
  567. /// <param name="dto"></param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  572. {
  573. try
  574. {
  575. #region 参数验证
  576. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  577. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  578. #region 页面操作权限验证
  579. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  580. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  581. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  582. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  583. #endregion
  584. #endregion
  585. _sqlSugar.BeginTran();
  586. var _dto = new GroupOperationDto();
  587. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  588. var groupData = await _groupRepository.GroupOperation(_dto);
  589. if (groupData.Code != 0)
  590. {
  591. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  592. }
  593. int diId = 0;
  594. //添加时 默认加入团组汇率
  595. if (dto.Status == 1) //添加
  596. {
  597. diId = groupData.Data;
  598. //添加默认币种
  599. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  600. //默认分配权限
  601. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  602. //消息提示 王鸽 主管号
  603. List<int> _managerIds = new List<int>() { 22, 32 };
  604. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  605. if (userIds.Count > 0)
  606. {
  607. userIds.Add(208);
  608. //创建团组管控
  609. GroupStepForDelegation.CreateWorkStep(diId);
  610. //发送消息
  611. string groupName = dto.TeamName;
  612. string createGroupUser = string.Empty;
  613. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  614. if (userInfo != null) createGroupUser = userInfo.CnName;
  615. string title = $"系统通知";
  616. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  617. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  618. }
  619. }
  620. if (dto.Status == 2)
  621. {
  622. diId = dto.Id;
  623. if (diId == 0)
  624. {
  625. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  626. }
  627. }
  628. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  629. if (viewData.Code != 0)
  630. {
  631. _sqlSugar.RollbackTran();
  632. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  633. }
  634. _sqlSugar.CommitTran();
  635. return Ok(JsonView(true, "添加成功"));
  636. }
  637. catch (Exception ex)
  638. {
  639. _sqlSugar.RollbackTran();
  640. return Ok(JsonView(false, ex.Message));
  641. }
  642. }
  643. /// <summary>
  644. /// 接团信息 操作(删除)
  645. /// </summary>
  646. /// <param name="dto"></param>
  647. /// <returns></returns>
  648. [HttpPost]
  649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  650. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  651. {
  652. try
  653. {
  654. var groupData = await _groupRepository.GroupDel(dto);
  655. if (groupData.Code != 0)
  656. {
  657. return Ok(JsonView(false, groupData.Msg));
  658. }
  659. return Ok(JsonView(true));
  660. }
  661. catch (Exception ex)
  662. {
  663. Logs("[response]" + JsonConvert.SerializeObject(dto));
  664. Logs(ex.Message);
  665. return Ok(JsonView(false, ex.Message));
  666. }
  667. }
  668. /// <summary>
  669. /// 获取团组销售报价号
  670. /// 团组添加时 使用
  671. /// </summary>
  672. /// <returns></returns>
  673. [HttpPost]
  674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  675. public async Task<IActionResult> GetGroupSalesQuoteNo()
  676. {
  677. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  678. if (groupData.Code != 0)
  679. {
  680. return Ok(JsonView(false, groupData.Msg));
  681. }
  682. object salesQuoteNo = new
  683. {
  684. SalesQuoteNo = groupData.Data
  685. };
  686. return Ok(JsonView(salesQuoteNo));
  687. }
  688. /// <summary>
  689. /// 设置确认出团
  690. /// </summary>
  691. /// <param name="dto"></param>
  692. /// <returns></returns>
  693. [HttpPost]
  694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  695. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  696. {
  697. var groupData = await _groupRepository.ConfirmationGroup(dto);
  698. if (groupData.Code != 0)
  699. {
  700. return Ok(JsonView(false, groupData.Msg));
  701. }
  702. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  703. #region OA消息推送
  704. try
  705. {
  706. string groupName = groupInfo.TeamName;
  707. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  708. List<int> userIds = new List<int>();
  709. listUser.ForEach(s => userIds.Add(s.Id));
  710. string title = $"系统通知";
  711. string content = $"团组[{groupName}]已确认出团!";
  712. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  713. }
  714. catch (Exception ex)
  715. {
  716. }
  717. #endregion
  718. #region 应用推送
  719. try
  720. {
  721. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  722. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  723. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  724. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  725. {
  726. List<string> userList = new List<string>() { users.QiyeChatUserId };
  727. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  728. }
  729. }
  730. catch (Exception ex)
  731. {
  732. }
  733. #endregion
  734. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  735. return Ok(JsonView(true, "操作成功!", groupData.Data));
  736. }
  737. /// <summary>
  738. /// 获取团组名称data And 签证国别Data
  739. /// </summary>
  740. /// <param name="dto"></param>
  741. /// <returns></returns>
  742. [HttpPost]
  743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  744. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  745. {
  746. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  747. if (groupData.Code != 0)
  748. {
  749. return Ok(JsonView(false, groupData.Msg));
  750. }
  751. return Ok(JsonView(groupData.Data));
  752. }
  753. /// <summary>
  754. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  755. /// </summary>
  756. /// <returns></returns>
  757. [HttpPost]
  758. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  759. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  760. {
  761. try
  762. {
  763. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  764. if (groupData.Code != 0)
  765. {
  766. return Ok(JsonView(false, groupData.Msg));
  767. }
  768. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  769. }
  770. catch (Exception ex)
  771. {
  772. return Ok(JsonView(false, "程序错误!"));
  773. throw;
  774. }
  775. }
  776. #endregion
  777. #region 团组&签证
  778. /// <summary>
  779. /// 根据团组Id获取签证客户信息List
  780. /// </summary>
  781. /// <param name="dto">请求dto</param>
  782. /// <returns></returns>
  783. [HttpPost]
  784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  785. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  786. {
  787. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  788. if (groupData.Code != 0)
  789. {
  790. return Ok(JsonView(false, groupData.Msg));
  791. }
  792. return Ok(JsonView(groupData.Data));
  793. }
  794. /// <summary>
  795. /// IOS获取团组签证拍照上传进度01(团组列表)
  796. /// </summary>
  797. /// <param name="dto">请求dto</param>
  798. /// <returns></returns>
  799. [HttpPost]
  800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  801. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  802. {
  803. if (dto == null)
  804. {
  805. return Ok(JsonView(false, "参数为空"));
  806. }
  807. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  808. return Ok(JsonView(visaList));
  809. }
  810. /// <summary>
  811. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  812. /// </summary>
  813. /// <returns></returns>
  814. [HttpPost]
  815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  816. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  817. {
  818. if (dto == null)
  819. {
  820. return Ok(JsonView(false, "请求错误:"));
  821. }
  822. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  823. return Ok(JsonView(list));
  824. }
  825. /// <summary>
  826. /// IOS获取团组签证拍照上传进度03(相册)
  827. /// </summary>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  832. {
  833. if (dto == null)
  834. {
  835. return Ok(JsonView(false, "请求错误:"));
  836. }
  837. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  838. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  839. list.ForEach(s => s.url = url);
  840. return Ok(JsonView(list));
  841. }
  842. /// <summary>
  843. /// IOS获取团组签证拍照上传进度04(图片上传)
  844. /// </summary>
  845. /// <param name="dto"></param>
  846. /// <returns></returns>
  847. [HttpPost]
  848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  849. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  850. {
  851. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  852. //if (!string.IsNullOrEmpty(result))
  853. //{
  854. //}
  855. //else {
  856. // return Ok(JsonView(false, "上传失败"));
  857. //}
  858. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  859. int sucNum = 0;
  860. try
  861. {
  862. foreach (var item in dto.base64DataList)
  863. {
  864. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  865. string result = decodeBase64ToImage(item, imageName);
  866. if (!string.IsNullOrEmpty(result))
  867. {
  868. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  869. pic.CreateUserId = dto.CreateUserId;
  870. pic.PicName = imageName;
  871. pic.PicPath = result;
  872. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  873. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  874. if (insertResult > 0)
  875. {
  876. sucNum++;
  877. }
  878. }
  879. }
  880. }
  881. catch (Exception ex)
  882. {
  883. return Ok(JsonView(false, ex.Message));
  884. }
  885. string msg = string.Format(@"成功上传{0}张", sucNum);
  886. return Ok(JsonView(true, msg));
  887. }
  888. private string decodeBase64ToImage(string base64DataURL, string imgName)
  889. {
  890. string filename = "";//声明一个string类型的相对路径
  891. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  892. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  893. try//会有异常抛出,try,catch一下
  894. {
  895. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  896. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  897. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  898. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  899. //文件名称
  900. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  901. //上传的文件的路径
  902. string filePath = "";
  903. if (!Directory.Exists(fileDir))
  904. {
  905. Directory.CreateDirectory(fileDir);
  906. }
  907. //上传的文件的路径
  908. filePath = fileDir + filename;
  909. //string url = HttpRuntime.AppDomainAppPath.ToString();
  910. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  911. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  912. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  913. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  914. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  915. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  916. ms.Close();//关闭当前流,并释放所有与之关联的资源
  917. bitmap.Dispose();
  918. }
  919. catch (Exception e)
  920. {
  921. string massage = e.Message;
  922. Logs("IOS图片上传Error:" + massage);
  923. //filename = e.Message;
  924. }
  925. return filename;//返回相对路径
  926. }
  927. /// <summary>
  928. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  929. /// </summary>
  930. /// <param name="dto"></param>
  931. /// <returns></returns>
  932. [HttpPost]
  933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  934. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  935. {
  936. if (dto == null)
  937. {
  938. return Ok(JsonView(false, "请求错误:"));
  939. }
  940. string msg = "参数错误";
  941. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  942. {
  943. try
  944. {
  945. //_delegationVisaRep.BeginTran();
  946. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  947. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  948. .Where(s => s.Id == dto.visaProgressCustomerId)
  949. .ExecuteCommandAsync();
  950. if (updCount > 0 && dto.publishCode == 1)
  951. {
  952. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  953. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  954. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  955. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  956. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  957. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  958. if (groupData == null)
  959. {
  960. _delegationVisaRep.RollbackTran();
  961. }
  962. string title = string.Format(@"[签证进度更新]");
  963. string content = string.Format(@"测试文本");
  964. bool rst = await _message.AddMsg(new MessageDto()
  965. {
  966. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  967. IssuerId = dto.publisher,
  968. Title = title,
  969. Content = content,
  970. ReleaseTime = DateTime.Now,
  971. UIdList = new List<int> {
  972. 234
  973. }
  974. });
  975. if (rst)
  976. {
  977. return Ok(JsonView(true, "发送通知成功"));
  978. }
  979. }
  980. //_delegationVisaRep.CommitTran();
  981. }
  982. catch (Exception)
  983. {
  984. //_delegationVisaRep.RollbackTran();
  985. }
  986. }
  987. return Ok(JsonView(true, msg));
  988. }
  989. #endregion
  990. #region 团组任务分配
  991. /// <summary>
  992. /// 团组任务分配初始化
  993. /// </summary>
  994. /// <param name="dto"></param>
  995. /// <returns></returns>
  996. [HttpPost]
  997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  998. public async Task<IActionResult> GetTaskAssignmen()
  999. {
  1000. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1001. if (groupData.Code != 0)
  1002. {
  1003. return Ok(JsonView(false, groupData.Msg));
  1004. }
  1005. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1006. }
  1007. /// <summary>
  1008. /// 团组任务分配查询
  1009. /// </summary>
  1010. /// <param name="dto"></param>
  1011. /// <returns></returns>
  1012. [HttpPost]
  1013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1014. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1015. {
  1016. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1017. if (groupData.Code != 0)
  1018. {
  1019. return Ok(JsonView(false, groupData.Msg));
  1020. }
  1021. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1022. }
  1023. /// <summary>
  1024. /// 团组任务分配操作
  1025. /// </summary>
  1026. /// <param name="dto"></param>
  1027. /// <returns></returns>
  1028. [HttpPost]
  1029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1030. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1031. {
  1032. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1033. if (groupData.Code != 0)
  1034. {
  1035. return Ok(JsonView(false, groupData.Msg));
  1036. }
  1037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1038. }
  1039. /// <summary>
  1040. /// 团组任务分配
  1041. /// 批量分配
  1042. /// 查询团组
  1043. /// </summary>
  1044. /// <param name="dto"></param>
  1045. /// <returns></returns>
  1046. [HttpPost]
  1047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1048. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1049. {
  1050. //参数验证
  1051. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1052. if (!DateTime.TryParse(dto.VisitBeginDt,out _) || !DateTime.TryParse(dto.VisitEndDt,out _))
  1053. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1054. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1055. }
  1056. /// <summary>
  1057. /// 团组任务分配
  1058. /// 批量分配
  1059. /// </summary>
  1060. /// <param name="dto"></param>
  1061. /// <returns></returns>
  1062. [HttpPost]
  1063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1064. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1065. {
  1066. //参数验证
  1067. if (dto.UserId < 1 ) return Ok(JsonView(false, MsgTips.UserId));
  1068. if (dto.OperateId < 1) return Ok(JsonView(false, MsgTips.OperateId));
  1069. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请传入有效的GroupIds数组参数!"));
  1070. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1071. }
  1072. #endregion
  1073. #region 团组费用审核
  1074. /// <summary>
  1075. /// 费用审核
  1076. /// 团组列表 Page
  1077. /// </summary>
  1078. /// <param name="_dto">团组列表请求dto</param>
  1079. /// <returns></returns>
  1080. [HttpPost]
  1081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1082. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1083. {
  1084. #region 参数验证
  1085. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1086. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1087. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1088. #region 页面操作权限验证
  1089. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1090. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1091. #endregion
  1092. #endregion
  1093. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1094. {
  1095. string sqlWhere = string.Empty;
  1096. if (_dto.IsSure == 0) //未完成
  1097. {
  1098. sqlWhere += string.Format(@" And IsSure = 0");
  1099. }
  1100. else if (_dto.IsSure == 1) //已完成
  1101. {
  1102. sqlWhere += string.Format(@" And IsSure = 1");
  1103. }
  1104. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1105. {
  1106. string tj = _dto.SearchCriteria;
  1107. 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}%')",
  1108. tj, tj, tj, tj, tj);
  1109. }
  1110. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1111. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1112. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1113. From (
  1114. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1115. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1116. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1117. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1118. From Grp_DelegationInfo gdi
  1119. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1120. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1121. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1122. Where gdi.IsDel = 0 {0}
  1123. ) temp ", sqlWhere);
  1124. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1125. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1126. var _view = new
  1127. {
  1128. PageFuncAuth = pageFunAuthView,
  1129. Data = _DelegationList
  1130. };
  1131. return Ok(JsonView(true, "查询成功!", _view, total));
  1132. }
  1133. else
  1134. {
  1135. return Ok(JsonView(false, "查询失败"));
  1136. }
  1137. }
  1138. /// <summary>
  1139. /// 获取团组费用审核
  1140. /// </summary>
  1141. /// <param name="paras">参数Json字符串</param>
  1142. /// <returns></returns>
  1143. [HttpPost]
  1144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1145. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1146. {
  1147. try
  1148. {
  1149. #region 参数验证
  1150. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1151. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1152. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1153. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1154. #region 页面操作权限验证
  1155. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1156. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1157. #endregion
  1158. #endregion
  1159. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1160. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1161. #region 费用清单
  1162. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1163. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1164. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1165. List<Grp_CreditCardPayment> entityList = _groupRepository
  1166. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1167. .Where(exp.ToExpression())
  1168. .ToList();
  1169. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1170. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1171. /*
  1172. * 76://酒店预订
  1173. */
  1174. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1175. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1178. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1179. .ToListAsync();
  1180. /*
  1181. * 79://车/导游地接
  1182. */
  1183. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1187. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1188. .ToListAsync();
  1189. /*
  1190. * 80: //签证
  1191. */
  1192. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1193. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1194. .ToListAsync();
  1195. /*
  1196. *81: //邀请/公务活动
  1197. */
  1198. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1199. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1200. .ToListAsync();
  1201. /*
  1202. * 82: //团组客户保险
  1203. */
  1204. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1205. /*
  1206. * Lable = 85 机票预订
  1207. */
  1208. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1209. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1210. .ToListAsync();
  1211. /*
  1212. * 85 机票预定
  1213. */
  1214. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1215. /*
  1216. * 98 其他款项
  1217. */
  1218. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1219. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1220. .ToListAsync();
  1221. /*
  1222. * 285:收款退还
  1223. */
  1224. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1225. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1226. .ToListAsync();
  1227. /*
  1228. * 1015: //超支费用
  1229. */
  1230. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1231. /*
  1232. * 币种信息
  1233. */
  1234. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1235. /*
  1236. * 车/导游地接 费用类型
  1237. */
  1238. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1239. /*
  1240. * 车/导游地接 费用类型
  1241. */
  1242. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1243. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1244. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1245. /*
  1246. * 用户信息
  1247. */
  1248. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1249. /*
  1250. * 费用模块
  1251. */
  1252. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1253. string priceModule = string.Empty;
  1254. if (sdPriceName != null)
  1255. {
  1256. priceModule = sdPriceName.Name;
  1257. }
  1258. /*
  1259. * 成本信息
  1260. */
  1261. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1262. decimal _groupRate = 0.0000M;
  1263. string _groupCurrencyCode = "-";
  1264. if (groupCost != null)
  1265. {
  1266. _groupRate = groupCost.Rate;
  1267. if (int.TryParse(groupCost.Currency, out int _currency))
  1268. {
  1269. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1270. }
  1271. else _groupCurrencyCode = groupCost.Currency;
  1272. }
  1273. string costContentSql = $"Select * From Grp_GroupCost";
  1274. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1275. //处理日期为空的天数
  1276. for (int i = 0; i < groupCostDetails.Count; i++)
  1277. if (i != 0)
  1278. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1279. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1280. /*
  1281. * 处理详情数据
  1282. */
  1283. foreach (var entity in entityList)
  1284. {
  1285. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1286. _detail.Id = entity.Id;
  1287. _detail.PriceName = priceModule;
  1288. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1289. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1290. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1291. /*
  1292. * 应付款金额
  1293. */
  1294. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1295. string PaymentCurrency_WaitPay = "Unknown";
  1296. string hotelCurrncyCode = "Unknown";
  1297. string hotelCurrncyName = "Unknown";
  1298. if (sdPaymentCurrency_WaitPay != null)
  1299. {
  1300. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1301. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1302. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1303. if (hotelCurrncyCode.Equals("CNY"))
  1304. {
  1305. entity.DayRate = 1.0000M;
  1306. }
  1307. }
  1308. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1309. /*
  1310. * 此次付款金额
  1311. */
  1312. decimal CurrPayStr = 0;
  1313. if (entity.PayPercentage == 0)
  1314. {
  1315. if (entity.PayThenMoney != 0)
  1316. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1317. }
  1318. else
  1319. {
  1320. if (entity.PayMoney != 0)
  1321. {
  1322. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1323. }
  1324. }
  1325. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1326. /*
  1327. * 剩余尾款
  1328. */
  1329. decimal BalanceStr = 0;
  1330. if (CurrPayStr != 0)
  1331. {
  1332. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1333. BalanceStr = 0;
  1334. else
  1335. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1336. }
  1337. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1338. /*
  1339. * Bus名称
  1340. */
  1341. _detail.BusName = "待增加";
  1342. /*
  1343. *费用所属
  1344. */
  1345. switch (entity.CTable)
  1346. {
  1347. case 76://酒店预订
  1348. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1349. if (hotelReservations != null)
  1350. {
  1351. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1352. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1353. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1354. string roomFeeStr = "", roomFeestr1 = "";
  1355. //是否比较房型价格
  1356. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1357. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1358. roomFeeStr += $"<br/>";
  1359. if (hotelReservations.SingleRoomPrice > 0)
  1360. {
  1361. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}<br/>";
  1362. __isSingle = true;
  1363. }
  1364. if (hotelReservations.DoubleRoomPrice > 0)
  1365. {
  1366. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}<br/>";
  1367. __isDouble = true;
  1368. }
  1369. if (hotelReservations.SuiteRoomPrice > 0)
  1370. {
  1371. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}<br/>";
  1372. __isSuite = true;
  1373. }
  1374. if (hotelReservations.OtherRoomPrice > 0)
  1375. {
  1376. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}";
  1377. __isOther = true;
  1378. }
  1379. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1380. else roomFeeStr += " 0.00 * 0";
  1381. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1382. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1383. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1384. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1385. /*
  1386. * 费用类型
  1387. * 1:房费
  1388. * 2:早餐
  1389. * 3:地税
  1390. * 4:城市税
  1391. * </summary>
  1392. */
  1393. //地税
  1394. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1395. if (governmentRentData != null)
  1396. {
  1397. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1398. governmentRentFee = governmentRentData.Price;
  1399. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1400. if (governmentRentCurrData != null)
  1401. {
  1402. governmentRentCode = governmentRentCurrData.Name;
  1403. governmentRentName = $"({governmentRentCurrData.Remark})";
  1404. }
  1405. }
  1406. //城市税
  1407. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1408. if (cityTaxData != null)
  1409. {
  1410. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1411. cityTaxFee = cityTaxData.Price;
  1412. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1413. if (cityTaxCurrData != null)
  1414. {
  1415. cityTaxCode = cityTaxCurrData.Name;
  1416. cityTaxName = $"({cityTaxCurrData.Remark})";
  1417. }
  1418. }
  1419. //酒店早餐
  1420. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1421. if (breakfastData != null)
  1422. {
  1423. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1424. breakfastFee = breakfastData.Price;
  1425. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1426. if (breakfastCurrData != null)
  1427. {
  1428. breakfastCode = breakfastCurrData.Name;
  1429. breakfastName = $"({breakfastCurrData.Remark})";
  1430. }
  1431. }
  1432. //房间费用
  1433. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1434. if (roomData != null)
  1435. {
  1436. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1437. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1438. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1439. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1440. roomFee = roomData.Price;
  1441. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1442. if (roomCurrData != null)
  1443. {
  1444. roomCode = roomCurrData.Name;
  1445. roomName = $"({roomCurrData.Remark})";
  1446. }
  1447. }
  1448. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1449. string hotelCostStr = "";
  1450. decimal hotelCsotTotal = 0.00M;
  1451. if (groupCost != null)
  1452. {
  1453. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1454. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1455. }
  1456. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1457. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1458. string hotelCost_day = "";
  1459. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1460. foreach (var item in hotelCostDetails1)
  1461. {
  1462. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1463. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1464. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1465. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1466. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1467. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1468. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1469. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1470. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1471. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1472. hotelCost_day += @$"</br>";
  1473. }
  1474. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1475. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1476. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1477. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1478. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1479. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1480. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1481. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1482. $"房间说明: {hotelReservations.Remark} <br/>" +
  1483. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} 是否由地接代付:{roomBool}<br/><br/>" +
  1484. $"{hotelBreakfastStr}" +
  1485. $"{hotelGovernmentRentStr}" +
  1486. $"{hotelCityTaxStr}";
  1487. _detail.PriceNameContent = hotelReservations.HotelName;
  1488. }
  1489. break;
  1490. case 79://车/导游地接
  1491. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1492. if (touristGuideGroundReservations != null)
  1493. {
  1494. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1495. {
  1496. _detail.BusName = touristGuideGroundReservations.BusName;
  1497. }
  1498. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1499. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1500. //if (isInt)
  1501. //{
  1502. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1503. // if (cityInfo != null)
  1504. // {
  1505. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1506. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1507. // if (carFeeItem != null)
  1508. // {
  1509. // nameContent += $@"({carFeeItem.Name})";
  1510. // }
  1511. // _detail.PriceNameContent = nameContent;
  1512. // }
  1513. //}
  1514. //else
  1515. //{
  1516. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1517. //}
  1518. var touristGuideGroundReservationsContents =
  1519. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1520. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1521. foreach (var item in touristGuideGroundReservationsContents)
  1522. {
  1523. string typeName = "Unknown";
  1524. string carCurrencyCode = "Unknown";
  1525. string carCurrencyName = "Unknown";
  1526. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1527. if (carTypeData != null) typeName = carTypeData.Name;
  1528. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1529. if (currencyData != null)
  1530. {
  1531. carCurrencyCode = currencyData.Name;
  1532. carCurrencyName = currencyData.Remark;
  1533. }
  1534. //op、成本 币种是否一致
  1535. bool IsCurrencyAgreement = false;
  1536. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  1537. string opCostStr = string.Empty;
  1538. decimal opCostTypePrice = 0.00M;
  1539. #region 处理成本各项费用
  1540. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1541. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1542. if (opCost.Count > 0)
  1543. {
  1544. switch (item.SId)
  1545. {
  1546. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1547. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1548. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1549. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1550. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1551. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1552. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1553. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1554. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1555. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1556. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1557. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1558. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1559. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1560. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1561. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1562. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1563. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1564. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1565. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1566. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1567. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1568. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1569. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1570. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1571. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1572. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1573. }
  1574. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1575. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  1576. }
  1577. #endregion
  1578. string opTypeStr = $"{typeName}{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})" ;
  1579. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  1580. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1581. $"{opTypeStr} {opCostStr}<br/>" +
  1582. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1583. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1584. }
  1585. _detail.PriceMsgContent = priceMsg;
  1586. }
  1587. break;
  1588. case 80: //签证
  1589. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1590. if (visaInfo != null)
  1591. {
  1592. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  1593. _detail.PriceNameContent = visaInfo.VisaDescription ;
  1594. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  1595. }
  1596. break;
  1597. case 81: //邀请/公务活动
  1598. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1599. if (_ioa != null)
  1600. {
  1601. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1602. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1603. sendCurrName = "Unknown", //快递费用币种 Name
  1604. sendCurrCode = "Unknown", //快递费用币种 Code
  1605. eventsCurrName = "Unknown", //公务活动费币种 Name
  1606. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1607. translateCurrName = "Unknown", //公务翻译费 Name
  1608. translateCurrCode = "Unknown"; //公务翻译费 Code
  1609. #region 处理费用币种
  1610. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1611. if (inviteCurrData != null)
  1612. {
  1613. inviteCurrName = inviteCurrData.Remark;
  1614. inviteCurrCode = inviteCurrData.Name;
  1615. }
  1616. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1617. if (sendCurrData != null)
  1618. {
  1619. sendCurrName = sendCurrData.Remark;
  1620. sendCurrCode = sendCurrData.Name;
  1621. }
  1622. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1623. if (eventsCurrData != null)
  1624. {
  1625. eventsCurrName = eventsCurrData.Remark;
  1626. eventsCurrCode = eventsCurrData.Name;
  1627. }
  1628. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1629. if (translateCurrData != null)
  1630. {
  1631. translateCurrName = translateCurrData.Remark;
  1632. translateCurrCode = translateCurrData.Name;
  1633. }
  1634. #endregion
  1635. _detail.PriceNameContent = _ioa.InviterArea;
  1636. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1637. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1638. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1639. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1640. $@"备注:" + _ioa.Remark + "<br/>";
  1641. }
  1642. break;
  1643. case 82: //团组客户保险
  1644. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1645. if (customers != null)
  1646. {
  1647. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1648. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1649. }
  1650. break;
  1651. case 85: //机票预订
  1652. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1653. if (jpRes != null)
  1654. {
  1655. string FlightsDescription = jpRes.FlightsDescription;
  1656. string PriceDescription = jpRes.PriceDescription;
  1657. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1658. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1659. }
  1660. break;
  1661. case 98://其他款项
  1662. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1663. if (gdpRes != null)
  1664. {
  1665. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1666. _detail.PriceNameContent = gdpRes.PriceName;
  1667. }
  1668. break;
  1669. case 285://收款退还
  1670. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1671. if (refundAndOtherMoney != null)
  1672. {
  1673. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1674. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1675. }
  1676. break;
  1677. case 751://酒店早餐
  1678. break;
  1679. case 1015://超支费用
  1680. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1681. if (groupExtraCost != null)
  1682. {
  1683. _detail.PriceNameContent = groupExtraCost.PriceName;
  1684. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1685. }
  1686. break;
  1687. default:
  1688. break;
  1689. }
  1690. /*
  1691. * 申请人
  1692. */
  1693. string operatorName = " - ";
  1694. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1695. if (_opUser != null)
  1696. {
  1697. operatorName = _opUser.CnName;
  1698. }
  1699. _detail.OperatorName = operatorName;
  1700. /*
  1701. * 审核人
  1702. */
  1703. string auditOperatorName = "Unknown";
  1704. if (entity.AuditGMOperate == 0)
  1705. auditOperatorName = " - ";
  1706. else if (entity.AuditGMOperate == 4)
  1707. auditOperatorName = "自动审核";
  1708. else
  1709. {
  1710. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1711. if (_adUser != null)
  1712. {
  1713. auditOperatorName = _adUser.CnName;
  1714. }
  1715. }
  1716. _detail.AuditOperatorName = auditOperatorName;
  1717. /*
  1718. * 超预算比例
  1719. */
  1720. string overBudgetStr = "";
  1721. if (entity.ExceedBudget == -1)
  1722. overBudgetStr = sdPriceName.Name + "尚无预算";
  1723. else if (entity.ExceedBudget == 0)
  1724. {
  1725. if (entity.CTable == 76 || entity.CTable == 79)
  1726. {
  1727. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1728. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  1729. }
  1730. else
  1731. {
  1732. overBudgetStr = "未超预算";
  1733. }
  1734. }
  1735. else
  1736. overBudgetStr = entity.ExceedBudget.ToString("P");
  1737. _detail.OverBudget = overBudgetStr;
  1738. /*
  1739. * 费用总计
  1740. */
  1741. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1742. {
  1743. CurrencyId = entity.PaymentCurrency,
  1744. CurrencyName = PaymentCurrency_WaitPay,
  1745. AmountPayable = entity.PayMoney,
  1746. ThisPayment = CurrPayStr,
  1747. BalancePayment = BalanceStr,
  1748. AuditedFunds = CurrPayStr
  1749. });
  1750. _detail.IsAuditGM = entity.IsAuditGM;
  1751. detailList.Add(_detail);
  1752. }
  1753. #endregion
  1754. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1755. /*
  1756. * 下方描述处理
  1757. */
  1758. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1759. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1760. if (ccpCurrencyPrice != null)
  1761. {
  1762. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1763. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1764. }
  1765. else
  1766. {
  1767. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1768. }
  1769. string amountPayableStr = string.Format(@"应付款总金额: ");
  1770. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1771. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1772. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1773. foreach (var item in nonDuplicat)
  1774. {
  1775. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1776. if (strs.Count > 0)
  1777. {
  1778. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1779. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1780. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1781. //单独处理此次付款金额
  1782. if (item.CurrencyId == 836) //人民币
  1783. {
  1784. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1785. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1786. }
  1787. else
  1788. {
  1789. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1790. }
  1791. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1792. //单独处理已审核费用
  1793. if (item.CurrencyId == 836) //人民币
  1794. {
  1795. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1796. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1797. }
  1798. else
  1799. {
  1800. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1801. }
  1802. }
  1803. }
  1804. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1805. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1806. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1807. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1808. var _view1 = new
  1809. {
  1810. PageFuncAuth = pageFunAuthView,
  1811. Data = _view
  1812. };
  1813. return Ok(JsonView(_view1));
  1814. }
  1815. catch (Exception ex)
  1816. {
  1817. return Ok(JsonView(false, ex.Message));
  1818. }
  1819. }
  1820. /// <summary>
  1821. /// 费用审核
  1822. /// 修改团组费用审核状态
  1823. /// </summary>
  1824. /// <param name="_dto">参数Json字符串</param>
  1825. /// <returns></returns>
  1826. [HttpPost]
  1827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1828. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1829. {
  1830. #region 参数验证
  1831. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1832. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1833. #endregion
  1834. #region 页面操作权限验证
  1835. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1836. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1837. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1838. #endregion
  1839. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1840. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1841. DateTime dtNow = DateTime.Now;
  1842. _groupRepository.BeginTran();
  1843. int rst = 0;
  1844. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1845. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1846. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1847. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1848. List<dynamic> msgDatas = new List<dynamic>();
  1849. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1850. foreach (var item in idList)
  1851. {
  1852. int CreditId = int.Parse(item);
  1853. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1854. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1855. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1856. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1857. .Where(s => s.Id == CreditId)
  1858. .ExecuteCommandAsync();
  1859. if (result < 1)
  1860. {
  1861. rst = -1;
  1862. _groupRepository.RollbackTran();
  1863. return Ok(JsonView(false, "操作失败并回滚!"));
  1864. }
  1865. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1866. if (creditData != null)
  1867. {
  1868. #region 应用通知配置
  1869. try
  1870. {
  1871. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1872. }
  1873. catch (Exception ex)
  1874. {
  1875. }
  1876. #endregion
  1877. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1878. string groupNameStr = string.Empty;
  1879. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1880. if (groupData != null) groupNameStr = groupData.TeamName;
  1881. string creditTypeStr = string.Empty;
  1882. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1883. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1884. string creditCurrency = string.Empty;
  1885. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1886. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1887. if (creditCurrency.Equals("CNY"))
  1888. {
  1889. creditData.DayRate = 1.0000M;
  1890. }
  1891. if (creditData.PayPercentage == 0.00M)
  1892. {
  1893. creditData.PayPercentage = 100M;
  1894. }
  1895. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1896. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1897. string msgContent = "";
  1898. if (creditCurrency.Equals("CNY"))
  1899. {
  1900. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1901. }
  1902. else
  1903. {
  1904. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1905. }
  1906. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1907. }
  1908. }
  1909. if (rst == 0)
  1910. {
  1911. _groupRepository.CommitTran();
  1912. foreach (var item in msgDatas)
  1913. {
  1914. //发送消息
  1915. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1916. }
  1917. #region 应用推送
  1918. try
  1919. {
  1920. foreach (var ccpId in dic_ccp_user.Keys)
  1921. {
  1922. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1923. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1924. }
  1925. }
  1926. catch (Exception)
  1927. {
  1928. }
  1929. #endregion
  1930. return Ok(JsonView(true, "操作成功!"));
  1931. }
  1932. return Ok(JsonView(false, "操作失败!"));
  1933. }
  1934. #endregion
  1935. #region 机票费用录入
  1936. /// <summary>
  1937. /// 机票录入当前登录人可操作团组
  1938. /// </summary>
  1939. /// <param name="dto"></param>
  1940. /// <returns></returns>
  1941. [HttpPost]
  1942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1943. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1944. {
  1945. try
  1946. {
  1947. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1948. if (groupData.Code != 0)
  1949. {
  1950. return Ok(JsonView(false, groupData.Msg));
  1951. }
  1952. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1953. }
  1954. catch (Exception ex)
  1955. {
  1956. return Ok(JsonView(false, "程序错误!"));
  1957. throw;
  1958. }
  1959. }
  1960. /// <summary>
  1961. /// 机票费用录入列表
  1962. /// </summary>
  1963. /// <param name="dto"></param>
  1964. /// <returns></returns>
  1965. [HttpPost]
  1966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1967. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1968. {
  1969. try
  1970. {
  1971. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1972. if (groupData.Code != 0)
  1973. {
  1974. return Ok(JsonView(false, groupData.Msg));
  1975. }
  1976. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1977. }
  1978. catch (Exception ex)
  1979. {
  1980. return Ok(JsonView(false, ex.Message));
  1981. throw;
  1982. }
  1983. }
  1984. /// <summary>
  1985. /// 根据id查询费用录入信息
  1986. /// </summary>
  1987. /// <param name="dto"></param>
  1988. /// <returns></returns>
  1989. [HttpPost]
  1990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1991. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1992. {
  1993. try
  1994. {
  1995. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1996. if (groupData.Code != 0)
  1997. {
  1998. return Ok(JsonView(false, groupData.Msg));
  1999. }
  2000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2001. }
  2002. catch (Exception ex)
  2003. {
  2004. return Ok(JsonView(false, "程序错误!"));
  2005. throw;
  2006. }
  2007. }
  2008. /// <summary>
  2009. /// 机票费用录入操作(Status:1.新增,2.修改)
  2010. /// </summary>
  2011. /// <param name="dto"></param>
  2012. /// <returns></returns>
  2013. [HttpPost]
  2014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2015. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2016. {
  2017. try
  2018. {
  2019. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2020. if (groupData.Code != 0)
  2021. {
  2022. return Ok(JsonView(false, groupData.Msg));
  2023. }
  2024. #region 应用推送
  2025. try
  2026. {
  2027. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2028. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2029. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2030. }
  2031. catch (Exception ex)
  2032. {
  2033. }
  2034. #endregion
  2035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2036. }
  2037. catch (Exception ex)
  2038. {
  2039. return Ok(JsonView(false, "程序错误!"));
  2040. throw;
  2041. }
  2042. }
  2043. /// <summary>
  2044. /// 根据舱位类型查询接团客户名单信息
  2045. /// </summary>
  2046. /// <param name="dto"></param>
  2047. /// <returns></returns>
  2048. [HttpPost]
  2049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2050. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2051. {
  2052. try
  2053. {
  2054. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2055. if (crm_Groups.Count != 0)
  2056. {
  2057. List<dynamic> Customer = new List<dynamic>();
  2058. foreach (var item in crm_Groups)
  2059. {
  2060. var data = new
  2061. {
  2062. Id = item.Id,
  2063. Pinyin = item.Pinyin,
  2064. Name = item.LastName + item.FirstName
  2065. };
  2066. Customer.Add(data);
  2067. }
  2068. return Ok(JsonView(true, "查询成功!", Customer));
  2069. }
  2070. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2071. }
  2072. catch (Exception ex)
  2073. {
  2074. return Ok(JsonView(false, "程序错误!"));
  2075. throw;
  2076. }
  2077. }
  2078. /// <summary>
  2079. /// 根据团号获取客户信息
  2080. /// </summary>
  2081. /// <param name="dto"></param>
  2082. /// <returns></returns>
  2083. [HttpPost]
  2084. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2085. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2086. {
  2087. var jw = JsonView(false);
  2088. if (dto.DIID < 1)
  2089. {
  2090. jw.Msg += "请输入正确的diid";
  2091. return Ok(jw);
  2092. }
  2093. var arr = getSimplClientList(dto.DIID);
  2094. jw = JsonView(true, "获取成功!", arr);
  2095. return Ok(jw);
  2096. }
  2097. private List<SimplClientInfo> getSimplClientList(int diId)
  2098. {
  2099. 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);
  2100. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2101. return arr;
  2102. }
  2103. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2104. {
  2105. string result = origin;
  2106. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2107. {
  2108. string[] temparr = origin.Split(',');
  2109. string fistrStr = temparr[0];
  2110. int count = temparr.Count();
  2111. int tempId;
  2112. bool success = int.TryParse(fistrStr, out tempId);
  2113. if (success)
  2114. {
  2115. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2116. if (tempInfo != null)
  2117. {
  2118. if (count > 1)
  2119. {
  2120. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2121. }
  2122. else
  2123. {
  2124. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2125. }
  2126. }
  2127. }
  2128. }
  2129. return result;
  2130. }
  2131. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2132. {
  2133. string result = origin;
  2134. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2135. {
  2136. string[] temparr = origin.Split(',');
  2137. result = "";
  2138. foreach (var item in temparr)
  2139. {
  2140. int tempId;
  2141. bool success = int.TryParse(item, out tempId);
  2142. if (success)
  2143. {
  2144. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2145. if (tempInfo != null)
  2146. {
  2147. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2148. }
  2149. }
  2150. }
  2151. }
  2152. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2153. return result;
  2154. }
  2155. /// <summary>
  2156. /// 机票费用录入,删除
  2157. /// </summary>
  2158. /// <param name="dto"></param>
  2159. /// <returns></returns>
  2160. [HttpPost]
  2161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2162. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2163. {
  2164. try
  2165. {
  2166. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2167. if (res)
  2168. {
  2169. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2170. {
  2171. IsDel = 1,
  2172. DeleteUserId = dto.DeleteUserId,
  2173. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2174. }).ExecuteCommandAsync();
  2175. return Ok(JsonView(true, "删除成功!"));
  2176. }
  2177. return Ok(JsonView(false, "删除失败!"));
  2178. }
  2179. catch (Exception ex)
  2180. {
  2181. return Ok(JsonView(false, "程序错误!"));
  2182. throw;
  2183. }
  2184. }
  2185. /// <summary>
  2186. /// 导出机票录入报表
  2187. /// </summary>
  2188. /// <param name="dto"></param>
  2189. /// <returns></returns>
  2190. [HttpPost]
  2191. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2192. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2193. {
  2194. try
  2195. {
  2196. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2197. if (groupData.Code != 0)
  2198. {
  2199. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2200. }
  2201. else
  2202. {
  2203. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2204. if (AirTicketReservations.Count != 0)
  2205. {
  2206. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2207. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2208. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2209. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2210. WorkbookDesigner designer = new WorkbookDesigner();
  2211. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2212. decimal countCost = 0;
  2213. foreach (var item in AirTicketReservations)
  2214. {
  2215. #region 处理客人姓名
  2216. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2217. item.ClientName = clientNames;
  2218. #endregion
  2219. if (item.BankType == "其他")
  2220. {
  2221. item.BankNo = "--";
  2222. }
  2223. else
  2224. {
  2225. if (!string.IsNullOrEmpty(item.BankType))
  2226. {
  2227. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2228. }
  2229. }
  2230. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2231. item.Price = System.Decimal.Round(item.Price, 2);
  2232. countCost += Convert.ToDecimal(item.Price);
  2233. }
  2234. designer.SetDataSource("Export", AirTicketReservations);
  2235. designer.SetDataSource("ExportDiCode", diCode);
  2236. designer.SetDataSource("ExportDiName", diName);
  2237. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2238. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2239. designer.Process();
  2240. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2241. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2242. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2243. return Ok(JsonView(true, "成功", url = rst));
  2244. }
  2245. else
  2246. {
  2247. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2248. }
  2249. }
  2250. }
  2251. catch (Exception ex)
  2252. {
  2253. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2254. throw;
  2255. }
  2256. }
  2257. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2258. /// <summary>
  2259. /// 行程单导出
  2260. /// </summary>
  2261. /// <param name="dto"></param>
  2262. /// <returns></returns>
  2263. [HttpPost]
  2264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2265. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2266. {
  2267. try
  2268. {
  2269. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2270. if (groupData.Code != 0)
  2271. {
  2272. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2273. }
  2274. else
  2275. {
  2276. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2277. if (dto.Language == "CN")
  2278. {
  2279. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2280. DocumentBuilder builder = new DocumentBuilder(doc);
  2281. int tableIndex = 0;//表格索引
  2282. //得到文档中的第一个表格
  2283. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2284. foreach (var item in _AirTicketReservations)
  2285. {
  2286. #region 处理固定数据
  2287. string[] FlightsCode = item.FlightsCode.Split('/');
  2288. if (FlightsCode.Length != 0)
  2289. {
  2290. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2291. if (_AirCompany != null)
  2292. {
  2293. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2294. }
  2295. else
  2296. {
  2297. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2298. }
  2299. }
  2300. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2301. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2302. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2303. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2304. string name = "";
  2305. foreach (string clientName in nameArray)
  2306. {
  2307. if (!name.Contains(clientName))
  2308. {
  2309. name += clientName + ",";
  2310. }
  2311. }
  2312. if (!string.IsNullOrWhiteSpace(name))
  2313. {
  2314. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2315. }
  2316. else
  2317. {
  2318. table.Range.Bookmarks["ClientName"].Text = "--";
  2319. }
  2320. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2321. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2322. table.Range.Bookmarks["JointTicket"].Text = "--";
  2323. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2324. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2325. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2326. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2327. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2328. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2329. #endregion
  2330. #region 循环数据处理
  2331. List<AirInfo> airs = new List<AirInfo>();
  2332. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2333. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2334. for (int i = 0; i < FlightsCode.Length; i++)
  2335. {
  2336. AirInfo air = new AirInfo();
  2337. string[] tempstr = DayArray[i]
  2338. .Replace("\r\n", string.Empty)
  2339. .Replace("\\r\\n", string.Empty)
  2340. .TrimStart().TrimEnd()
  2341. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2342. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2343. string starCity = "";
  2344. if (star_Three != null)
  2345. {
  2346. starCity = star_Three.AirPort;
  2347. }
  2348. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2349. string EndCity = "";
  2350. if (End_Three != null)
  2351. {
  2352. EndCity = End_Three.AirPort;
  2353. }
  2354. air.Destination = starCity + "/" + EndCity;
  2355. air.Flight = FlightsCode[i];
  2356. air.SeatingClass = item.CTypeName;
  2357. string dateTime = tempstr[2];
  2358. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2359. air.FlightDate = DateTemp;
  2360. air.DepartureTime = tempstr[5];
  2361. air.LandingTime = tempstr[6];
  2362. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2363. air.TicketStatus = "--";
  2364. air.Luggage = "--";
  2365. air.DepartureTerminal = "--";
  2366. air.LandingTerminal = "--";
  2367. airs.Add(air);
  2368. }
  2369. int row = 13;
  2370. for (int i = 0; i < airs.Count; i++)
  2371. {
  2372. if (airs.Count > 2)
  2373. {
  2374. for (int j = 0; j < airs.Count - 2; j++)
  2375. {
  2376. var CopyRow = table.Rows[12].Clone(true);
  2377. table.Rows.Add(CopyRow);
  2378. }
  2379. }
  2380. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2381. int index = 0;
  2382. foreach (PropertyInfo property in properties)
  2383. {
  2384. string value = property.GetValue(airs[i]).ToString();
  2385. Cell ishcel0 = table.Rows[row].Cells[index];
  2386. Paragraph p = new Paragraph(doc);
  2387. string s = value;
  2388. p.AppendChild(new Run(doc, s));
  2389. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2390. ishcel0.AppendChild(p);
  2391. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2392. index++;
  2393. }
  2394. row++;
  2395. }
  2396. #endregion
  2397. Paragraph lastParagraph = new Paragraph(doc);
  2398. //第一个表格末尾加段落
  2399. table.ParentNode.InsertAfter(lastParagraph, table);
  2400. //复制第一个表格
  2401. Table cloneTable = (Table)table.Clone(true);
  2402. //在文档末尾段落后面加入复制的表格
  2403. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2404. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2405. {
  2406. int rownewsIndex = 13;
  2407. for (int i = 0; i < 2; i++)
  2408. {
  2409. var CopyRow = table.Rows[12].Clone(true);
  2410. table.Rows.RemoveAt(13);
  2411. table.Rows.Add(CopyRow);
  2412. rownewsIndex++;
  2413. }
  2414. }
  2415. else
  2416. {
  2417. table.Rows.RemoveAt(12);
  2418. }
  2419. cloneTable.Rows.RemoveAt(12);
  2420. }
  2421. if (_AirTicketReservations.Count != 0)
  2422. {
  2423. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2424. if (FlightsCode.Length != 0)
  2425. {
  2426. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2427. if (_AirCompany != null)
  2428. {
  2429. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2430. }
  2431. else
  2432. {
  2433. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2434. }
  2435. }
  2436. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2437. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2438. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2439. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2440. string name = "";
  2441. foreach (string clientName in nameArray)
  2442. {
  2443. if (!name.Contains(clientName))
  2444. {
  2445. name += clientName + ",";
  2446. }
  2447. }
  2448. if (!string.IsNullOrWhiteSpace(name))
  2449. {
  2450. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2451. }
  2452. else
  2453. {
  2454. table.Range.Bookmarks["ClientName"].Text = "--";
  2455. }
  2456. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2457. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2458. table.Range.Bookmarks["JointTicket"].Text = "--";
  2459. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2460. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2461. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2462. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2463. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2464. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2465. }
  2466. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2467. //保存合并后的文档
  2468. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2469. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2470. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2471. return Ok(JsonView(true, "成功!", rst));
  2472. }
  2473. else
  2474. {
  2475. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2476. DocumentBuilder builder = new DocumentBuilder(doc);
  2477. int tableIndex = 0;//表格索引
  2478. //得到文档中的第一个表格
  2479. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2480. List<string> texts = new List<string>();
  2481. foreach (var item in _AirTicketReservations)
  2482. {
  2483. string[] FlightsCode = item.FlightsCode.Split('/');
  2484. if (FlightsCode.Length != 0)
  2485. {
  2486. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2487. if (_AirCompany != null)
  2488. {
  2489. if (!transDic.ContainsKey(_AirCompany.CnName))
  2490. {
  2491. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2492. }
  2493. }
  2494. else
  2495. {
  2496. if (!transDic.ContainsKey("--"))
  2497. {
  2498. transDic.Add("--", "--");
  2499. }
  2500. }
  2501. }
  2502. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2503. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2504. string name = "";
  2505. foreach (string clientName in nameArray)
  2506. {
  2507. name += clientName + ",";
  2508. }
  2509. if (!texts.Contains(name))
  2510. {
  2511. texts.Add(name);
  2512. }
  2513. List<AirInfo> airs = new List<AirInfo>();
  2514. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2515. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2516. for (int i = 0; i < FlightsCode.Length; i++)
  2517. {
  2518. AirInfo air = new AirInfo();
  2519. string[] tempstr = DayArray[i]
  2520. .Replace("\r\n", string.Empty)
  2521. .Replace("\\r\\n", string.Empty)
  2522. .TrimStart().TrimEnd()
  2523. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2524. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2525. if (star_Three != null)
  2526. {
  2527. if (!transDic.ContainsKey(star_Three.AirPort))
  2528. {
  2529. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2530. }
  2531. }
  2532. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2533. if (End_Three != null)
  2534. {
  2535. if (!transDic.ContainsKey(End_Three.AirPort))
  2536. {
  2537. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2538. }
  2539. }
  2540. if (!texts.Contains(item.CTypeName))
  2541. {
  2542. texts.Add(item.CTypeName);
  2543. }
  2544. }
  2545. }
  2546. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2547. if (transData.Count > 0)
  2548. {
  2549. foreach (TranslateResult item in transData)
  2550. {
  2551. if (!transDic.ContainsKey(item.Query))
  2552. {
  2553. transDic.Add(item.Query, item.Translation);
  2554. }
  2555. }
  2556. }
  2557. foreach (var item in _AirTicketReservations)
  2558. {
  2559. #region 处理固定数据
  2560. string[] FlightsCode = item.FlightsCode.Split('/');
  2561. if (FlightsCode.Length != 0)
  2562. {
  2563. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2564. if (_AirCompany != null)
  2565. {
  2566. string str = "--";
  2567. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2568. if (!string.IsNullOrEmpty(translateResult))
  2569. {
  2570. str = translateResult;
  2571. str = _airTicketResRep.Processing(str);
  2572. }
  2573. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2574. }
  2575. else
  2576. {
  2577. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2578. }
  2579. }
  2580. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2581. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2582. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2583. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2584. string names = "";
  2585. foreach (string clientName in nameArray)
  2586. {
  2587. names += clientName + ",";
  2588. }
  2589. if (!string.IsNullOrWhiteSpace(names))
  2590. {
  2591. string str = "--";
  2592. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2593. if (!string.IsNullOrEmpty(translateResult))
  2594. {
  2595. str = translateResult;
  2596. str = _airTicketResRep.Processing(str);
  2597. }
  2598. table.Range.Bookmarks["ClientName"].Text = str;
  2599. }
  2600. else
  2601. {
  2602. table.Range.Bookmarks["ClientName"].Text = "--";
  2603. }
  2604. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2605. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2606. table.Range.Bookmarks["JointTicket"].Text = "--";
  2607. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2608. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2609. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2610. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2611. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2612. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2613. #endregion
  2614. #region 循环数据处理
  2615. List<AirInfo> airs = new List<AirInfo>();
  2616. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2617. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2618. for (int i = 0; i < FlightsCode.Length; i++)
  2619. {
  2620. AirInfo air = new AirInfo();
  2621. string[] tempstr = DayArray[i]
  2622. .Replace("\r\n", string.Empty)
  2623. .Replace("\\r\\n", string.Empty)
  2624. .TrimStart().TrimEnd()
  2625. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2626. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2627. string starCity = "";
  2628. if (star_Three != null)
  2629. {
  2630. string str2 = "--";
  2631. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2632. if (!string.IsNullOrEmpty(translateResult2))
  2633. {
  2634. str2 = translateResult2;
  2635. str2 = _airTicketResRep.Processing(str2);
  2636. }
  2637. starCity = str2;
  2638. }
  2639. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2640. string EndCity = "";
  2641. if (End_Three != null)
  2642. {
  2643. string str1 = "--";
  2644. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2645. if (!string.IsNullOrEmpty(translateResult1))
  2646. {
  2647. str1 = translateResult1;
  2648. str1 = _airTicketResRep.Processing(str1);
  2649. }
  2650. EndCity = str1;
  2651. }
  2652. air.Destination = starCity + "/" + EndCity;
  2653. air.Flight = FlightsCode[i];
  2654. string str = "--";
  2655. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2656. if (!string.IsNullOrEmpty(translateResult))
  2657. {
  2658. str = translateResult;
  2659. str = _airTicketResRep.Processing(str);
  2660. }
  2661. air.SeatingClass = str;
  2662. string dateTime = tempstr[2];
  2663. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2664. air.FlightDate = DateTemp;
  2665. air.DepartureTime = tempstr[5];
  2666. air.LandingTime = tempstr[6];
  2667. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2668. air.TicketStatus = "--";
  2669. air.Luggage = "--";
  2670. air.DepartureTerminal = "--";
  2671. air.LandingTerminal = "--";
  2672. airs.Add(air);
  2673. }
  2674. int row = 13;
  2675. for (int i = 0; i < airs.Count; i++)
  2676. {
  2677. if (airs.Count > 2)
  2678. {
  2679. for (int j = 0; j < airs.Count - 2; j++)
  2680. {
  2681. var CopyRow = table.Rows[12].Clone(true);
  2682. table.Rows.Add(CopyRow);
  2683. }
  2684. }
  2685. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2686. int index = 0;
  2687. foreach (PropertyInfo property in properties)
  2688. {
  2689. string value = property.GetValue(airs[i]).ToString();
  2690. Cell ishcel0 = table.Rows[row].Cells[index];
  2691. Paragraph p = new Paragraph(doc);
  2692. string s = value;
  2693. p.AppendChild(new Run(doc, s));
  2694. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2695. ishcel0.AppendChild(p);
  2696. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2697. //ishcel0.CellFormat.VerticalAlignment=
  2698. index++;
  2699. }
  2700. row++;
  2701. }
  2702. #endregion
  2703. Paragraph lastParagraph = new Paragraph(doc);
  2704. //第一个表格末尾加段落
  2705. table.ParentNode.InsertAfter(lastParagraph, table);
  2706. //复制第一个表格
  2707. Table cloneTable = (Table)table.Clone(true);
  2708. //在文档末尾段落后面加入复制的表格
  2709. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2710. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2711. {
  2712. int rownewsIndex = 13;
  2713. for (int i = 0; i < 2; i++)
  2714. {
  2715. var CopyRow = table.Rows[12].Clone(true);
  2716. table.Rows.RemoveAt(13);
  2717. table.Rows.Add(CopyRow);
  2718. rownewsIndex++;
  2719. }
  2720. }
  2721. else
  2722. {
  2723. table.Rows.RemoveAt(12);
  2724. }
  2725. cloneTable.Rows.RemoveAt(12);
  2726. }
  2727. if (_AirTicketReservations.Count != 0)
  2728. {
  2729. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2730. if (FlightsCode.Length != 0)
  2731. {
  2732. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2733. if (_AirCompany != null)
  2734. {
  2735. string str = "--";
  2736. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2737. if (!string.IsNullOrEmpty(translateResult))
  2738. {
  2739. str = translateResult;
  2740. str = _airTicketResRep.Processing(str);
  2741. }
  2742. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2743. }
  2744. else
  2745. {
  2746. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2747. }
  2748. }
  2749. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2750. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2751. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2752. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2753. string names = "";
  2754. foreach (string clientName in nameArray)
  2755. {
  2756. names += clientName + ",";
  2757. }
  2758. if (!string.IsNullOrWhiteSpace(names))
  2759. {
  2760. string str = "--";
  2761. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2762. if (!string.IsNullOrEmpty(translateResult))
  2763. {
  2764. str = translateResult;
  2765. str = _airTicketResRep.Processing(str);
  2766. }
  2767. table.Range.Bookmarks["ClientName"].Text = str;
  2768. }
  2769. else
  2770. {
  2771. table.Range.Bookmarks["ClientName"].Text = "--";
  2772. }
  2773. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2774. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2775. table.Range.Bookmarks["JointTicket"].Text = "--";
  2776. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2777. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2778. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2779. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2780. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2781. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2782. }
  2783. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2784. //保存合并后的文档
  2785. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2786. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2787. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2788. return Ok(JsonView(true, "成功!", rst));
  2789. }
  2790. }
  2791. }
  2792. catch (Exception ex)
  2793. {
  2794. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2795. throw;
  2796. }
  2797. }
  2798. #endregion
  2799. #region 团组增减款项 --> 其他款项
  2800. /// <summary>
  2801. /// 团组增减款项下拉框绑定
  2802. /// </summary>
  2803. /// <param name="dto"></param>
  2804. /// <returns></returns>
  2805. [HttpPost]
  2806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2807. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2808. {
  2809. #region 参数验证
  2810. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2811. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2812. #endregion
  2813. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2814. }
  2815. /// <summary>
  2816. /// 根据团组Id查询团组增减款项
  2817. /// </summary>
  2818. /// <param name="dto"></param>
  2819. /// <returns></returns>
  2820. [HttpPost]
  2821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2822. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2823. {
  2824. #region 参数验证
  2825. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2826. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2827. #endregion
  2828. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2829. }
  2830. /// <summary>
  2831. /// 团组增减款项操作(Status:1.新增,2.修改)
  2832. /// </summary>
  2833. /// <param name="dto"></param>
  2834. /// <returns></returns>
  2835. [HttpPost]
  2836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2837. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2838. {
  2839. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2840. if (groupData.Code != 200)
  2841. {
  2842. return Ok(JsonView(false, groupData.Msg));
  2843. }
  2844. #region 应用推送
  2845. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2846. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2847. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2848. #endregion
  2849. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2850. }
  2851. /// <summary>
  2852. /// 团组增减款项操作 删除
  2853. /// </summary>
  2854. /// <param name="dto"></param>
  2855. /// <returns></returns>
  2856. [HttpPost]
  2857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2858. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2859. {
  2860. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2861. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2862. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2863. if (res.Code == 0)
  2864. {
  2865. return Ok(JsonView(true, "删除成功!"));
  2866. }
  2867. return Ok(JsonView(false, "删除失败!"));
  2868. }
  2869. /// <summary>
  2870. /// 根据团组增减款项Id查询
  2871. /// </summary>
  2872. /// <param name="dto"></param>
  2873. /// <returns></returns>
  2874. [HttpPost]
  2875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2876. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2877. {
  2878. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2879. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2880. }
  2881. /// <summary>
  2882. /// 查询供应商名称
  2883. /// </summary>
  2884. /// <param name="dto"></param>
  2885. /// <returns></returns>
  2886. [HttpPost]
  2887. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2888. {
  2889. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2890. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2891. ?? new List<Grp_DecreasePayments>();
  2892. dbResult = dbResult.Distinct(new
  2893. ProductComparer()).ToList();
  2894. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2895. {
  2896. x.Id,
  2897. x.SupplierAddress,
  2898. x.SupplierArea,
  2899. x.SupplierContact,
  2900. x.SupplierContactNumber,
  2901. x.SupplierEmail,
  2902. x.SupplierName,
  2903. x.SupplierSocialAccount,
  2904. x.SupplierTypeId,
  2905. }).ToList());
  2906. return Ok(jw);
  2907. }
  2908. #endregion
  2909. #region 文件上传、删除
  2910. /// <summary>
  2911. /// region 文件上传 可以带参数
  2912. /// </summary>
  2913. /// <param name="file"></param>
  2914. /// <returns></returns>
  2915. [HttpPost]
  2916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2917. public async Task<IActionResult> UploadProject(IFormFile file)
  2918. {
  2919. try
  2920. {
  2921. var TypeName = Request.Headers["TypeName"].ToString();
  2922. if (file != null)
  2923. {
  2924. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2925. //文件名称
  2926. string projectFileName = file.FileName;
  2927. //上传的文件的路径
  2928. string filePath = "";
  2929. if (TypeName == "A")//A代表团组增减款项
  2930. {
  2931. if (!Directory.Exists(fileDir))
  2932. {
  2933. Directory.CreateDirectory(fileDir);
  2934. }
  2935. //上传的文件的路径
  2936. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2937. }
  2938. else if (TypeName == "B")//B代表商邀相关文件
  2939. {
  2940. if (!Directory.Exists(fileDir))
  2941. {
  2942. Directory.CreateDirectory(fileDir);
  2943. }
  2944. //上传的文件的路径
  2945. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2946. }
  2947. using (FileStream fs = System.IO.File.Create(filePath))
  2948. {
  2949. file.CopyTo(fs);
  2950. fs.Flush();
  2951. }
  2952. return Ok(JsonView(true, "上传成功!", projectFileName));
  2953. }
  2954. else
  2955. {
  2956. return Ok(JsonView(false, "上传失败!"));
  2957. }
  2958. }
  2959. catch (Exception ex)
  2960. {
  2961. return Ok(JsonView(false, "程序错误!"));
  2962. throw;
  2963. }
  2964. }
  2965. /// <summary>
  2966. /// 删除指定文件
  2967. /// </summary>
  2968. /// <param name="dto"></param>
  2969. /// <returns></returns>
  2970. [HttpPost]
  2971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2972. public async Task<IActionResult> DelFile(DelFileDto dto)
  2973. {
  2974. try
  2975. {
  2976. var TypeName = Request.Headers["TypeName"].ToString();
  2977. string filePath = "";
  2978. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2979. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2980. int id = 0;
  2981. if (TypeName == "A")
  2982. {
  2983. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2984. // 删除该文件
  2985. System.IO.File.Delete(filePath);
  2986. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2987. }
  2988. else if (TypeName == "B")
  2989. {
  2990. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2991. // 删除该文件
  2992. System.IO.File.Delete(filePath);
  2993. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2994. }
  2995. if (id != 0)
  2996. {
  2997. return Ok(JsonView(true, "成功!"));
  2998. }
  2999. else
  3000. {
  3001. return Ok(JsonView(false, "失败!"));
  3002. }
  3003. }
  3004. catch (Exception ex)
  3005. {
  3006. return Ok(JsonView(false, "程序错误!"));
  3007. throw;
  3008. }
  3009. }
  3010. #endregion
  3011. #region 商邀费用录入
  3012. /// <summary>
  3013. /// 根据团组Id查询商邀费用列表
  3014. /// </summary>
  3015. /// <param name="dto"></param>
  3016. /// <returns></returns>
  3017. [HttpPost]
  3018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3019. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3020. {
  3021. try
  3022. {
  3023. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3024. if (groupData.Code != 0)
  3025. {
  3026. return Ok(JsonView(false, groupData.Msg));
  3027. }
  3028. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3029. }
  3030. catch (Exception ex)
  3031. {
  3032. return Ok(JsonView(false, "程序错误!"));
  3033. throw;
  3034. }
  3035. }
  3036. //
  3037. /// <summary>
  3038. /// 商邀费用 Info Page 基础数据源
  3039. /// </summary>
  3040. /// <param name="dto"></param>
  3041. /// <returns></returns>
  3042. [HttpPost]
  3043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3044. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3045. {
  3046. try
  3047. {
  3048. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3049. if (groupData.Code != 0)
  3050. {
  3051. return Ok(JsonView(false, groupData.Msg));
  3052. }
  3053. return Ok(JsonView(true, "操作成功", groupData.Data));
  3054. }
  3055. catch (Exception ex)
  3056. {
  3057. return Ok(JsonView(false, ex.Message));
  3058. throw;
  3059. }
  3060. }
  3061. /// <summary>
  3062. /// 根据商邀费用ID查询C表和商邀费用数据
  3063. /// </summary>
  3064. /// <param name="dto"></param>
  3065. /// <returns></returns>
  3066. [HttpPost]
  3067. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3068. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3069. {
  3070. try
  3071. {
  3072. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3073. if (groupData.Code != 0)
  3074. {
  3075. return Ok(JsonView(false, groupData.Msg));
  3076. }
  3077. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3078. }
  3079. catch (Exception ex)
  3080. {
  3081. return Ok(JsonView(false, ex.Message));
  3082. throw;
  3083. }
  3084. }
  3085. /// <summary>
  3086. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3087. /// </summary>
  3088. /// <param name="dto"></param>
  3089. /// <returns></returns>
  3090. [HttpPost]
  3091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3092. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3093. {
  3094. try
  3095. {
  3096. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3097. if (groupData.Code != 0)
  3098. {
  3099. return Ok(JsonView(false, groupData.Msg));
  3100. }
  3101. #region 应用推送
  3102. try
  3103. {
  3104. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3105. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3106. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3107. }
  3108. catch (Exception ex)
  3109. {
  3110. }
  3111. #endregion
  3112. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3113. }
  3114. catch (Exception ex)
  3115. {
  3116. return Ok(JsonView(false, "程序错误!"));
  3117. throw;
  3118. }
  3119. }
  3120. /// <summary>
  3121. /// 商邀删除
  3122. /// </summary>
  3123. /// <param name="dto"></param>
  3124. /// <returns></returns>
  3125. [HttpPost]
  3126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3127. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3128. {
  3129. try
  3130. {
  3131. _sqlSugar.BeginTran();
  3132. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3133. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3134. {
  3135. IsDel = 1,
  3136. DeleteUserId = dto.DeleteUserId,
  3137. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3138. })
  3139. .Where(it => it.Id == dto.Id)
  3140. .ExecuteCommand();
  3141. if (res1 > 0)
  3142. {
  3143. int _diId = 0;
  3144. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3145. if (_ioaInfo != null)
  3146. {
  3147. _diId = _ioaInfo.DiId;
  3148. }
  3149. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3150. .SetColumns(a => new Grp_CreditCardPayment()
  3151. {
  3152. IsDel = 1,
  3153. DeleteUserId = dto.DeleteUserId,
  3154. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3155. })
  3156. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3157. .ExecuteCommand();
  3158. if (res2 > 0)
  3159. {
  3160. _sqlSugar.CommitTran();
  3161. return Ok(JsonView(true, "删除成功!"));
  3162. }
  3163. }
  3164. _sqlSugar.RollbackTran();
  3165. return Ok(JsonView(false, "删除失败"));
  3166. }
  3167. catch (Exception ex)
  3168. {
  3169. _sqlSugar.RollbackTran();
  3170. return Ok(JsonView(false, ex.Message));
  3171. }
  3172. }
  3173. /// <summary>
  3174. /// 团组模块文件上传
  3175. /// </summary>
  3176. /// <param name="dto"></param>
  3177. /// <returns></returns>
  3178. [HttpPost]
  3179. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3180. {
  3181. var jw = JsonView(false);
  3182. long M = 1024 * 1024;
  3183. if (dto.Files == null || dto.Files.Count == 0)
  3184. {
  3185. jw.Msg = "无文件信息!";
  3186. return Ok(jw);
  3187. }
  3188. if (dto.Files.Sum(x=>x.Length) > 20 * M)
  3189. {
  3190. jw.Msg = "文件大小超过20M!";
  3191. return Ok(jw);
  3192. }
  3193. //var nameSp = dto.File.FileName.Split(".");
  3194. //if (nameSp.Length < 2)
  3195. //{
  3196. // jw.Msg = "拓展名称有误!";
  3197. // return Ok(jw);
  3198. //}
  3199. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3200. //if (!existsName.Contains(nameSp[1].ToUpper()))
  3201. //{
  3202. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3203. // return Ok(jw);
  3204. //}
  3205. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3206. if (Ctable == null)
  3207. {
  3208. jw.Msg = "Ctable指向有误!";
  3209. return Ok(jw);
  3210. }
  3211. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3212. if (groupInfo == null)
  3213. {
  3214. jw.Msg = "团组信息不存在!";
  3215. return Ok(jw);
  3216. }
  3217. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3218. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3219. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3220. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3221. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3222. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3223. try
  3224. {
  3225. if (!Directory.Exists(fileBase))
  3226. {
  3227. Directory.CreateDirectory(fileBase);
  3228. }
  3229. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  3230. foreach (var fileStream in dto.Files)
  3231. {
  3232. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  3233. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3234. {
  3235. Cid = dto.Cid,
  3236. CreateTime = DateTime.Now,
  3237. CreateUserId = dto.Userid,
  3238. Ctable = dto.Ctable,
  3239. Diid = dto.Diid,
  3240. IsDel = 0,
  3241. FilePath = saveFilePath,
  3242. FileName = fileStream.FileName
  3243. };
  3244. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3245. {
  3246. fileStream.CopyTo(fs);
  3247. fs.Flush();
  3248. }
  3249. saveArr.Add(file);
  3250. }
  3251. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  3252. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3253. jw = JsonView(true, "保存成功!", new
  3254. {
  3255. count = addResult,
  3256. filesName = saveArr.Select(x => x.FileName)
  3257. }) ;
  3258. }
  3259. catch (Exception ex)
  3260. {
  3261. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3262. {
  3263. count = 0,
  3264. filesName = new string[0],
  3265. }) ;
  3266. }
  3267. return Ok(jw);
  3268. }
  3269. /// <summary>
  3270. /// 查询各模块已保存文件
  3271. /// </summary>
  3272. /// <param name="dto"></param>
  3273. /// <returns></returns>
  3274. [HttpPost]
  3275. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  3276. {
  3277. var expression = Expressionable.Create<Grp_GroupModelFile>()
  3278. .AndIF(dto.UserId != -1 , x => x.CreateUserId == dto.UserId);
  3279. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x=>x.Id).ToList();
  3280. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  3281. {
  3282. expression = Expressionable.Create<Grp_GroupModelFile>()
  3283. .And(x=>visaIds.Contains(x.CreateUserId));
  3284. }
  3285. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  3286. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  3287. .Where(expression.ToExpression())
  3288. .ToList();
  3289. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  3290. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  3291. {
  3292. x.FileName,
  3293. x.Id,
  3294. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  3295. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  3296. })));
  3297. }
  3298. /// <summary>
  3299. /// 下载该团组下的所有文件
  3300. /// </summary>
  3301. /// <param name="dto"></param>
  3302. /// <returns></returns>
  3303. [HttpPost]
  3304. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  3305. {
  3306. var jw = JsonView(false);
  3307. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3308. if (groupInfo == null)
  3309. {
  3310. jw.Msg = "团组信息不存在!";
  3311. return Ok(jw);
  3312. }
  3313. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  3314. var isModule = Convert.ToBoolean(dto.isModule);
  3315. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3316. IOOperatorHelper io = new IOOperatorHelper();
  3317. if (isModule)
  3318. {
  3319. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  3320. foreach (var moduleArr in moduleGroup)
  3321. {
  3322. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  3323. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3324. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3325. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  3326. foreach (var item in moduleArr)
  3327. {
  3328. if (System.IO.File.Exists(item.FilePath))
  3329. {
  3330. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3331. {
  3332. byte[] bytes = new byte[fileStream.Length];
  3333. fileStream.Read(bytes, 0, bytes.Length);
  3334. fileStream.Close();
  3335. Stream stream = new MemoryStream(bytes);
  3336. chiZips.Add(item.FileName, stream);
  3337. }
  3338. }
  3339. }
  3340. if (chiZips.Count > 0)
  3341. {
  3342. var byts = io.ConvertZipStream(chiZips);
  3343. Stream stream = new MemoryStream(byts);
  3344. Zips.Add(key.Name+"_.zip", stream);
  3345. }
  3346. }
  3347. }
  3348. else
  3349. {
  3350. foreach (var item in dbQuery)
  3351. {
  3352. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3353. {
  3354. byte[] bytes = new byte[fileStream.Length];
  3355. fileStream.Read(bytes, 0, bytes.Length);
  3356. fileStream.Close();
  3357. Stream stream = new MemoryStream(bytes);
  3358. while (Zips.Keys.Contains(item.FileName))
  3359. {
  3360. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3361. }
  3362. Zips.Add(item.FileName, stream);
  3363. }
  3364. }
  3365. }
  3366. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3367. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3368. if (Zips.Count > 0)
  3369. {
  3370. var byts = io.ConvertZipStream(Zips);
  3371. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3372. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  3373. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  3374. }
  3375. else
  3376. {
  3377. jw.Msg = "暂无生成文件!";
  3378. }
  3379. return Ok(jw);
  3380. }
  3381. /// <summary>
  3382. /// 下载该团组下此模块的所有文件
  3383. /// </summary>
  3384. /// <param name="dto"></param>
  3385. /// <returns></returns>
  3386. [HttpPost]
  3387. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  3388. {
  3389. var jw = JsonView(false);
  3390. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  3391. if (groupInfo == null)
  3392. {
  3393. jw.Msg = "团组信息不存在!";
  3394. return Ok(jw);
  3395. }
  3396. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  3397. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  3398. && x.IsDel == 0);
  3399. if (key == null)
  3400. {
  3401. jw.Msg = "Ctable指向错误!";
  3402. return Ok(jw);
  3403. }
  3404. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  3405. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3406. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3407. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3408. IOOperatorHelper io = new IOOperatorHelper();
  3409. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  3410. foreach (var item in dbQuery)
  3411. {
  3412. if (System.IO.File.Exists(item.FilePath))
  3413. {
  3414. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  3415. {
  3416. byte[] bytes = new byte[fileStream.Length];
  3417. fileStream.Read(bytes, 0, bytes.Length);
  3418. fileStream.Close();
  3419. Stream stream = new MemoryStream(bytes);
  3420. while (Zips.Keys.Contains(item.FileName))
  3421. {
  3422. item.FileName = new Random().Next(100) + "_" + item.FileName;
  3423. }
  3424. Zips.Add(item.FileName, stream);
  3425. }
  3426. }
  3427. }
  3428. if (Zips.Count > 0)
  3429. {
  3430. var byts = io.ConvertZipStream(Zips);
  3431. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  3432. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  3433. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  3434. }
  3435. else
  3436. {
  3437. jw.Msg = "暂无生成文件!";
  3438. }
  3439. return Ok(jw);
  3440. }
  3441. /// <summary>
  3442. /// 删除该团组下的指定文件
  3443. /// </summary>
  3444. /// <param name="dto"></param>
  3445. /// <returns></returns>
  3446. [HttpPost]
  3447. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  3448. {
  3449. var jw = JsonView(false);
  3450. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  3451. if (sing == null)
  3452. {
  3453. jw.Msg = "暂无";
  3454. return Ok(jw);
  3455. }
  3456. if (System.IO.File.Exists(sing.FilePath))
  3457. {
  3458. try
  3459. {
  3460. System.IO.File.Delete(sing.FilePath);
  3461. }
  3462. catch (Exception ex)
  3463. {
  3464. jw.Msg = "删除失败!" + ex.Message;
  3465. return Ok(jw);
  3466. }
  3467. }
  3468. sing.IsDel = 1;
  3469. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  3470. sing.DeleteUserId = dto.UserId;
  3471. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  3472. jw = JsonView(true, "删除成功!");
  3473. return Ok(jw);
  3474. }
  3475. #endregion
  3476. #region 团组英文资料
  3477. /// <summary>
  3478. /// 查询团组英文所有资料
  3479. /// </summary>
  3480. /// <param name="dto"></param>
  3481. /// <returns></returns>
  3482. [HttpPost]
  3483. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3484. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3485. {
  3486. try
  3487. {
  3488. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3489. if (groupData.Code != 0)
  3490. {
  3491. return Ok(JsonView(false, groupData.Msg));
  3492. }
  3493. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3494. }
  3495. catch (Exception ex)
  3496. {
  3497. return Ok(JsonView(false, "程序错误!"));
  3498. throw;
  3499. }
  3500. }
  3501. /// <summary>
  3502. /// 团组英文资料操作(Status:1.新增,2.修改)
  3503. /// </summary>
  3504. /// <param name="dto"></param>
  3505. /// <returns></returns>
  3506. [HttpPost]
  3507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3508. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3509. {
  3510. try
  3511. {
  3512. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3513. if (groupData.Code != 0)
  3514. {
  3515. return Ok(JsonView(false, groupData.Msg));
  3516. }
  3517. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3518. }
  3519. catch (Exception ex)
  3520. {
  3521. return Ok(JsonView(false, "程序错误!"));
  3522. throw;
  3523. }
  3524. }
  3525. /// <summary>
  3526. /// 团组英文资料Id查询数据
  3527. /// </summary>
  3528. /// <param name="dto"></param>
  3529. /// <returns></returns>
  3530. [HttpPost]
  3531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3532. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3533. {
  3534. try
  3535. {
  3536. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3537. if (_DelegationEnData != null)
  3538. {
  3539. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3540. }
  3541. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3542. }
  3543. catch (Exception ex)
  3544. {
  3545. return Ok(JsonView(false, "程序错误!"));
  3546. throw;
  3547. }
  3548. }
  3549. /// <summary>
  3550. /// 团组英文资料删除
  3551. /// </summary>
  3552. /// <param name="dto"></param>
  3553. /// <returns></returns>
  3554. [HttpPost]
  3555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3556. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3557. {
  3558. try
  3559. {
  3560. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3561. if (!res)
  3562. {
  3563. return Ok(JsonView(false, "删除失败"));
  3564. }
  3565. return Ok(JsonView(true, "删除成功!"));
  3566. }
  3567. catch (Exception ex)
  3568. {
  3569. return Ok(JsonView(false, "程序错误!"));
  3570. throw;
  3571. }
  3572. }
  3573. #endregion
  3574. #region 导出邀请函
  3575. /// <summary>
  3576. /// 导出邀请函页面初始化
  3577. /// </summary>
  3578. /// <param name="dto"></param>
  3579. /// <returns></returns>
  3580. [HttpPost]
  3581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3582. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3583. {
  3584. try
  3585. {
  3586. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3587. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3588. if (dto.DiId == 0)
  3589. {
  3590. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3591. }
  3592. else
  3593. {
  3594. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3595. }
  3596. return Ok(JsonView(true, "查询成功!", new
  3597. {
  3598. deleClient = crm_Deles,
  3599. delegations = grp_Delegations
  3600. }));
  3601. }
  3602. catch (Exception ex)
  3603. {
  3604. return Ok(JsonView(false, "程序错误!"));
  3605. throw;
  3606. }
  3607. }
  3608. /// <summary>
  3609. /// 导出邀请函
  3610. /// </summary>
  3611. /// <param name="dto"></param>
  3612. /// <returns></returns>
  3613. [HttpPost]
  3614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3615. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3616. {
  3617. #region 参数验证
  3618. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3619. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3620. #endregion
  3621. try
  3622. {
  3623. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3624. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3625. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3626. From Grp_TourClientList tcl
  3627. Left Join
  3628. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3629. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3630. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3631. From Crm_DeleClient dc
  3632. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3633. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3634. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3635. Where dc.IsDel = 0) temp
  3636. On temp.DcId =tcl.ClientId
  3637. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3638. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3639. List<string> texts = new List<string>();
  3640. if (datas.Count != 0)
  3641. {
  3642. foreach (TourClientListDetailsView item in datas)
  3643. {
  3644. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3645. {
  3646. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3647. }
  3648. else
  3649. {
  3650. string name = item.LastName + item.FirstName;
  3651. texts.Add(name);
  3652. }
  3653. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3654. {
  3655. if (!transDic.ContainsKey(item.Job))
  3656. {
  3657. texts.Add(item.Job);
  3658. }
  3659. }
  3660. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3661. {
  3662. texts.Add(item.CompanyFullName);
  3663. }
  3664. }
  3665. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3666. if (transData.Count > 0)
  3667. {
  3668. foreach (TranslateResult item in transData)
  3669. {
  3670. if (!transDic.ContainsKey(item.Query))
  3671. {
  3672. transDic.Add(item.Query, item.Translation);
  3673. }
  3674. }
  3675. }
  3676. List<GuestList> list = new List<GuestList>();
  3677. foreach (TourClientListDetailsView dele in datas)
  3678. {
  3679. GuestList guestList = new GuestList();
  3680. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3681. {
  3682. guestList.Name = dele.Pinyin;
  3683. }
  3684. else
  3685. {
  3686. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3687. guestList.Name = Name;
  3688. }
  3689. if (dele.Sex == 0)
  3690. {
  3691. guestList.Sex = "Male";
  3692. }
  3693. else if (dele.Sex == 1)
  3694. {
  3695. guestList.Sex = "Female";
  3696. }
  3697. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3698. if (!string.IsNullOrEmpty(dele.Job))
  3699. {
  3700. guestList.Job = dele.Job;
  3701. }
  3702. list.Add(guestList);
  3703. }
  3704. //载入模板
  3705. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3706. DocumentBuilder builder = new DocumentBuilder(doc);
  3707. //获取word里所有表格
  3708. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3709. //获取所填表格的序数
  3710. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3711. var rowStart = tableOne.Rows[0]; //获取第1行
  3712. //循环赋值
  3713. for (int i = 0; i < list.Count; i++)
  3714. {
  3715. builder.MoveToCell(0, i + 1, 0, 0);
  3716. builder.Write(list[i].Name.ToString());
  3717. builder.MoveToCell(0, i + 1, 1, 0);
  3718. builder.Write(list[i].Sex.ToString());
  3719. builder.MoveToCell(0, i + 1, 2, 0);
  3720. builder.Write(list[i].DOB.ToString());
  3721. builder.MoveToCell(0, i + 1, 3, 0);
  3722. builder.Write(list[i].Job.ToString());
  3723. }
  3724. //删除多余行
  3725. while (tableOne.Rows.Count > list.Count + 1)
  3726. {
  3727. tableOne.Rows.RemoveAt(list.Count + 1);
  3728. }
  3729. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3730. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3731. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3732. doc.Save(filePath);
  3733. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3734. return Ok(JsonView(true, "操作成功!", Url));
  3735. }
  3736. else
  3737. {
  3738. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3739. }
  3740. }
  3741. catch (Exception ex)
  3742. {
  3743. return Ok(JsonView(false, ex.Message));
  3744. throw;
  3745. }
  3746. }
  3747. #endregion
  3748. #region 团组经理模块 出入境费用
  3749. ///// <summary>
  3750. ///// 团组模块 - 出入境费用
  3751. ///// </summary>
  3752. ///// <returns></returns>
  3753. //[HttpPost]
  3754. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3755. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3756. //{
  3757. // try
  3758. // {
  3759. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3760. // if (data.Code != 0)
  3761. // {
  3762. // return Ok(JsonView(false, data.Msg));
  3763. // }
  3764. // return Ok(JsonView(true, "查询成功!"));
  3765. // }
  3766. // catch (Exception ex)
  3767. // {
  3768. // return Ok(JsonView(false, ex.Message));
  3769. // throw;
  3770. // }
  3771. //}
  3772. /// <summary>
  3773. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3774. /// </summary>
  3775. /// <returns></returns>
  3776. [HttpPost]
  3777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3778. public async Task<IActionResult> SetDayAndCostAreaChange()
  3779. {
  3780. try
  3781. {
  3782. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3783. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3784. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3785. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3786. foreach (var item in unite) //处理交集数据
  3787. {
  3788. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3789. }
  3790. foreach (var item in merge) //处理差集数据
  3791. {
  3792. int nationalTravelFeeId = 0;
  3793. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3794. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3795. else
  3796. {
  3797. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3798. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3799. }
  3800. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3801. }
  3802. //只更新dayAndCost 的 nationalTravelFeeId;
  3803. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3804. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3805. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3806. }
  3807. catch (Exception ex)
  3808. {
  3809. return Ok(JsonView(false, ex.Message));
  3810. throw;
  3811. }
  3812. }
  3813. /// <summary>
  3814. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3815. /// </summary>
  3816. /// <returns></returns>
  3817. [HttpPost]
  3818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3819. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3820. {
  3821. try
  3822. {
  3823. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3824. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3825. //SetDataInfoView
  3826. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3827. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3828. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3829. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3830. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3831. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3832. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3833. //默认币种显示
  3834. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3835. {
  3836. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3837. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3838. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3839. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3840. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3841. };
  3842. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3843. if (_currencyRate.Count > 0)
  3844. {
  3845. foreach (var item in _currencyInfos)
  3846. {
  3847. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3848. if (rateInfo != null)
  3849. {
  3850. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3851. rate1 *= 1.035M;
  3852. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3853. }
  3854. }
  3855. }
  3856. return Ok(JsonView(true, "查询成功!", new
  3857. {
  3858. GroupNameData = groupNameData.Data,
  3859. CurrencyData = _CurrencyData,
  3860. WordTypeData = _WordTypeData,
  3861. ExcelTypeData = _ExcelTypeData,
  3862. CurrencyInit = _currencyInfos
  3863. }));
  3864. }
  3865. catch (Exception ex)
  3866. {
  3867. return Ok(JsonView(false, ex.Message));
  3868. throw;
  3869. }
  3870. }
  3871. /// <summary>
  3872. /// 团组模块 - 出入境费用
  3873. /// 实时汇率 tips
  3874. /// 签证费用 tips
  3875. /// </summary>
  3876. /// <returns></returns>
  3877. [HttpPost]
  3878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3879. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3880. {
  3881. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3882. //默认币种显示
  3883. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3884. {
  3885. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3886. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3887. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3888. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3889. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3890. };
  3891. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3892. List<dynamic> reteInfos = new List<dynamic>();
  3893. if (_currencyRate.Count > 0)
  3894. {
  3895. foreach (var item in _currencyInfos)
  3896. {
  3897. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3898. if (rateInfo != null)
  3899. {
  3900. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3901. decimal rate1 = item.Rate;
  3902. rate1 *= 1.03M;
  3903. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3904. reteInfos.Add(new
  3905. {
  3906. currCode = item.CurrencyCode,
  3907. currName = item.CurrencyName,
  3908. rate = rate2,
  3909. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3910. });
  3911. }
  3912. }
  3913. }
  3914. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3915. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3916. return Ok(JsonView(true, "查询成功!", new
  3917. {
  3918. //GroupNameData = groupNameData.Data,
  3919. visaData = visaData.Data,
  3920. airData = airData.Data,
  3921. reteInfos = reteInfos
  3922. }));
  3923. }
  3924. /// <summary>
  3925. /// 团组模块 - 出入境费用 - Info
  3926. /// </summary>
  3927. /// <returns></returns>
  3928. [HttpPost]
  3929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3930. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3931. {
  3932. try
  3933. {
  3934. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3935. if (data.Code != 0)
  3936. {
  3937. return Ok(JsonView(false, data.Msg));
  3938. }
  3939. return Ok(JsonView(true, "查询成功!", data.Data));
  3940. }
  3941. catch (Exception ex)
  3942. {
  3943. return Ok(JsonView(false, ex.Message));
  3944. }
  3945. }
  3946. /// <summary>
  3947. /// 团组模块 - 出入境费用 - Add And Update
  3948. /// </summary>
  3949. /// <returns></returns>
  3950. [HttpPost]
  3951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3952. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3953. {
  3954. try
  3955. {
  3956. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3957. if (data.Code != 0)
  3958. {
  3959. return Ok(JsonView(false, data.Msg));
  3960. }
  3961. //生成默认文件pdf并且通知人员
  3962. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3963. {
  3964. DiId = dto.DiId,
  3965. ExportType = 1,
  3966. SubTypeId = 1005
  3967. }, "pdf");
  3968. //发送通知
  3969. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3970. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3971. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3972. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3973. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3974. return Ok(JsonView(true, data.Msg, data.Data));
  3975. }
  3976. catch (Exception ex)
  3977. {
  3978. return Ok(JsonView(false, ex.Message));
  3979. }
  3980. }
  3981. /// <summary>
  3982. /// 团组模块 - 出入境费用 - Confirm 费用
  3983. /// </summary>
  3984. /// <returns></returns>
  3985. [HttpPost]
  3986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3987. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3988. {
  3989. //TODO:测试完毕需把对应的用户ID更改
  3990. //1、数据表添加字段
  3991. //2、更改字段接口()
  3992. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3993. //3、确认成功 给财务发送消息
  3994. if (_view.Code == 200)
  3995. {
  3996. if (dto.Type == 1)
  3997. {
  3998. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3999. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4000. }
  4001. }
  4002. return Ok(_view);
  4003. }
  4004. /// <summary>
  4005. /// 团组模块 - 出入境费用 - File downlaod
  4006. /// </summary>
  4007. /// <param name="dto"></param>
  4008. /// <returns></returns>
  4009. [HttpPost]
  4010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4011. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4012. {
  4013. try
  4014. {
  4015. if (dto.DiId < 1)
  4016. {
  4017. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4018. }
  4019. if (dto.ExportType < 1)
  4020. {
  4021. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  4022. }
  4023. if (dto.SubTypeId < 1)
  4024. {
  4025. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  4026. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4027. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4028. 3 团组成员名单 1 团组成员名单"));
  4029. }
  4030. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4031. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4032. if (_EnterExitCosts == null)
  4033. {
  4034. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  4035. }
  4036. //数据源
  4037. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4038. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4039. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4040. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4041. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4042. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  4043. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  4044. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  4045. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  4046. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  4047. .Select((tcl, dc, cc) => new
  4048. {
  4049. Name = dc.LastName + dc.FirstName,
  4050. Sex = dc.Sex,
  4051. Birthday = dc.BirthDay,
  4052. Company = cc.CompanyFullName,
  4053. Job = dc.Job
  4054. })
  4055. .ToList();
  4056. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  4057. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  4058. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  4059. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  4060. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  4061. if (dto.ExportType == 1) //明细表
  4062. {
  4063. if (dto.SubTypeId == 1005) //1005(默认明细表)
  4064. {
  4065. //获取模板
  4066. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  4067. //载入模板
  4068. Document doc = new Document(tempPath);
  4069. DocumentBuilder builder = new DocumentBuilder(doc);
  4070. //利用键值对存放数据
  4071. Dictionary<string, string> dic = new Dictionary<string, string>();
  4072. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  4073. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  4074. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  4075. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  4076. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  4077. //境内费用(其他费用)
  4078. if (_EnterExitCosts.ChoiceOne == 1)
  4079. {
  4080. string row1_1 = "";
  4081. if (_EnterExitCosts.Visa > 0)
  4082. {
  4083. //insidePayTotal += _EnterExitCosts.Visa;
  4084. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  4085. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  4086. {
  4087. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  4088. }
  4089. }
  4090. string row1_2 = "";
  4091. if (_EnterExitCosts.YiMiao > 0)
  4092. {
  4093. //insidePayTotal += _EnterExitCosts.YiMiao;
  4094. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  4095. }
  4096. if (_EnterExitCosts.HeSuan > 0)
  4097. {
  4098. //insidePayTotal += _EnterExitCosts.HeSuan;
  4099. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  4100. }
  4101. if (_EnterExitCosts.Service > 0)
  4102. {
  4103. //insidePayTotal += _EnterExitCosts.Service;
  4104. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  4105. }
  4106. string row1_3 = "";
  4107. if (_EnterExitCosts.Safe > 0)
  4108. {
  4109. //insidePayTotal += _EnterExitCosts.Safe;
  4110. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  4111. }
  4112. if (_EnterExitCosts.Ticket > 0)
  4113. {
  4114. //insidePayTotal += _EnterExitCosts.Ticket;
  4115. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  4116. }
  4117. string row1 = "";
  4118. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  4119. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  4120. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  4121. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  4122. dic.Add("Row1Str", row1);
  4123. }
  4124. string airTotalStr = string.Empty,
  4125. airPriceStr = string.Empty;
  4126. //经济舱
  4127. if (_EnterExitCosts.SumJJC == 1)
  4128. {
  4129. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  4130. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  4131. }
  4132. //公务舱
  4133. if (_EnterExitCosts.SumGWC == 1)
  4134. {
  4135. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  4136. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  4137. }
  4138. //头等舱
  4139. if (_EnterExitCosts.SumTDC == 1)
  4140. {
  4141. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  4142. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  4143. }
  4144. dic.Add("AirTotalStr", airTotalStr);
  4145. dic.Add("AirPriceStr", airPriceStr);
  4146. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4147. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4148. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4149. int table1Row = 0,
  4150. table2Row = 0,
  4151. table3Row = 0,
  4152. table4Row = 0;
  4153. //住宿费
  4154. if (_EnterExitCosts.ChoiceThree == 1)
  4155. {
  4156. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  4157. table1Row = dac1.Count;
  4158. #region 填充word表格内容
  4159. for (int i = 0; i < dac1.Count; i++)
  4160. {
  4161. Grp_DayAndCost dac = dac1[i];
  4162. if (dac == null) continue;
  4163. builder.MoveToCell(0, i, 0, 0);
  4164. builder.Write("第" + dac.Days.ToString() + "晚:");
  4165. builder.MoveToCell(0, i, 1, 0);
  4166. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  4167. //builder.Write(dac.Place == null ? "" : dac.Place);
  4168. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4169. builder.MoveToCell(0, i, 2, 0);
  4170. builder.Write("费用标准:");
  4171. string curr = "";
  4172. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4173. if (currData != null)
  4174. {
  4175. curr = currData.Name;
  4176. }
  4177. builder.MoveToCell(0, i, 3, 0);
  4178. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4179. builder.MoveToCell(0, i, 4, 0);
  4180. builder.Write("费用小计:");
  4181. builder.MoveToCell(0, i, 5, 0);
  4182. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4183. }
  4184. #endregion
  4185. }else dic.Add("SubZS","0.00");
  4186. //删除多余行
  4187. while (table1.Rows.Count > table1Row)
  4188. {
  4189. table1.Rows.RemoveAt(table1Row);
  4190. }
  4191. //伙食费
  4192. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  4193. if (_EnterExitCosts.ChoiceFour == 1)
  4194. {
  4195. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  4196. table2Row = dac2.Count;
  4197. #region 填充word表格内容
  4198. for (int i = 0; i < dac2.Count; i++)
  4199. {
  4200. Grp_DayAndCost dac = dac2[i];
  4201. if (dac == null) continue;
  4202. builder.MoveToCell(1, i, 0, 0);
  4203. builder.Write("第" + dac.Days.ToString() + "天:");
  4204. builder.MoveToCell(1, i, 1, 0);
  4205. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4206. builder.MoveToCell(1, i, 2, 0);
  4207. builder.Write("费用标准:");
  4208. string curr = "";
  4209. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4210. if (currData != null)
  4211. {
  4212. curr = currData.Name;
  4213. }
  4214. builder.MoveToCell(1, i, 3, 0);
  4215. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4216. builder.MoveToCell(1, i, 4, 0);
  4217. builder.Write("费用小计:");
  4218. builder.MoveToCell(1, i, 5, 0);
  4219. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4220. }
  4221. #endregion
  4222. }else dic.Add("SubHS","0.00");
  4223. //删除多余行
  4224. while (table2.Rows.Count > table2Row)
  4225. {
  4226. table2.Rows.RemoveAt(table2Row);
  4227. }
  4228. //公杂费
  4229. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  4230. if (_EnterExitCosts.ChoiceFive == 1)
  4231. {
  4232. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  4233. table3Row = dac3.Count;
  4234. #region 填充word表格内容
  4235. for (int i = 0; i < dac3.Count; i++)
  4236. {
  4237. Grp_DayAndCost dac = dac3[i];
  4238. if (dac == null) continue;
  4239. builder.MoveToCell(2, i, 0, 0);
  4240. builder.Write("第" + dac.Days.ToString() + "天:");
  4241. builder.MoveToCell(2, i, 1, 0);
  4242. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4243. builder.MoveToCell(2, i, 2, 0);
  4244. builder.Write("费用标准:");
  4245. string curr = "";
  4246. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4247. if (currData != null)
  4248. {
  4249. curr = currData.Name;
  4250. }
  4251. builder.MoveToCell(2, i, 3, 0);
  4252. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4253. builder.MoveToCell(2, i, 4, 0);
  4254. builder.Write("费用小计:");
  4255. builder.MoveToCell(2, i, 5, 0);
  4256. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4257. }
  4258. //删除多余行
  4259. while (table3.Rows.Count > table3Row)
  4260. {
  4261. table3.Rows.RemoveAt(table3Row);
  4262. }
  4263. #endregion
  4264. }else dic.Add("SubGZF", "0.00");
  4265. //删除多余行
  4266. while (table3.Rows.Count > table3Row)
  4267. {
  4268. table3.Rows.RemoveAt(table3Row);
  4269. }
  4270. //培训费
  4271. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  4272. if (_EnterExitCosts.ChoiceSix == 1)
  4273. {
  4274. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  4275. dic.Add("SubPX", pxStr);
  4276. table4Row = dac4.Count;
  4277. #region 填充word表格内容
  4278. for (int i = 0; i < dac4.Count; i++)
  4279. {
  4280. Grp_DayAndCost dac = dac4[i];
  4281. if (dac == null) continue;
  4282. builder.MoveToCell(3, i, 0, 0);
  4283. builder.Write("第" + dac.Days.ToString() + "天:");
  4284. builder.MoveToCell(3, i, 1, 0);
  4285. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4286. builder.MoveToCell(3, i, 2, 0);
  4287. builder.Write("费用标准:");
  4288. string curr = "";
  4289. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  4290. if (currData != null)
  4291. {
  4292. curr = currData.Name;
  4293. }
  4294. builder.MoveToCell(3, i, 3, 0);
  4295. builder.Write(dac.Cost.ToString("#0.00") + curr);
  4296. builder.MoveToCell(3, i, 4, 0);
  4297. builder.Write("费用小计:");
  4298. builder.MoveToCell(3, i, 5, 0);
  4299. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  4300. }
  4301. #endregion
  4302. }
  4303. //else dic.Add("SubPX","0.00");
  4304. //删除多余行
  4305. while (table4.Rows.Count > table4Row)
  4306. {
  4307. table4.Rows.RemoveAt(table4Row);
  4308. }
  4309. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal;
  4310. decimal subJJC = 0.00M,
  4311. subGWC = 0.00M,
  4312. subTDC = 0.00M;
  4313. //经济舱
  4314. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  4315. //公务舱
  4316. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  4317. //头等舱
  4318. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  4319. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  4320. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  4321. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  4322. #region 填充word模板书签内容
  4323. foreach (var key in dic.Keys)
  4324. {
  4325. builder.MoveToBookmark(key);
  4326. builder.Write(dic[key]);
  4327. }
  4328. #endregion
  4329. //文件名
  4330. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  4331. AsposeHelper.removewatermark_v2180();
  4332. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4333. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4334. return Ok(JsonView(true, "成功", new { Url = url }));
  4335. }
  4336. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  4337. {
  4338. //获取模板
  4339. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  4340. //载入模板
  4341. Document doc = new Document(tempPath);
  4342. DocumentBuilder builder = new DocumentBuilder(doc);
  4343. Dictionary<string, string> dic = new Dictionary<string, string>();
  4344. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4345. {
  4346. List<string> list = new List<string>();
  4347. try
  4348. {
  4349. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4350. foreach (var item in spilitArr)
  4351. {
  4352. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4353. var depCode = spDotandEmpty[2].Substring(0, 3);
  4354. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4355. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4356. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4357. list.Add(depName);
  4358. list.Add(arrName);
  4359. }
  4360. list = list.Distinct().ToList();
  4361. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4362. }
  4363. catch (Exception)
  4364. {
  4365. dic.Add("ReturnCode", "行程录入不正确!");
  4366. }
  4367. }
  4368. else
  4369. {
  4370. dic.Add("ReturnCode", "未录入行程!");
  4371. }
  4372. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4373. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4374. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4375. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4376. {
  4377. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4378. dic.Add("Day", sp.Days.ToString());
  4379. }
  4380. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4381. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4382. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4383. //dic.Add("Names", Names);
  4384. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4385. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4386. decimal dac1totalPrice = 0.00M;
  4387. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4388. foreach (var dac in dac1)
  4389. {
  4390. if (dac.SubTotal == 0.00M)
  4391. {
  4392. continue;
  4393. }
  4394. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4395. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4396. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4397. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4398. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4399. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4400. builder.Write(currency);//币种
  4401. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4402. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4403. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4404. builder.Write("");//人数
  4405. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4406. builder.Write("");//天数
  4407. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4408. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4409. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4410. decimal rate = 0.00M;
  4411. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4412. builder.Write(rate.ToString("#0.0000"));//汇率
  4413. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4414. decimal rbmPrice = dac.SubTotal;
  4415. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4416. accommodationStartIndex++;
  4417. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4418. }
  4419. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4420. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4421. {
  4422. table1.Rows.RemoveAt(i - 1);
  4423. foodandotherStartIndex--;
  4424. }
  4425. if (dac2.Count == dac3.Count)//国家 币种 金额
  4426. {
  4427. for (int i = 0; i < dac2.Count; i++)
  4428. {
  4429. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4430. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4431. }
  4432. }
  4433. decimal dac2totalPrice = 0.00M;
  4434. foreach (var dac in dac2)
  4435. {
  4436. if (dac.SubTotal == 0)
  4437. {
  4438. continue;
  4439. }
  4440. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4441. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4442. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4443. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4444. builder.Write(currency);//币种
  4445. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4446. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4447. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4448. builder.Write("");//人数
  4449. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4450. builder.Write("");//天数
  4451. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4452. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4453. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4454. decimal rate = 0.00M;
  4455. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4456. builder.Write(rate.ToString("#0.0000"));//汇率
  4457. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4458. decimal rbmPrice = dac.SubTotal;
  4459. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4460. foodandotherStartIndex++;
  4461. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4462. }
  4463. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4464. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4465. {
  4466. table1.Rows.RemoveAt(i - 1);
  4467. }
  4468. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4469. string otherFeeStr = "";
  4470. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4471. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4472. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4473. if (otherFeeStr.Length > 0)
  4474. {
  4475. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4476. otherFeeStr = $"({otherFeeStr})";
  4477. dic.Add("OtherFeeStr", otherFeeStr);
  4478. }
  4479. //总计
  4480. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4481. //国际旅费
  4482. string outsideAir = string.Empty;
  4483. string allPriceAir = string.Empty;
  4484. if (_EnterExitCosts.SumJJC == 1)
  4485. {
  4486. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4487. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4488. }
  4489. if (_EnterExitCosts.SumGWC == 1)
  4490. {
  4491. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  4492. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4493. }
  4494. if (_EnterExitCosts.SumTDC == 1)
  4495. {
  4496. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  4497. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  4498. }
  4499. dic.Add("InTravelPrice", $"({outsideAir})");
  4500. dic.Add("FinalSumPrice", $"({allPriceAir})");
  4501. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4502. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4503. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4504. foreach (var key in dic.Keys)
  4505. {
  4506. builder.MoveToBookmark(key);
  4507. builder.Write(dic[key]);
  4508. }
  4509. //模板文件名
  4510. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  4511. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4512. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4513. return Ok(JsonView(true, "成功", new { Url = url }));
  4514. }
  4515. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4516. {
  4517. //获取模板
  4518. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4519. //载入模板
  4520. WorkbookDesigner designer = new WorkbookDesigner();
  4521. designer.Workbook = new Workbook(tempPath);
  4522. Dictionary<string, string> dic = new Dictionary<string, string>();
  4523. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4524. {
  4525. List<string> list = new List<string>();
  4526. try
  4527. {
  4528. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4529. foreach (var item in spilitArr)
  4530. {
  4531. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4532. var depCode = spDotandEmpty[2].Substring(0, 3);
  4533. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4534. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4535. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4536. list.Add(depName);
  4537. list.Add(arrName);
  4538. }
  4539. list = list.Distinct().ToList();
  4540. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4541. }
  4542. catch (Exception)
  4543. {
  4544. dic.Add("ReturnCode", "行程录入不正确!");
  4545. }
  4546. }
  4547. else
  4548. {
  4549. dic.Add("ReturnCode", "未录入行程!");
  4550. }
  4551. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4552. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4553. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4554. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4555. {
  4556. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4557. dic.Add("Day", sp.Days.ToString());
  4558. }
  4559. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4560. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4561. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4562. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4563. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4564. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4565. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4566. designer.SetDataSource("Name", Names);
  4567. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4568. designer.SetDataSource("Day", dic["Day"] + "天");
  4569. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4570. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4571. int startIndex = 10;
  4572. const int startIndexcopy = 10;
  4573. if (dac2.Count == dac3.Count)//国家 币种 金额
  4574. {
  4575. for (int i = 0; i < dac2.Count; i++)
  4576. {
  4577. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4578. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4579. }
  4580. }
  4581. DataTable dtdac1 = new DataTable();
  4582. List<string> place = new List<string>();
  4583. dtdac1.Columns.AddRange(new DataColumn[] {
  4584. new DataColumn(){ ColumnName = "city"},
  4585. new DataColumn(){ ColumnName = "curr"},
  4586. new DataColumn(){ ColumnName = "criterion"},
  4587. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4588. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4589. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4590. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4591. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4592. });
  4593. DataTable dtdac2 = new DataTable();
  4594. dtdac2.Columns.AddRange(new DataColumn[] {
  4595. new DataColumn(){ ColumnName = "city"},
  4596. new DataColumn(){ ColumnName = "curr"},
  4597. new DataColumn(){ ColumnName = "criterion"},
  4598. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4599. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4600. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4601. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4602. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4603. });
  4604. dtdac1.TableName = "tb1";
  4605. dtdac2.TableName = "tb2";
  4606. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4607. foreach (var item in dac1)
  4608. {
  4609. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4610. if (place.Contains(item.Place))
  4611. {
  4612. continue;
  4613. }
  4614. DataRow row = dtdac1.NewRow();
  4615. row["city"] = item.Place;
  4616. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4617. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4618. row["curr"] = currency;
  4619. row["rate"] = rate.ToString("#0.0000");
  4620. row["criterion"] = item.Cost.ToString("#0.00");
  4621. row["number"] = 1;
  4622. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4623. //row["costRMB"] = rbmPrice;
  4624. dtdac1.Rows.Add(row);
  4625. place.Add(item.Place);
  4626. }
  4627. place = new List<string>();
  4628. foreach (var item in dac2)
  4629. {
  4630. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4631. if (place.Contains(item.Place))
  4632. {
  4633. continue;
  4634. }
  4635. DataRow row = dtdac2.NewRow();
  4636. row["city"] = item.Place;
  4637. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4638. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4639. row["curr"] = currency;
  4640. row["rate"] = rate.ToString("#0.0000");
  4641. row["criterion"] = item.Cost.ToString("#0.00");
  4642. row["number"] = 1;
  4643. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4644. //row["cost"] = item.SubTotal;
  4645. //row["costRMB"] = rbmPrice;
  4646. dtdac2.Rows.Add(row);
  4647. place.Add(item.Place);
  4648. //dac2totalPrice += rbmPrice;
  4649. }
  4650. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4651. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4652. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4653. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4654. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4655. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4656. string cell4Str1 = string.Empty;
  4657. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  4658. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  4659. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  4660. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  4661. string cellStr = $" 5.其他费用(";
  4662. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4663. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4664. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4665. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4666. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4667. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4668. if (cellStr.Length > 8)
  4669. {
  4670. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4671. }
  4672. cellStr += ")";
  4673. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4674. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  4675. decimal pxFee = dac4.Sum(it => it.Cost);
  4676. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  4677. string celllastStr1 = "";
  4678. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4679. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4680. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4681. celllastStr1 += $",国际旅费 元";
  4682. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4683. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4684. designer.SetDataSource("cell4Str", cell4Str);
  4685. designer.SetDataSource("cellStr", cellStr);
  4686. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4687. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  4688. designer.SetDataSource("celllastStr", celllastStr);
  4689. Workbook wb = designer.Workbook;
  4690. var sheet = wb.Worksheets[0];
  4691. //绑定datatable数据集
  4692. designer.SetDataSource(dtdac1);
  4693. designer.SetDataSource(dtdac2);
  4694. designer.Process();
  4695. var rowStart = dtdac1.Rows.Count;
  4696. while (rowStart > 0)
  4697. {
  4698. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4699. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4700. startIndex++;
  4701. rowStart--;
  4702. }
  4703. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4704. startIndex += 1; //总计行
  4705. rowStart = dtdac2.Rows.Count;
  4706. while (rowStart > 0)
  4707. {
  4708. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4709. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4710. startIndex++;
  4711. rowStart--;
  4712. }
  4713. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4714. wb.CalculateFormula(true);
  4715. //模板文件名
  4716. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  4717. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4718. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4719. return Ok(JsonView(true, "成功", new { Url = url }));
  4720. }
  4721. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4722. {
  4723. //获取模板
  4724. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4725. //载入模板
  4726. Document doc = new Document(tempPath);
  4727. DocumentBuilder builder = new DocumentBuilder(doc);
  4728. Dictionary<string, string> dic = new Dictionary<string, string>();
  4729. dic.Add("GroupName", _DelegationInfo.TeamName);
  4730. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4731. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4732. string missionLeaderJob = "";//负责人job
  4733. int groupNumber = 0; //团人数
  4734. if (DeleClientList.Count > 0)
  4735. {
  4736. missionLeader = DeleClientList[0]?.Name ?? "";
  4737. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4738. }
  4739. dic.Add("MissionLeader", missionLeader); //团负责人
  4740. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4741. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4742. #region MyRegion
  4743. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4744. //{
  4745. // List<string> list = new List<string>();
  4746. // try
  4747. // {
  4748. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4749. // foreach (var item in spilitArr)
  4750. // {
  4751. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4752. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4753. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4754. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4755. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4756. // list.Add(depName);
  4757. // list.Add(arrName);
  4758. // }
  4759. // list = list.Distinct().ToList();
  4760. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4761. // }
  4762. // catch (Exception)
  4763. // {
  4764. // dic.Add("ReturnCode", "行程录入不正确!");
  4765. // }
  4766. //}
  4767. //else
  4768. //{
  4769. // dic.Add("ReturnCode", "未录入行程!");
  4770. //}
  4771. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4772. dic.Add("ReturnCode", string.Join("、", countrys));
  4773. #endregion
  4774. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4775. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4776. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4777. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4778. //{
  4779. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4780. // dic.Add("Day", sp.Days.ToString());
  4781. //}
  4782. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4783. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4784. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4785. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4786. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4787. //培训人员名单
  4788. int cultivateRowIndex = 7;
  4789. foreach (var item in DeleClientList)
  4790. {
  4791. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4792. builder.Write(item.Name);
  4793. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4794. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4795. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4796. string birthDay = "";
  4797. if (item.Birthday != null)
  4798. {
  4799. DateTime dt = Convert.ToDateTime(item.Birthday);
  4800. birthDay = $"{dt.Year}.{dt.Month}";
  4801. }
  4802. builder.Write(birthDay);
  4803. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4804. builder.Write(item.Company);
  4805. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4806. builder.Write(item.Job);
  4807. cultivateRowIndex++;
  4808. }
  4809. //删除多余行
  4810. //cultivateRowIndex -= 2;
  4811. int delRows = 10 + 7 - cultivateRowIndex;
  4812. if (delRows > 0)
  4813. {
  4814. for (int i = 0; i < delRows; i++)
  4815. {
  4816. table1.Rows.RemoveAt(cultivateRowIndex);
  4817. //cultivateRowIndex++;
  4818. }
  4819. }
  4820. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4821. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4822. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4823. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4824. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4825. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4826. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4827. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4828. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4829. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4830. //其他费用
  4831. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4832. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4833. //其他费用合计
  4834. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4835. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4836. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4837. //公务舱合计
  4838. //国际旅费
  4839. string outsideJJ = "";
  4840. string allPriceJJ = "";
  4841. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4842. {
  4843. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4844. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4845. }
  4846. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4847. {
  4848. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4849. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4850. }
  4851. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4852. {
  4853. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4854. dic.Add("AirFeeTotal", airFeeTotalStr);
  4855. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4856. dic.Add("FeeTotal", feeTotalStr);
  4857. }
  4858. foreach (var key in dic.Keys)
  4859. {
  4860. builder.MoveToBookmark(key);
  4861. builder.Write(dic[key]);
  4862. }
  4863. //模板文件名
  4864. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4865. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4866. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4867. return Ok(JsonView(true, "成功", new { Url = url }));
  4868. }
  4869. }
  4870. else if (dto.ExportType == 2) //表格
  4871. {
  4872. //利用键值对存放数据
  4873. Dictionary<string, string> dic = new Dictionary<string, string>();
  4874. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4875. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4876. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4877. dic.Add("Day", sp.Days.ToString());
  4878. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4879. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4880. {
  4881. //获取模板
  4882. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4883. //载入模板
  4884. Document doc = new Document(tempPath);
  4885. DocumentBuilder builder = new DocumentBuilder(doc);
  4886. dic.Add("TeamName", _DelegationInfo.TeamName);
  4887. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4888. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4889. string missionLeaderName = "",
  4890. missionLeaderJob = "";
  4891. if (DeleClientList.Count > 0)
  4892. {
  4893. missionLeaderName = DeleClientList[0].Name;
  4894. missionLeaderJob = DeleClientList[0].Job;
  4895. }
  4896. dic.Add("MissionLeaderName", missionLeaderName);
  4897. dic.Add("MissionLeaderJob", missionLeaderJob);
  4898. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4899. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4900. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4901. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4902. int rowCount = 10;//总人数行
  4903. int startRowIndex = 7; //起始行
  4904. for (int i = 0; i < DeleClientList.Count; i++)
  4905. {
  4906. builder.MoveToCell(0, startRowIndex, 0, 0);
  4907. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4908. builder.MoveToCell(0, startRowIndex, 1, 0);
  4909. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4910. builder.Write(sex);//性别
  4911. builder.MoveToCell(0, startRowIndex, 2, 0);
  4912. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4913. builder.MoveToCell(0, startRowIndex, 3, 0);
  4914. builder.Write(DeleClientList[i].Company);//工作单位
  4915. builder.MoveToCell(0, startRowIndex, 4, 0);
  4916. builder.Write(DeleClientList[i].Job);//职务及级别
  4917. builder.MoveToCell(0, startRowIndex, 5, 0);
  4918. builder.Write("");//人员属性
  4919. builder.MoveToCell(0, startRowIndex, 6, 0);
  4920. builder.Write("");//上次出国时间
  4921. startRowIndex++;
  4922. }
  4923. int nullRow = rowCount - DeleClientList.Count;//空行
  4924. for (int i = 0; i < nullRow; i++)
  4925. {
  4926. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4927. }
  4928. foreach (var key in dic.Keys)
  4929. {
  4930. builder.MoveToBookmark(key);
  4931. builder.Write(dic[key]);
  4932. }
  4933. //模板文件名
  4934. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4935. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4936. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4937. return Ok(JsonView(true, "成功", new { Url = url }));
  4938. }
  4939. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4940. {
  4941. //获取模板
  4942. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4943. //载入模板
  4944. Document doc = new Document(tempPath);
  4945. DocumentBuilder builder = new DocumentBuilder(doc);
  4946. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4947. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4948. dic.Add("Names", Names);
  4949. int accommodationRows = 12, foodandotherRows = 12;
  4950. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4951. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4952. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4953. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4954. int accommodationStartIndex = 6;
  4955. decimal dac1totalPrice = 0.00M;
  4956. foreach (var dac in dac1)
  4957. {
  4958. if (dac.SubTotal == 0)
  4959. {
  4960. continue;
  4961. }
  4962. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4963. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4964. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4965. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4966. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4967. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4968. builder.Write(currency);//币种
  4969. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4970. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4971. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4972. builder.Write("");//人数
  4973. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4974. builder.Write("");//天数
  4975. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4976. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4977. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4978. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4979. builder.Write(rate.ToString("#0.0000"));//汇率
  4980. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4981. decimal rbmPrice = rate * dac.SubTotal;
  4982. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4983. accommodationStartIndex++;
  4984. dac1totalPrice += rbmPrice;
  4985. }
  4986. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4987. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4988. builder.Write("小计");
  4989. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4990. builder.Write(dac1totalPrice.ToString("#0.00"));
  4991. accommodationStartIndex++;
  4992. int nullRow = accommodationRows - dac1.Count;
  4993. //删除空行
  4994. //if (nullRow > 0)
  4995. //{
  4996. // int rowIndex = accommodationStartIndex;
  4997. // for (int i = 0; i < nullRow; i++)
  4998. // {
  4999. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  5000. // row.Remove();
  5001. // rowIndex++;
  5002. // }
  5003. //}
  5004. if (dac2.Count == dac3.Count)//国家 币种 金额
  5005. {
  5006. for (int i = 0; i < dac2.Count; i++)
  5007. {
  5008. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5009. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5010. }
  5011. }
  5012. int foodandotherStartIndex = 19;//
  5013. decimal dac2totalPrice = 0.00M;
  5014. foreach (var dac in dac2)
  5015. {
  5016. if (dac.SubTotal == 0)
  5017. {
  5018. continue;
  5019. }
  5020. //foodandotherStartIndex = 12;
  5021. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5022. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  5023. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5024. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  5025. builder.Write(currency);//币种
  5026. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5027. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5028. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5029. builder.Write("");//人数
  5030. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5031. builder.Write("");//天数
  5032. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5033. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5034. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5035. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5036. builder.Write(rate.ToString("#0.0000"));//汇率
  5037. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5038. decimal rbmPrice = rate * dac.SubTotal;
  5039. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5040. foodandotherStartIndex++;
  5041. dac2totalPrice += rbmPrice;
  5042. }
  5043. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5044. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5045. //删除空行
  5046. //if (dac2.Count < foodandotherRows)
  5047. //{
  5048. // while (table2.Rows.Count > dac2.Count)
  5049. // {
  5050. // table2.Rows.RemoveAt(dac2.Count);
  5051. // }
  5052. //}
  5053. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5054. string otherFeeStr = "";
  5055. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5056. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5057. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5058. if (otherFeeStr.Length > 0)
  5059. {
  5060. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5061. otherFeeStr = $"({otherFeeStr})";
  5062. dic.Add("OtherFeeStr", otherFeeStr);
  5063. }
  5064. foreach (var key in dic.Keys)
  5065. {
  5066. builder.MoveToBookmark(key);
  5067. builder.Write(dic[key]);
  5068. }
  5069. //模板文件名
  5070. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5071. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5072. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5073. return Ok(JsonView(true, "成功", new { Url = url }));
  5074. }
  5075. }
  5076. else if (dto.ExportType == 3)
  5077. {
  5078. if (dto.SubTypeId == 1) //团组成员名单
  5079. {
  5080. if (DeleClientList.Count < 1)
  5081. {
  5082. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  5083. }
  5084. //获取模板
  5085. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  5086. //载入模板
  5087. Document doc = new Document(tempPath);
  5088. DocumentBuilder builder = new DocumentBuilder(doc);
  5089. //获取word里所有表格
  5090. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5091. //获取所填表格的序数
  5092. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  5093. var rowStart = tableOne.Rows[0]; //获取第1行
  5094. //循环赋值
  5095. for (int i = 0; i < DeleClientList.Count; i++)
  5096. {
  5097. builder.MoveToCell(0, i + 1, 0, 0);
  5098. builder.Write(DeleClientList[i].Name);
  5099. builder.MoveToCell(0, i + 1, 1, 0);
  5100. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5101. builder.Write(sex);
  5102. builder.MoveToCell(0, i + 1, 2, 0);
  5103. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  5104. builder.MoveToCell(0, i + 1, 3, 0);
  5105. builder.Write(DeleClientList[i].Company);
  5106. builder.MoveToCell(0, i + 1, 4, 0);
  5107. builder.Write(DeleClientList[i].Job);
  5108. }
  5109. //删除多余行
  5110. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  5111. {
  5112. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  5113. }
  5114. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  5115. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  5116. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  5117. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5118. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5119. return Ok(JsonView(true, "成功", new { Url = url }));
  5120. }
  5121. }
  5122. return Ok(JsonView(false, "操作失败!"));
  5123. }
  5124. catch (Exception ex)
  5125. {
  5126. return Ok(JsonView(false, ex.Message));
  5127. }
  5128. }
  5129. /// <summary>
  5130. /// 获取三公费用标准city
  5131. /// </summary>
  5132. /// <param name="placeData"></param>
  5133. /// <param name="nationalTravelFeeId"></param>
  5134. /// <returns></returns>
  5135. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  5136. {
  5137. string _city = string.Empty;
  5138. if (placeData.Count < 1) return _city;
  5139. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  5140. if (data == null) return _city;
  5141. string country = data.Country;
  5142. string city = data.City;
  5143. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  5144. else _city = city;
  5145. return _city;
  5146. }
  5147. /// <summary>
  5148. /// 团组模块 - 出入境费用 - 明细表导出
  5149. /// </summary>
  5150. /// <returns></returns>
  5151. [HttpPost]
  5152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5153. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  5154. {
  5155. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  5156. if (data.Code != 0)
  5157. {
  5158. return Ok(JsonView(false, data.Msg));
  5159. }
  5160. return Ok(JsonView(true, data.Msg, data.Data));
  5161. }
  5162. /// <summary>
  5163. /// 团组模块 - 出入境费用 - 一键清空
  5164. /// </summary>
  5165. /// <returns></returns>
  5166. [HttpPost]
  5167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5168. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  5169. {
  5170. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  5171. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  5172. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  5173. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  5174. if (_view.Code == 0)
  5175. {
  5176. return Ok(JsonView(true, "操作成功"));
  5177. }
  5178. return Ok(JsonView(false, "操作失败"));
  5179. }
  5180. /// <summary>
  5181. /// 团组模块 - 出入境费用 - 子项删除
  5182. /// </summary>
  5183. /// <returns></returns>
  5184. [HttpPost]
  5185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5186. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  5187. {
  5188. try
  5189. {
  5190. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  5191. if (data.Code != 0)
  5192. {
  5193. return Ok(JsonView(false, data.Msg));
  5194. }
  5195. return Ok(JsonView(true, "操作成功!", data.Data));
  5196. }
  5197. catch (Exception ex)
  5198. {
  5199. return Ok(JsonView(false, ex.Message));
  5200. }
  5201. }
  5202. /// <summary>
  5203. /// 团组模块 - 出入境国家费用标准 List
  5204. /// </summary>
  5205. /// <returns></returns>
  5206. [HttpPost]
  5207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5208. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  5209. {
  5210. try
  5211. {
  5212. Stopwatch sw = new Stopwatch();
  5213. sw.Start();
  5214. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  5215. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5216. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5217. Where gntf.Isdel = 0");
  5218. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  5219. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  5220. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  5221. //foreach (var item in nationalTravel)
  5222. //{
  5223. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  5224. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  5225. // if (otherData != null)
  5226. // {
  5227. // cityData.Remove(otherData);
  5228. // cityData.Add(otherData);
  5229. // }
  5230. // nationalTravelFeeData1.Add(new
  5231. // {
  5232. // Country = item.Country,
  5233. // CityData = cityData
  5234. // });
  5235. //}
  5236. sw.Stop();
  5237. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  5238. }
  5239. catch (Exception ex)
  5240. {
  5241. return Ok(JsonView(false, ex.Message));
  5242. throw;
  5243. }
  5244. }
  5245. /// <summary>
  5246. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  5247. /// </summary>
  5248. /// <returns></returns>
  5249. [HttpPost]
  5250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5251. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  5252. {
  5253. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  5254. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  5255. List<string> countryData = new List<string>();
  5256. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  5257. countryData = countryData.Distinct().ToList();
  5258. List<dynamic> dataSource = new List<dynamic>();
  5259. foreach (var item in countryData)
  5260. {
  5261. List<string> cityData1 = new List<string>();
  5262. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  5263. var countryData2 = new
  5264. {
  5265. CountryName = item,
  5266. CityData = cityData1
  5267. };
  5268. dataSource.Add(countryData2);
  5269. }
  5270. return Ok(JsonView(true, "查询成功!", dataSource));
  5271. }
  5272. /// <summary>
  5273. /// 团组模块 - 出入境国家费用标准 Page List
  5274. /// </summary>
  5275. /// <returns></returns>
  5276. [HttpPost]
  5277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5278. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  5279. {
  5280. int portId = dto.PortType;
  5281. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5282. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  5283. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  5284. string whereSql = string.Empty;
  5285. if (!string.IsNullOrEmpty(dto.Country))
  5286. {
  5287. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  5288. }
  5289. if (!string.IsNullOrEmpty(dto.City))
  5290. {
  5291. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  5292. }
  5293. string pageSql = string.Format(@"Select * From (
  5294. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  5295. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  5296. From Grp_NationalTravelFee gntf
  5297. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5298. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5299. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  5300. RefAsync<int> total = 0;
  5301. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5302. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  5303. }
  5304. /// <summary>
  5305. /// 团组模块 - 出入境国家费用标准 根据城市查询
  5306. /// </summary>
  5307. /// <returns></returns>
  5308. [HttpPost]
  5309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5310. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  5311. {
  5312. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  5313. int portId = dto.PortType;
  5314. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  5315. string whereSql = string.Empty;
  5316. if (!string.IsNullOrEmpty(dto.Country))
  5317. {
  5318. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  5319. }
  5320. if (!string.IsNullOrEmpty(dto.City))
  5321. {
  5322. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  5323. }
  5324. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  5325. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  5326. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  5327. From Grp_NationalTravelFee gntf
  5328. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  5329. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  5330. Where gntf.Isdel = 0 {0} ", whereSql);
  5331. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  5332. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  5333. }
  5334. /// <summary>
  5335. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  5336. /// </summary>
  5337. /// <returns></returns>
  5338. [HttpPost]
  5339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5340. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  5341. {
  5342. try
  5343. {
  5344. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  5345. if (data.Code != 0)
  5346. {
  5347. return Ok(JsonView(false, data.Msg));
  5348. }
  5349. return Ok(JsonView(true, "操作成功!", data.Data));
  5350. }
  5351. catch (Exception ex)
  5352. {
  5353. return Ok(JsonView(false, ex.Message));
  5354. }
  5355. }
  5356. /// <summary>
  5357. /// 团组模块 - 出入境国家费用标准 - Del
  5358. /// </summary>
  5359. /// <returns></returns>
  5360. [HttpPost]
  5361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5362. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  5363. {
  5364. try
  5365. {
  5366. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5367. {
  5368. Id = dto.Id,
  5369. DeleteUserId = dto.DeleteUserId,
  5370. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5371. IsDel = 1
  5372. };
  5373. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5374. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5375. .WhereColumns(it => new { it.Id })
  5376. .ExecuteCommandAsync();
  5377. if (delStatus <= 0)
  5378. {
  5379. return Ok(JsonView(false, "删除失败!"));
  5380. }
  5381. return Ok(JsonView(true, "操作成功!"));
  5382. }
  5383. catch (Exception ex)
  5384. {
  5385. return Ok(JsonView(false, ex.Message));
  5386. }
  5387. }
  5388. #endregion
  5389. #region 签证费用录入
  5390. /// <summary>
  5391. /// 根据diid查询签证费用列表
  5392. /// </summary>
  5393. /// <param name="dto"></param>
  5394. /// <returns></returns>
  5395. [HttpPost]
  5396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5397. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5398. {
  5399. try
  5400. {
  5401. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5402. if (groupData.Code != 0)
  5403. {
  5404. return Ok(JsonView(false, groupData.Msg));
  5405. }
  5406. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5407. }
  5408. catch (Exception ex)
  5409. {
  5410. return Ok(JsonView(false, ex.Message));
  5411. }
  5412. }
  5413. /// <summary>
  5414. /// 根据签证费用Id查询单条数据及c表数据
  5415. /// </summary>
  5416. /// <param name="dto"></param>
  5417. /// <returns></returns>
  5418. [HttpPost]
  5419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5420. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5421. {
  5422. try
  5423. {
  5424. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5425. if (groupData.Code != 0)
  5426. {
  5427. return Ok(JsonView(false, groupData.Msg));
  5428. }
  5429. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5430. }
  5431. catch (Exception ex)
  5432. {
  5433. return Ok(JsonView(false, ex.Message));
  5434. }
  5435. }
  5436. /// <summary>
  5437. /// 签证费用删除
  5438. /// </summary>
  5439. /// <param name="dto"></param>
  5440. /// <returns></returns>
  5441. [HttpPost]
  5442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5443. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5444. {
  5445. _sqlSugar.BeginTran();
  5446. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5447. if (!res)
  5448. {
  5449. _sqlSugar.RollbackTran();
  5450. return Ok(JsonView(false, "删除失败"));
  5451. }
  5452. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5453. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5454. .SetColumns(a => new Grp_CreditCardPayment()
  5455. {
  5456. IsDel = 1,
  5457. DeleteUserId = dto.DeleteUserId,
  5458. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5459. }).ExecuteCommand();
  5460. if (resSub < 1)
  5461. {
  5462. _sqlSugar.RollbackTran();
  5463. return Ok(JsonView(false, "删除失败"));
  5464. }
  5465. _sqlSugar.CommitTran();
  5466. return Ok(JsonView(true, "删除成功!"));
  5467. }
  5468. /// <summary>
  5469. /// 签证费用录入下拉框初始化
  5470. /// </summary>
  5471. /// <returns></returns>
  5472. [HttpPost]
  5473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5474. public async Task<IActionResult> VisaPriceAddSelect()
  5475. {
  5476. try
  5477. {
  5478. //支付方式
  5479. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5480. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5481. //币种
  5482. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5483. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5484. //乘客类型
  5485. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5486. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5487. //卡类型
  5488. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5489. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5490. var data = new
  5491. {
  5492. Payment = _Payment,
  5493. CurrencyList = _CurrencyList,
  5494. PassengerType = _PassengerType,
  5495. BankCard = _BankCard
  5496. };
  5497. return Ok(JsonView(true, "查询成功!", data));
  5498. }
  5499. catch (Exception ex)
  5500. {
  5501. return Ok(JsonView(false, "程序错误!"));
  5502. throw;
  5503. }
  5504. }
  5505. /// <summary>
  5506. /// 签证费用录入操作(Status:1.新增,2.修改)
  5507. /// </summary>
  5508. /// <param name="dto"></param>
  5509. /// <returns></returns>
  5510. [HttpPost]
  5511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5512. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5513. {
  5514. try
  5515. {
  5516. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5517. if (groupData.Code != 0)
  5518. {
  5519. return Ok(JsonView(false, groupData.Msg));
  5520. }
  5521. #region 应用推送
  5522. try
  5523. {
  5524. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5525. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5526. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5527. }
  5528. catch (Exception ex)
  5529. {
  5530. }
  5531. #endregion
  5532. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5533. }
  5534. catch (Exception ex)
  5535. {
  5536. return Ok(JsonView(false, ex.Message));
  5537. }
  5538. }
  5539. #endregion
  5540. #region 签证提成录入
  5541. /// <summary>
  5542. /// 签证提成录入
  5543. /// 基础数据
  5544. /// </summary>
  5545. /// <param name="_dto"></param>
  5546. /// <returns></returns>
  5547. [HttpGet]
  5548. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5549. public async Task<IActionResult> VisaCommissionInit()
  5550. {
  5551. return Ok(await _visaCommissionRep._Init());
  5552. }
  5553. /// <summary>
  5554. /// 签证提成录入
  5555. /// Item
  5556. /// </summary>
  5557. /// <param name="_dto"></param>
  5558. /// <returns></returns>
  5559. [HttpGet]
  5560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5561. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto dto)
  5562. {
  5563. var validator = new VisaCommissionItemDtoValidator();
  5564. var validatorRes = await validator.ValidateAsync(dto);
  5565. if (!validatorRes.IsValid)
  5566. {
  5567. StringBuilder sb = new StringBuilder();
  5568. foreach (var item in validatorRes.Errors)
  5569. {
  5570. sb.AppendLine(item.ErrorMessage);
  5571. }
  5572. return Ok(JsonView(false, sb.ToString()));
  5573. }
  5574. return Ok(await _visaCommissionRep._Init());
  5575. }
  5576. #endregion
  5577. #region op费用录入
  5578. /// <summary>
  5579. /// 根据diid查询op费用列表
  5580. /// </summary>
  5581. /// <param name="dto"></param>
  5582. /// <returns></returns>
  5583. [HttpPost]
  5584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5585. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5586. {
  5587. try
  5588. {
  5589. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5590. if (groupData.Code != 0)
  5591. {
  5592. return Ok(JsonView(false, groupData.Msg));
  5593. }
  5594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5595. }
  5596. catch (Exception ex)
  5597. {
  5598. return Ok(JsonView(false, ex.Message));
  5599. }
  5600. }
  5601. /// <summary>
  5602. /// 根据op费用Id查询单条数据及c表数据
  5603. /// </summary>
  5604. /// <param name="dto"></param>
  5605. /// <returns></returns>
  5606. [HttpPost]
  5607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5608. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5609. {
  5610. try
  5611. {
  5612. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5613. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5614. var data = new
  5615. {
  5616. CarTouristGuideGround = _groupData,
  5617. CreditCardPayment = _creditCardPayment
  5618. };
  5619. return Ok(JsonView(true, "查询成功!", data));
  5620. }
  5621. catch (Exception ex)
  5622. {
  5623. return Ok(JsonView(false, "程序错误!"));
  5624. }
  5625. }
  5626. /// <summary>
  5627. /// op费用删除
  5628. /// </summary>
  5629. /// <param name="dto"></param>
  5630. /// <returns></returns>
  5631. [HttpPost]
  5632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5633. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5634. {
  5635. try
  5636. {
  5637. _sqlSugar.BeginTran();
  5638. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5639. if (!res)
  5640. {
  5641. return Ok(JsonView(false, "删除失败"));
  5642. }
  5643. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5644. {
  5645. IsDel = 1,
  5646. DeleteUserId = dto.DeleteUserId,
  5647. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5648. }).ExecuteCommandAsync();
  5649. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5650. {
  5651. IsDel = 1,
  5652. DeleteUserId = dto.DeleteUserId,
  5653. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5654. }).ExecuteCommandAsync();
  5655. #region 删除超支相关数据
  5656. //删除导入的超支数据
  5657. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  5658. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  5659. {
  5660. IsDel = 1,
  5661. DeleteUserId = dto.DeleteUserId,
  5662. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5663. }).ExecuteCommand();
  5664. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  5665. {
  5666. IsDel = 1,
  5667. DeleteUserId = dto.DeleteUserId,
  5668. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5669. }).ExecuteCommand() ;
  5670. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x=>x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  5671. {
  5672. IsDel = 1,
  5673. DeleteUserId = dto.DeleteUserId,
  5674. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5675. }).ExecuteCommand();
  5676. #endregion
  5677. _sqlSugar.CommitTran();
  5678. return Ok(JsonView(true, "删除成功!"));
  5679. }
  5680. catch (Exception ex)
  5681. {
  5682. _sqlSugar.RollbackTran();
  5683. return Ok(JsonView(false, "程序错误!" + ex.Message));
  5684. }
  5685. }
  5686. /// <summary>
  5687. /// op费用录入操作(Status:1.新增,2.修改)
  5688. /// </summary>
  5689. /// <param name="dto"></param>
  5690. /// <returns></returns>
  5691. [HttpPost]
  5692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5693. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5694. {
  5695. try
  5696. {
  5697. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5698. if (groupData.Code != 0)
  5699. {
  5700. return Ok(JsonView(false, groupData.Msg));
  5701. }
  5702. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5703. }
  5704. catch (Exception ex)
  5705. {
  5706. return Ok(JsonView(false, ex.Message));
  5707. }
  5708. }
  5709. /// <summary>
  5710. /// 填写费用详细页面初始化绑定
  5711. /// </summary>
  5712. /// <param name="dto"></param>
  5713. /// <returns></returns>
  5714. [HttpPost]
  5715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5716. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5717. {
  5718. try
  5719. {
  5720. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5721. if (groupData.Code != 0)
  5722. {
  5723. return Ok(JsonView(false, groupData.Msg));
  5724. }
  5725. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5726. }
  5727. catch (Exception ex)
  5728. {
  5729. return Ok(JsonView(false, ex.Message));
  5730. }
  5731. }
  5732. /// <summary>
  5733. /// 根据op费用Id查询详细数据
  5734. /// </summary>
  5735. /// <param name="dto"></param>
  5736. /// <returns></returns>
  5737. [HttpPost]
  5738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5739. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5740. {
  5741. try
  5742. {
  5743. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5744. if (groupData.Code != 0)
  5745. {
  5746. return Ok(JsonView(false, groupData.Msg));
  5747. }
  5748. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5749. }
  5750. catch (Exception ex)
  5751. {
  5752. return Ok(JsonView(false, ex.Message));
  5753. }
  5754. }
  5755. /// <summary>
  5756. /// OP费用录入填写详情
  5757. /// </summary>
  5758. /// <param name="dto"></param>
  5759. /// <returns></returns>
  5760. [HttpPost]
  5761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5762. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5763. {
  5764. try
  5765. {
  5766. #region 参数校验
  5767. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5768. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5769. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5770. #endregion
  5771. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5772. if (groupData.Code != 0)
  5773. {
  5774. return Ok(JsonView(false, groupData.Msg));
  5775. }
  5776. //自动审核
  5777. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5778. #region 应用推送
  5779. try
  5780. {
  5781. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5782. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5783. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5784. }
  5785. catch (Exception ex)
  5786. {
  5787. }
  5788. #endregion
  5789. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5790. }
  5791. catch (Exception ex)
  5792. {
  5793. return Ok(JsonView(false, ex.Message));
  5794. }
  5795. }
  5796. /// <summary>
  5797. /// 获取三公详细所有城市
  5798. /// </summary>
  5799. /// <returns></returns>
  5800. [HttpGet]
  5801. public IActionResult OpCarCityResult()
  5802. {
  5803. var jw = JsonView(false);
  5804. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5805. {
  5806. x.Id,
  5807. x.Country,
  5808. x.City,
  5809. }).ToList();
  5810. if (data.Count > 0)
  5811. {
  5812. jw = JsonView(true, "获取成功!", data);
  5813. }
  5814. else
  5815. {
  5816. jw.Msg = "城市数据为空!";
  5817. jw.Data = new string[0];
  5818. }
  5819. return Ok(jw);
  5820. }
  5821. /// <summary>
  5822. /// 导出地接费用明细
  5823. /// </summary>
  5824. /// <param name="dto"></param>
  5825. /// <returns></returns>
  5826. [HttpPost]
  5827. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5828. {
  5829. var jw = JsonView(false);
  5830. if (dto.Diid < 1)
  5831. {
  5832. jw.Msg = "请输入正确的diid!";
  5833. return Ok(jw);
  5834. }
  5835. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5836. if (group == null)
  5837. {
  5838. jw.Msg = "未找到团组信息!";
  5839. return Ok(jw);
  5840. }
  5841. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5842. if (localGuideArr.Count == 0)
  5843. {
  5844. jw.Msg = "该团组暂无地接信息!";
  5845. return Ok(jw);
  5846. }
  5847. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5848. var overspendSoure = new Dictionary<int, int>
  5849. {
  5850. { 91, 982 }, //车
  5851. { 92 , 1059} ,//导游
  5852. { 994 , 1073}, //翻译
  5853. { 988 , 1074 }, //早餐
  5854. { 93 , 1075 }, //午餐
  5855. { 989 , 1076 }, //晚餐
  5856. };
  5857. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5858. foreach (var groupArr in localGroup)
  5859. {
  5860. var keyValue = groupArr.Key;
  5861. if (int.TryParse(keyValue, out int cityid))
  5862. {
  5863. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5864. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5865. }
  5866. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5867. foreach (var item in groupArr)
  5868. {
  5869. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5870. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5871. new Grp_CarTouristGuideGroundReservationsContentExtend
  5872. {
  5873. Count = a.Count,
  5874. CreateTime = a.CreateTime,
  5875. CreateUserId = a.CreateUserId,
  5876. CTGGRId = a.CTGGRId,
  5877. Currency = a.Currency,
  5878. DatePrice = a.DatePrice,
  5879. DeleteTime = a.DeleteTime,
  5880. DeleteUserId = a.DeleteUserId,
  5881. DiId = a.DiId,
  5882. Id = a.Id,
  5883. IsDel = a.IsDel,
  5884. Price = a.Price,
  5885. PriceContent = a.PriceContent,
  5886. Remark = a.Remark,
  5887. SId = a.SId,
  5888. SidName = b.Name,
  5889. Units = a.Units,
  5890. }
  5891. ).ToList();
  5892. if (content.Count > 0)
  5893. {
  5894. contentArr.Add(content);
  5895. }
  5896. }
  5897. //open excel
  5898. //set excel
  5899. //save excel
  5900. try
  5901. {
  5902. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5903. IWorkbook workbook;
  5904. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5905. {
  5906. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5907. }
  5908. else
  5909. {
  5910. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5911. }
  5912. ISheet sheet = workbook.GetSheetAt(0);
  5913. var rowStartIndex = 2;
  5914. var clounmCount = 10;
  5915. var initStyleRow = sheet.GetRow(2);
  5916. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5917. //var overspendArrDetail =
  5918. var existsId = new List<CarCompare>();
  5919. var lastElem = arr.Last();
  5920. var thisSid = -1;
  5921. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5922. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5923. {
  5924. Name = "未知币种!",
  5925. Remark = "未知币种!",
  5926. };
  5927. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5928. Action cloneRowFn = () =>
  5929. {
  5930. rowStartIndex++;
  5931. var cloneRow = sheet.CreateRow(rowStartIndex);
  5932. // 复制样式
  5933. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5934. {
  5935. ICell sourceCell = initStyleRow.GetCell(i);
  5936. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5937. // 确保单元格存在样式
  5938. if (sourceCell.CellStyle != null)
  5939. {
  5940. targetCell.CellStyle = sourceCell.CellStyle;
  5941. }
  5942. }
  5943. };
  5944. var mergeRow = () =>
  5945. {
  5946. for (int i = 2; i < sheet.LastRowNum; i++)
  5947. {
  5948. var row = sheet.GetRow(i);
  5949. var cellFirst = row.GetCell(0);
  5950. var thisIndex = i + 1;
  5951. while (thisIndex < sheet.LastRowNum)
  5952. {
  5953. var nextRow = sheet.GetRow(thisIndex);
  5954. var nextCellFirst = nextRow.GetCell(0);
  5955. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5956. {
  5957. thisIndex++;
  5958. }
  5959. else
  5960. {
  5961. break;
  5962. }
  5963. }
  5964. thisIndex--;
  5965. if (thisIndex != i)
  5966. {
  5967. //合并row
  5968. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5969. i, // 起始行索引(0-based)
  5970. thisIndex, // 结束行索引(0-based)
  5971. 0, // 起始列索引(0-based)
  5972. 0 // 结束列索引(0-based)
  5973. );
  5974. sheet.AddMergedRegion(cellRangeAddress);
  5975. i = thisIndex;
  5976. }
  5977. }
  5978. };
  5979. var chaoshiNumber = 0;
  5980. var totalNumber = 0.00M;
  5981. string lastStr = "";
  5982. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5983. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5984. {
  5985. b.IsAuditGM,
  5986. x.Id,
  5987. x.Area,
  5988. b.PayPercentage,
  5989. b.PayMoney,
  5990. }).ToList();
  5991. string yesPayment = "", noPayment = "";
  5992. foreach (var item in queryCarArrByCityAndDiid)
  5993. {
  5994. if (item.IsAuditGM == 1)
  5995. {
  5996. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5997. }
  5998. else
  5999. {
  6000. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  6001. }
  6002. }
  6003. lastStr = yesPayment + noPayment;
  6004. foreach (var item in arr)
  6005. {
  6006. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  6007. {
  6008. if (thisSid != item.SId)
  6009. {
  6010. if (thisSid == -1)
  6011. {
  6012. thisSid = item.SId;
  6013. }
  6014. else
  6015. {
  6016. //合并小计行
  6017. //创建合并区域的实例
  6018. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6019. rowStartIndex, // 起始行索引(0-based)
  6020. rowStartIndex, // 结束行索引(0-based)
  6021. 0, // 起始列索引(0-based)
  6022. 3 // 结束列索引(0-based)
  6023. );
  6024. sheet.AddMergedRegion(cellRangeAddress);
  6025. var CellStyle = workbook.CreateCellStyle();
  6026. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6027. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6028. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6029. for (int i = 0; i <= clounmCount; i++)
  6030. {
  6031. if (i > 6)
  6032. {
  6033. var CellStyle1 = workbook.CreateCellStyle();
  6034. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6035. IFont Font = workbook.CreateFont(); // 创建字体
  6036. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6037. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6038. CellStyle1.SetFont(Font);
  6039. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6040. }
  6041. else
  6042. {
  6043. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6044. }
  6045. }
  6046. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6047. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6048. //超时合计
  6049. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6050. //超时数
  6051. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6052. //超时合计费用
  6053. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6054. thisSid = item.SId;
  6055. cloneRowFn();
  6056. chaoshiNumber = 0;
  6057. totalNumber = 0;
  6058. }
  6059. }
  6060. IRow row = sheet.GetRow(rowStartIndex);
  6061. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6062. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  6063. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  6064. if (isOpenOverspendSoure)
  6065. {
  6066. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6067. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  6068. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  6069. }
  6070. for (int i = 0; i <= clounmCount; i++)
  6071. {
  6072. var cell = row.GetCell(i);
  6073. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  6074. if (cell == null)
  6075. {
  6076. cell = row.CreateCell(i);
  6077. }
  6078. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  6079. fontRed.CloneStyleFrom(cell.CellStyle);
  6080. IFont Font = workbook.CreateFont(); // 创建字体
  6081. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  6082. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6083. fontRed.SetFont(Font);
  6084. byte[] rgb = new byte[3] { 255, 242, 204 };
  6085. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  6086. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  6087. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  6088. if (workbook is XSSFWorkbook)
  6089. {
  6090. BackgroundColor255_242_204.FillForegroundColor = 0;
  6091. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  6092. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  6093. }
  6094. else
  6095. {
  6096. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  6097. }
  6098. if (i == 1 || i > 6)
  6099. {
  6100. if (i > 6)
  6101. {
  6102. fontRed.FillForegroundColor = 0;
  6103. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  6104. fontRed.FillPattern = FillPattern.SolidForeground;
  6105. }
  6106. cell.CellStyle = fontRed;
  6107. }
  6108. if (i > 2 && i < 7)
  6109. {
  6110. cell.CellStyle = BackgroundColor255_242_204;
  6111. }
  6112. cell.SetCellValue(setCellValue); //写入单元格
  6113. }
  6114. if (overspendSoure.ContainsKey(thisSid))
  6115. {
  6116. var overspendId = overspendSoure[thisSid];
  6117. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  6118. }
  6119. cloneRowFn();
  6120. existsId.Add(new CarCompare
  6121. {
  6122. DataPrice = item.DatePrice.ObjToDate(),
  6123. Sid = item.SId
  6124. });
  6125. }
  6126. if (item.Equals(lastElem))
  6127. {
  6128. //合并小计行
  6129. //创建合并区域的实例
  6130. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  6131. rowStartIndex, // 起始行索引(0-based)
  6132. rowStartIndex, // 结束行索引(0-based)
  6133. 0, // 起始列索引(0-based)
  6134. 3 // 结束列索引(0-based)
  6135. );
  6136. sheet.AddMergedRegion(cellRangeAddress);
  6137. var CellStyle = workbook.CreateCellStyle();
  6138. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6139. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  6140. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  6141. for (int i = 0; i <= clounmCount; i++)
  6142. {
  6143. if (i > 6)
  6144. {
  6145. var CellStyle1 = workbook.CreateCellStyle();
  6146. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  6147. IFont Font = workbook.CreateFont(); // 创建字体
  6148. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  6149. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  6150. CellStyle1.SetFont(Font);
  6151. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  6152. }
  6153. else
  6154. {
  6155. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  6156. }
  6157. }
  6158. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  6159. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  6160. //超时合计
  6161. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  6162. //超时数
  6163. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  6164. //超时合计费用
  6165. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  6166. cloneRowFn();
  6167. // 创建合并区域的实例
  6168. cellRangeAddress = new CellRangeAddress(
  6169. rowStartIndex, // 起始行索引(0-based)
  6170. rowStartIndex, // 结束行索引(0-based)
  6171. 0, // 起始列索引(0-based)
  6172. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  6173. );
  6174. // 添加合并区域
  6175. sheet.AddMergedRegion(cellRangeAddress);
  6176. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  6177. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  6178. }
  6179. }
  6180. mergeRow();
  6181. // 保存修改后的Excel文件到新文件
  6182. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  6183. // new FileStream(newFilePath, FileMode.CreateNew)
  6184. using (var stream = new MemoryStream())
  6185. {
  6186. workbook.Write(stream, true);
  6187. stream.Flush();
  6188. stream.Seek(0, SeekOrigin.Begin);
  6189. MemoryStream memoryStream = new MemoryStream();
  6190. stream.CopyTo(memoryStream);
  6191. memoryStream.Seek(0, SeekOrigin.Begin);
  6192. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  6193. }
  6194. workbook.Close();
  6195. workbook.Dispose();
  6196. }
  6197. catch (Exception ex)
  6198. {
  6199. jw.Msg = "出现异常!" + ex.Message;
  6200. return Ok(jw);
  6201. }
  6202. }
  6203. if (Zips.Count > 0)
  6204. {
  6205. IOOperatorHelper io = new IOOperatorHelper();
  6206. var byts = io.ConvertZipStream(Zips);
  6207. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  6208. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  6209. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  6210. }
  6211. else
  6212. {
  6213. jw.Msg = "暂无生成文件!";
  6214. }
  6215. return Ok(jw);
  6216. }
  6217. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  6218. {
  6219. string outStr = string.Empty;
  6220. switch (i)
  6221. {
  6222. case 0:
  6223. outStr = arr[0].SidName;
  6224. break;
  6225. case 1:
  6226. outStr = arr[0].DataPriceStr;
  6227. break;
  6228. case 2:
  6229. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  6230. break;
  6231. case 4:
  6232. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  6233. break;
  6234. case 7:
  6235. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6236. {
  6237. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  6238. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  6239. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  6240. }
  6241. break;
  6242. case 8:
  6243. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6244. {
  6245. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  6246. }
  6247. break;
  6248. case 9:
  6249. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6250. {
  6251. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  6252. }
  6253. break;
  6254. case 10:
  6255. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  6256. {
  6257. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  6258. }
  6259. break;
  6260. }
  6261. return outStr;
  6262. }
  6263. #region OP行程单
  6264. /// <summary>
  6265. /// OP行程单初始化
  6266. /// </summary>
  6267. /// <param name="dto"></param>
  6268. /// <returns></returns>
  6269. [HttpPost]
  6270. public IActionResult InitOpTravel(InitOpTravelDto dto)
  6271. {
  6272. var jw = JsonView(false);
  6273. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  6274. var group = groupList.First();
  6275. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  6276. if (group == null)
  6277. {
  6278. jw.Msg = "暂无团组!";
  6279. return Ok(jw);
  6280. }
  6281. group = groupList.Find(x => x.Id == diid);
  6282. if (group == null)
  6283. {
  6284. jw.Msg = "请输入正确的团组ID!";
  6285. return Ok(jw);
  6286. }
  6287. string city = string.Empty;
  6288. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  6289. if (blackCode.Count > 0)
  6290. {
  6291. var black = blackCode.First();
  6292. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  6293. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  6294. if (blackSp.Length > 0)
  6295. {
  6296. try
  6297. {
  6298. var cityArrCode = new List<string>(20);
  6299. foreach (var item in blackSp)
  6300. {
  6301. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  6302. var IndexSelect = itemSp[2];
  6303. var cityArrCodeLength = cityArrCode.Count - 1;
  6304. var startCity = IndexSelect.Substring(0, 3);
  6305. if (cityArrCodeLength > 0)
  6306. {
  6307. var arrEndCity = cityArrCode[cityArrCodeLength];
  6308. if (arrEndCity != startCity)
  6309. {
  6310. cityArrCode.Add(startCity.ToUpper());
  6311. }
  6312. }
  6313. else
  6314. {
  6315. cityArrCode.Add(startCity.ToUpper());
  6316. }
  6317. var endCity = IndexSelect.Substring(3, 3);
  6318. cityArrCode.Add(endCity.ToUpper());
  6319. }
  6320. var cityThree = string.Empty;
  6321. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  6322. cityThree = cityThree.TrimEnd(',');
  6323. if (string.IsNullOrWhiteSpace(cityThree))
  6324. {
  6325. throw new
  6326. Exception("error");
  6327. }
  6328. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  6329. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  6330. foreach (var item in cityArrCode)
  6331. {
  6332. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  6333. if (find != null)
  6334. {
  6335. city += find.City + "/";
  6336. }
  6337. else
  6338. {
  6339. city += item + "三字码未收入/";
  6340. }
  6341. }
  6342. city = city.TrimEnd('/');
  6343. }
  6344. catch (Exception e)
  6345. {
  6346. city = "黑屏代码格式不正确!";
  6347. }
  6348. }
  6349. }
  6350. else
  6351. {
  6352. city = "未录入黑屏代码";
  6353. }
  6354. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  6355. {
  6356. Date = x.Date,
  6357. Days = x.Days,
  6358. Diffgroup = x.Diffgroup,
  6359. Diid = x.Diid,
  6360. Traffic_First = x.Traffic_First,
  6361. Traffic_Second = x.Traffic_Second,
  6362. Trip = x.Trip,
  6363. WeekDay = x.WeekDay,
  6364. Id = x.Id
  6365. }).ToList();
  6366. jw.Data = new
  6367. {
  6368. groupList = groupList.Select(x => new
  6369. {
  6370. x.Id,
  6371. x.TeamName,
  6372. x.TourCode
  6373. }).ToList(),
  6374. groupInfo = new
  6375. {
  6376. group.VisitDays,
  6377. group.TourCode,
  6378. group.VisitPNumber,
  6379. group.TeamName,
  6380. city
  6381. },
  6382. OpTravelList
  6383. };
  6384. jw.Code = 200;
  6385. jw.Msg = "操作成功!";
  6386. return Ok(jw);
  6387. }
  6388. /// <summary>
  6389. /// 删除团组行程单
  6390. /// </summary>
  6391. /// <returns></returns>
  6392. [HttpPost]
  6393. public IActionResult DelTravel(DelOpTravelDto dto)
  6394. {
  6395. var jw = JsonView(false);
  6396. if (dto.UserId <= 0 || dto.Diid <= 0)
  6397. {
  6398. jw.Msg = "请输入正确的参数!";
  6399. return Ok(jw);
  6400. }
  6401. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  6402. .SetColumns(x => new Grp_TravelList
  6403. {
  6404. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6405. DeleteUserId = dto.UserId,
  6406. IsDel = 1,
  6407. }).ExecuteCommand();
  6408. jw = JsonView(true);
  6409. return Ok(jw);
  6410. }
  6411. /// <summary>
  6412. /// 行程单保存
  6413. /// </summary>
  6414. /// <returns></returns>
  6415. [HttpPost]
  6416. public IActionResult TravelSave(TravelSaveDto dto)
  6417. {
  6418. var jw = JsonView(false);
  6419. if (dto.Arr.Count > 0)
  6420. {
  6421. try
  6422. {
  6423. _sqlSugar.BeginTran();
  6424. foreach (var item in dto.Arr)
  6425. {
  6426. if (item.Id == 0)
  6427. {
  6428. throw new Exception("请传入正确的Id");
  6429. }
  6430. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6431. .SetColumns(x => new Grp_TravelList
  6432. {
  6433. Trip = item.Trip
  6434. }).ExecuteCommand();
  6435. }
  6436. _sqlSugar.CommitTran();
  6437. jw = JsonView(true);
  6438. }
  6439. catch (Exception ex)
  6440. {
  6441. _sqlSugar.RollbackTran();
  6442. jw.Msg = "程序异常!" + ex.Message;
  6443. }
  6444. }
  6445. else
  6446. {
  6447. jw.Msg = "请传入正确的参数!";
  6448. }
  6449. return Ok(jw);
  6450. }
  6451. /// <summary>
  6452. /// 导出行程单
  6453. /// </summary>
  6454. /// <param name="dto"></param>
  6455. /// <returns></returns>
  6456. [HttpPost]
  6457. public IActionResult ExportTravel(ExportTravelDto dto)
  6458. {
  6459. var jw = JsonView(false);
  6460. jw.Data = "";
  6461. int diid = 0;
  6462. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6463. if (Find == null)
  6464. {
  6465. jw.Msg = "请选择正确的团组!";
  6466. return Ok(jw);
  6467. }
  6468. else
  6469. {
  6470. diid = Find.Id;
  6471. }
  6472. //数据源
  6473. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6474. DataTable dtBlack = null;
  6475. try
  6476. {
  6477. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6478. }
  6479. catch (Exception)
  6480. {
  6481. jw.Msg = "机票黑屏代码有误!";
  6482. return Ok(jw);
  6483. }
  6484. string CityStr = string.Empty;
  6485. if (dtBlack.Rows.Count == 0)
  6486. {
  6487. jw.Msg = "机票黑屏代码有误!";
  6488. return Ok(jw);
  6489. }
  6490. else
  6491. {
  6492. foreach (DataRow row in dtBlack.Rows)
  6493. {
  6494. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6495. {
  6496. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6497. return Ok(jw);
  6498. }
  6499. }
  6500. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6501. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6502. }
  6503. //创建数据源Table
  6504. DataTable dtSource = new DataTable();
  6505. dtSource.Columns.Add("Days", typeof(string));
  6506. dtSource.Columns.Add("Date", typeof(string));
  6507. dtSource.Columns.Add("Week", typeof(string));
  6508. dtSource.Columns.Add("Traffic", typeof(string));
  6509. dtSource.Columns.Add("Trip", typeof(string));
  6510. //获取数据,放到datatable
  6511. foreach (var item in _travelList)
  6512. {
  6513. DataRow dr = dtSource.NewRow();
  6514. dr["Days"] = item.Days;
  6515. dr["Date"] = item.Date;
  6516. dr["Week"] = item.WeekDay;
  6517. dr["Traffic"] = item.Traffic_First
  6518. + "\r\n"
  6519. + item.Traffic_Second;
  6520. dr["Trip"] = item.Trip;
  6521. dtSource.Rows.Add(dr);
  6522. }
  6523. Dictionary<string, string> dic = new Dictionary<string, string>();
  6524. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6525. dic.Add("City", CityStr);
  6526. dic.Add("Days", Find.VisitDays.ToString());
  6527. dic.Add("DeleCode", Find.TourCode);
  6528. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6529. //模板路径
  6530. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6531. //载入模板
  6532. Document doc = null;
  6533. DocumentBuilder builder = null;
  6534. try
  6535. {
  6536. //载入模板
  6537. doc = new Document(tempPath);
  6538. builder = new DocumentBuilder(doc);
  6539. }
  6540. catch (Exception)
  6541. {
  6542. jw.Msg = "模板位置不存在!";
  6543. return Ok(jw);
  6544. }
  6545. foreach (var key in dic.Keys)
  6546. {
  6547. Bookmark bookmark = doc.Range.Bookmarks[key];
  6548. if (bookmark != null)
  6549. {
  6550. builder.MoveToBookmark(key);
  6551. builder.Write(dic[key]);
  6552. }
  6553. }
  6554. //获取word里所有表格
  6555. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6556. //获取所填表格的序数
  6557. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6558. try
  6559. {
  6560. //循环赋值
  6561. for (int i = 0; i < dtSource.Rows.Count; i++)
  6562. {
  6563. builder.MoveToCell(0, i + 1, 0, 0);
  6564. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6565. builder.MoveToCell(0, i + 1, 1, 0);
  6566. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6567. builder.MoveToCell(0, i + 1, 2, 0);
  6568. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6569. var trip = dtSource.Rows[i]["Trip"].ToString();
  6570. builder.MoveToCell(0, i + 1, 3, 0);
  6571. builder.Write(trip);
  6572. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6573. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6574. // 获取特定索引的段落
  6575. Paragraph paragraph = (Paragraph)paragraphs[0];
  6576. Run run = paragraph.Runs[0];
  6577. Aspose.Words.Font font = run.Font;
  6578. font.Name = "黑体";
  6579. //设置双休红色
  6580. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6581. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6582. paragraph = (Paragraph)paragraphs[1];
  6583. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6584. {
  6585. run = paragraph.Runs[0];
  6586. font = run.Font;
  6587. font.Color = Color.Red;
  6588. }
  6589. }
  6590. }
  6591. catch (Exception ex)
  6592. {
  6593. }
  6594. //删除多余行
  6595. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6596. {
  6597. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6598. }
  6599. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6600. if (!Directory.Exists(savePath))
  6601. {
  6602. try
  6603. {
  6604. Directory.CreateDirectory(savePath);
  6605. }
  6606. catch
  6607. {
  6608. }
  6609. }
  6610. string path = savePath + Find.TeamName + "出访日程";
  6611. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6612. try
  6613. {
  6614. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6615. string postfix = ".docx";
  6616. if (dto.IsPDF == 1)
  6617. {
  6618. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6619. postfix = ".pdf";
  6620. }
  6621. doc.Save(path + postfix, saveFormat);
  6622. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6623. }
  6624. catch (Exception)
  6625. {
  6626. jw = JsonView(false);
  6627. }
  6628. return Ok(jw);
  6629. }
  6630. /// <summary>
  6631. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6632. /// </summary>
  6633. /// <param name="num"></param>
  6634. /// <returns></returns>
  6635. string GetNum(string num)
  6636. {
  6637. string str = "";
  6638. switch (num)
  6639. {
  6640. case "1":
  6641. str = "一";
  6642. break;
  6643. case "2":
  6644. str = "二";
  6645. break;
  6646. case "3":
  6647. str = "三";
  6648. break;
  6649. case "4":
  6650. str = "四";
  6651. break;
  6652. case "5":
  6653. str = "五";
  6654. break;
  6655. case "6":
  6656. str = "六";
  6657. break;
  6658. case "7":
  6659. str = "七";
  6660. break;
  6661. case "8":
  6662. str = "八";
  6663. break;
  6664. case "9":
  6665. str = "九";
  6666. break;
  6667. case "10":
  6668. str = "十";
  6669. break;
  6670. case "11":
  6671. str = "十一";
  6672. break;
  6673. case "12":
  6674. str = "十二";
  6675. break;
  6676. case "一":
  6677. str = "1";
  6678. break;
  6679. case "二":
  6680. str = "2";
  6681. break;
  6682. case "三":
  6683. str = "3";
  6684. break;
  6685. case "四":
  6686. str = "4";
  6687. break;
  6688. case "五":
  6689. str = "5";
  6690. break;
  6691. case "六":
  6692. str = "6";
  6693. break;
  6694. case "七":
  6695. str = "7";
  6696. break;
  6697. case "八":
  6698. str = "8";
  6699. break;
  6700. case "九":
  6701. str = "9";
  6702. break;
  6703. case "十":
  6704. str = "10";
  6705. break;
  6706. case "十一":
  6707. str = "11";
  6708. break;
  6709. case "十二":
  6710. str = "12";
  6711. break;
  6712. }
  6713. return str;
  6714. }
  6715. #endregion
  6716. #endregion
  6717. #region 团组成本
  6718. /// <summary>
  6719. /// 团组成本数据初始化
  6720. /// </summary>
  6721. /// <param name="dto"></param>
  6722. /// <returns></returns>
  6723. [HttpPost]
  6724. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6725. {
  6726. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6727. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6728. WHEN COUNT(*) >= 0 THEN 'True'
  6729. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6730. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6731. ").ToList(); //团组列表
  6732. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6733. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6734. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6735. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6736. if (groupinfoValue != null)
  6737. {
  6738. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6739. var spArr = new string[1] { countryArr };
  6740. if (countryArr.Contains("|"))
  6741. {
  6742. spArr = countryArr.Split("|");
  6743. }
  6744. else if (countryArr.Contains("、"))
  6745. {
  6746. spArr = countryArr.Split("、");
  6747. }
  6748. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6749. {
  6750. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6751. if (dbQueryCountry != null)
  6752. {
  6753. visaCountryInfoArr.Add(dbQueryCountry);
  6754. }
  6755. }
  6756. }
  6757. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6758. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6759. var create = _GroupCostRepository.
  6760. CreateGroupCostByBlackCode(dto.Diid);
  6761. if (groupCost.Count == 0 && create.Code == 0)
  6762. {
  6763. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6764. }
  6765. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6766. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6767. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6768. groupCostMap = groupCostMap.Select(x =>
  6769. {
  6770. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6771. {
  6772. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6773. }
  6774. return x;
  6775. }).ToList();
  6776. //GroupCostParameter.Add(new
  6777. // Grp_GroupCostParameter());
  6778. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6779. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6780. return Ok(JsonView(new
  6781. {
  6782. groupList,
  6783. groupInfo,
  6784. groupChecks,
  6785. groupCost = groupCostMap,
  6786. hotelNumber,
  6787. GroupCostParameter = GroupCostParameterMap,
  6788. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6789. {
  6790. x.VisaCountry,
  6791. x.VisaPrice,
  6792. x.Id,
  6793. }).ToList(),
  6794. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6795. blackCodeIsTrue = create.Code == 0 ? true : false,
  6796. hotelIsTrue = hotelIsTrue,
  6797. }));
  6798. }
  6799. /// <summary>
  6800. /// 团组成本信息保存
  6801. /// </summary>
  6802. /// <param name="dto"></param>
  6803. /// <returns></returns>
  6804. [HttpPost]
  6805. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6806. {
  6807. if (dto.Diid <= 0 || dto.Userid <= 0)
  6808. {
  6809. return Ok(JsonView(false));
  6810. }
  6811. JsonView jw = null;
  6812. bool isTrue = false;
  6813. #region 复制团组成本
  6814. //if (dto.Diid == 2581)
  6815. //{
  6816. // dto.Diid = 2599;
  6817. // dto.CheckBoxs.ForEach(x =>
  6818. // {
  6819. // x.Diid = 2599;
  6820. // });
  6821. // dto.GroupCosts.ForEach(x =>
  6822. // {
  6823. // x.Diid = 2599;
  6824. // });
  6825. // dto.CostTypeHotelNumbers.ForEach(x =>
  6826. // {
  6827. // x.Diid = 2599;
  6828. // });
  6829. // dto.GroupCostParameters.ForEach(x =>
  6830. // {
  6831. // x.DiId = 2599;
  6832. // });
  6833. //}
  6834. #endregion
  6835. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6836. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6837. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6838. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6839. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6840. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6841. try
  6842. {
  6843. _sqlSugar.BeginTran();
  6844. isTrue = await _GroupCostRepository.
  6845. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6846. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6847. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6848. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6849. _sqlSugar.CommitTran();
  6850. jw = JsonView(true, "保存成功!", isTrue);
  6851. }
  6852. catch (Exception)
  6853. {
  6854. _sqlSugar.RollbackTran();
  6855. jw = JsonView(false);
  6856. }
  6857. return Ok(jw);
  6858. }
  6859. /// <summary>
  6860. /// 司兼导数据
  6861. /// </summary>
  6862. /// <param name="dto"></param>
  6863. /// <returns></returns>
  6864. [HttpPost]
  6865. public IActionResult GetCarGuides(CarGuidesDto dto)
  6866. {
  6867. JsonView jw = null;
  6868. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6869. jw = JsonView(true, "获取成功!", Data);
  6870. return Ok(jw);
  6871. }
  6872. /// <summary>
  6873. /// 导游数据
  6874. /// </summary>
  6875. /// <param name="dto"></param>
  6876. /// <returns></returns>
  6877. [HttpPost]
  6878. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6879. {
  6880. JsonView jw = null;
  6881. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6882. // 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
  6883. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6884. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6885. jw = JsonView(true, "获取成功!", Data);
  6886. return Ok(jw);
  6887. }
  6888. /// <summary>
  6889. /// 成本车数据
  6890. /// </summary>
  6891. /// <param name="dto"></param>
  6892. /// <returns></returns>
  6893. [HttpPost]
  6894. public IActionResult GetCarInfo(CarGuidesDto dto)
  6895. {
  6896. JsonView jw = null;
  6897. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6898. jw = JsonView(true, "获取成功!", Data);
  6899. return Ok(jw);
  6900. }
  6901. /// <summary>
  6902. /// 景点数据
  6903. /// </summary>
  6904. /// <param name="dto"></param>
  6905. /// <returns></returns>
  6906. [HttpPost]
  6907. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6908. {
  6909. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6910. return Ok(JsonView(true, "获取成功!", Data));
  6911. }
  6912. /// <summary>
  6913. /// 成本通知
  6914. /// </summary>
  6915. /// <param name="dto"></param>
  6916. /// <returns></returns>
  6917. [HttpPost]
  6918. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6919. {
  6920. if (dto.Diid < 0)
  6921. {
  6922. return Ok(JsonView(false));
  6923. }
  6924. JsonView jw = null;
  6925. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6926. if (GroupCostParameter != null)
  6927. {
  6928. int IsShare = 0;
  6929. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6930. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6931. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6932. string msg = string.Empty;
  6933. if (isTrue)
  6934. {
  6935. if (IsShare == 0)
  6936. {
  6937. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6938. }
  6939. else
  6940. {
  6941. #region 企微通知对应岗位用户
  6942. try
  6943. {
  6944. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6945. }
  6946. catch (Exception ex)
  6947. {
  6948. }
  6949. #endregion
  6950. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6951. }
  6952. jw = JsonView(isTrue, msg, new { IsShare });
  6953. }
  6954. else
  6955. {
  6956. msg = "修改失败!";
  6957. jw = JsonView(isTrue, msg);
  6958. }
  6959. }
  6960. else
  6961. {
  6962. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6963. }
  6964. return Ok(jw);
  6965. }
  6966. /// <summary>
  6967. /// 导出报价单
  6968. /// </summary>
  6969. /// <param name="dto"></param>
  6970. /// <returns></returns>
  6971. [HttpPost]
  6972. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6973. {
  6974. if (dto.Diid == 0)
  6975. {
  6976. return Ok(JsonView(false, "请传递团组id"));
  6977. }
  6978. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6979. if (deleInfo.Code != 0)
  6980. {
  6981. return Ok(JsonView(false, "团组信息查询失败!"));
  6982. }
  6983. var di = deleInfo.Data as DelegationInfoWebView;
  6984. if (di != null)
  6985. {
  6986. di.TeamName = di.TeamName.Replace("|","、");
  6987. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  6988. //文件名
  6989. string strFileName = di.TeamName + "-收款账单.doc";
  6990. //获取模板
  6991. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6992. //载入模板
  6993. Document doc = new Document(tmppath);
  6994. decimal TotalPrice = 0.00M;
  6995. string itemStr = string.Empty;
  6996. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6997. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6998. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6999. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7000. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7001. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7002. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7003. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7004. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7005. foreach (var cost in groupCostType)
  7006. {
  7007. var List = cost.ToList();
  7008. if (cost.Key == "A")
  7009. {
  7010. foreach (var ListItem in List)
  7011. {
  7012. if (ListItem.number > 0)
  7013. {
  7014. if (ListItem.code.Contains("TBR"))
  7015. {
  7016. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7017. }
  7018. else
  7019. {
  7020. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7021. }
  7022. TotalPrice += (ListItem.number * ListItem.price);
  7023. }
  7024. }
  7025. }
  7026. else
  7027. {
  7028. itemStr = itemStr.Insert(0, "A段\r\n");
  7029. itemStr += "B段\r\n";
  7030. foreach (var ListItem in List)
  7031. {
  7032. if (ListItem.number > 0)
  7033. {
  7034. if (ListItem.code.Contains("TBR"))
  7035. {
  7036. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7037. }
  7038. else
  7039. {
  7040. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7041. }
  7042. TotalPrice += (ListItem.number * ListItem.price);
  7043. }
  7044. }
  7045. }
  7046. }
  7047. #region 替换Word模板书签内容
  7048. Dictionary<string, string> marks = new Dictionary<string, string>();
  7049. marks.Add("To", di.ClientUnit);//付款方
  7050. marks.Add("ToTel", di.TellPhone);//付款方电话
  7051. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7052. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7053. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7054. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7055. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7056. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  7057. marks.Add("PayItemContent", itemStr);//详细信息
  7058. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7059. #endregion
  7060. ////注
  7061. //if (doc.Range.Bookmarks["Attention"] != null)
  7062. //{
  7063. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7064. // mark.Text = frList[0].Attention;
  7065. //}
  7066. foreach (var item in marks.Keys)
  7067. {
  7068. if (doc.Range.Bookmarks[item] != null)
  7069. {
  7070. Bookmark mark = doc.Range.Bookmarks[item];
  7071. mark.Text = marks[item];
  7072. }
  7073. }
  7074. byte[] bytes = null;
  7075. using (MemoryStream stream = new MemoryStream())
  7076. {
  7077. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7078. bytes = stream.ToArray();
  7079. }
  7080. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7081. return Ok(JsonView(true, "", new
  7082. {
  7083. Data = bytes,
  7084. strFileName,
  7085. }));
  7086. }
  7087. else
  7088. {
  7089. return Ok(JsonView(false, "团组信息不存在!"));
  7090. }
  7091. }
  7092. /// <summary>
  7093. /// 导出团组成本
  7094. /// </summary>
  7095. /// <param name="dto"></param>
  7096. /// <returns></returns>
  7097. [HttpPost]
  7098. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7099. {
  7100. var jw = JsonView(false);
  7101. if (dto.Diid == 0)
  7102. {
  7103. return Ok(JsonView(false, "请传递团组id"));
  7104. }
  7105. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7106. if (deleInfo.Code != 0)
  7107. {
  7108. return Ok(JsonView(false, "团组信息查询失败!"));
  7109. }
  7110. var di = deleInfo.Data as DelegationInfoWebView;
  7111. if (di == null)
  7112. {
  7113. return Ok(JsonView(false, "团组信息查询失败!"));
  7114. }
  7115. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7116. WorkbookDesigner designer = new WorkbookDesigner();
  7117. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7118. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7119. for (int i = 0; i < List_GC.Count; i++)
  7120. {
  7121. GroupCost_Excel gc = new GroupCost_Excel();
  7122. gc.Id = List_GC[i].Id;
  7123. gc.Diid = List_GC[i].Diid.ToString();
  7124. gc.DAY = List_GC[i].DAY;
  7125. string week = "";
  7126. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7127. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7128. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7129. gc.ITIN = List_GC[i].ITIN;
  7130. gc.CarType = List_GC[i].CarType;
  7131. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7132. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7133. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7134. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7135. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7136. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7137. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7138. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7139. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7140. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7141. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7142. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7143. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7144. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7145. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7146. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7147. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7148. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7149. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7150. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7151. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7152. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7153. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7154. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7155. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7156. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7157. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7158. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7159. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7160. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7161. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7162. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7163. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7164. List_GC1.Add(gc);
  7165. }
  7166. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7167. dt.TableName = "TB";
  7168. //报表标题等不用dt的值
  7169. designer.SetDataSource("TeamName", dto.title.TeamName);
  7170. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7171. designer.SetDataSource("Tax", dto.title.Tax);
  7172. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7173. designer.SetDataSource("Currency", dto.title.Currency);
  7174. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7175. designer.SetDataSource("Rate", dto.title.Rate);
  7176. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7177. var Aparams = hotels.Find(x => x.Type == "Default");
  7178. if (Aparams == null)
  7179. {
  7180. return Ok(jw);
  7181. }
  7182. //酒店数量
  7183. var txtSGRNumber = Aparams.SGR.ToString();
  7184. var txtTBRNumber = Aparams.TBR.ToString();
  7185. var txtJSESNumber = Aparams.JSES.ToString();
  7186. var txtSUITENumbe = Aparams.SUITE.ToString();
  7187. if (dto.costType == "B")
  7188. {
  7189. Aparams = hotels.Find(x => x.Type == "A");
  7190. var Bparams = hotels.Find(x => x.Type == "B");
  7191. if (Aparams == null || Bparams == null)
  7192. {
  7193. return Ok(jw);
  7194. }
  7195. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7196. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7197. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7198. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7199. }
  7200. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7201. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7202. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7203. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7204. var ws = designer.Workbook.Worksheets[0];
  7205. int Row = List_GC.Count;
  7206. int startIndex = 11;
  7207. int HideRows = 0;
  7208. List<int> hideRowsList = new List<int>();
  7209. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7210. #region A段left数据
  7211. var left = dto.leftInfo.Find(x => x.Type == "A");
  7212. if (left == null)
  7213. {
  7214. return Ok(jw);
  7215. }
  7216. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7217. if (leftBindData != null)
  7218. {
  7219. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7220. designer.SetDataSource("VisaRS", leftBindData.rs);
  7221. designer.SetDataSource("VisaXS", leftBindData.xs);
  7222. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7223. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7224. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7225. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7226. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7227. }
  7228. else
  7229. {
  7230. hideRowsList.Add(Row + startIndex + HideRows);
  7231. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7232. }
  7233. HideRows += 2;
  7234. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7235. if (leftBindData != null)
  7236. {
  7237. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7238. designer.SetDataSource("BXRS", leftBindData.rs);
  7239. designer.SetDataSource("BXXS", leftBindData.xs);
  7240. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7241. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7242. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7243. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7244. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7245. }
  7246. else
  7247. {
  7248. hideRowsList.Add(Row + startIndex + HideRows);
  7249. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7250. }
  7251. HideRows += 2;
  7252. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7253. if (leftBindData != null)
  7254. {
  7255. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7256. designer.SetDataSource("HSRS", leftBindData.rs);
  7257. designer.SetDataSource("HSXS", leftBindData.xs);
  7258. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7259. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7260. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7261. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7262. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7263. }
  7264. else
  7265. {
  7266. hideRowsList.Add(Row + startIndex + HideRows);
  7267. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7268. }
  7269. HideRows += 2;
  7270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7271. if (leftBindData != null)
  7272. {
  7273. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7274. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7275. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7276. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7277. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7278. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7279. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7280. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7281. }
  7282. else
  7283. {
  7284. hideRowsList.Add(Row + startIndex + HideRows);
  7285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7286. }
  7287. HideRows += 2;
  7288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7289. if (leftBindData != null)
  7290. {
  7291. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7292. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7293. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7294. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7295. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7296. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7297. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7298. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7299. }
  7300. else
  7301. {
  7302. hideRowsList.Add(Row + startIndex + HideRows);
  7303. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7304. }
  7305. HideRows += 2;
  7306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7307. if (leftBindData != null)
  7308. {
  7309. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  7310. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  7311. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  7312. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7313. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7314. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7315. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7316. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7317. }
  7318. else
  7319. {
  7320. hideRowsList.Add(Row + startIndex + HideRows);
  7321. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7322. }
  7323. HideRows += 2;
  7324. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7325. if (leftBindData != null)
  7326. {
  7327. ////TBR
  7328. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7329. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7330. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7331. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7332. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7333. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7334. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7335. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7336. }
  7337. else
  7338. {
  7339. hideRowsList.Add(Row + startIndex + HideRows);
  7340. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7341. }
  7342. HideRows += 2;
  7343. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7344. if (leftBindData != null)
  7345. {
  7346. ////SGR
  7347. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7348. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7349. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7350. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7351. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7352. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7353. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7354. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7355. }
  7356. else
  7357. {
  7358. hideRowsList.Add(Row + startIndex + HideRows);
  7359. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7360. }
  7361. HideRows += 2;
  7362. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7363. if (leftBindData != null)
  7364. {
  7365. ////JS/ES
  7366. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7367. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7368. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7369. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7370. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7371. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7372. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7373. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7374. }
  7375. else
  7376. {
  7377. hideRowsList.Add(Row + startIndex + HideRows);
  7378. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7379. }
  7380. HideRows += 2;
  7381. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7382. if (leftBindData != null)
  7383. {
  7384. ////SUITE
  7385. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7386. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7387. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7388. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7389. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7390. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7391. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7392. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7393. }
  7394. else
  7395. {
  7396. hideRowsList.Add(Row + startIndex + HideRows);
  7397. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7398. }
  7399. HideRows += 2;
  7400. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7401. if (leftBindData != null)
  7402. {
  7403. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7404. designer.SetDataSource("DJRS", leftBindData.rs);
  7405. designer.SetDataSource("DJXS", leftBindData.xs);
  7406. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7407. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7408. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7409. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7410. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7411. }
  7412. else
  7413. {
  7414. hideRowsList.Add(Row + startIndex + HideRows);
  7415. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7416. }
  7417. HideRows += 2;
  7418. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7419. if (leftBindData != null)
  7420. {
  7421. designer.SetDataSource("HCPCB", leftBindData.cb);
  7422. designer.SetDataSource("HCPRS", leftBindData.rs);
  7423. designer.SetDataSource("HCPXS", leftBindData.xs);
  7424. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7425. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7426. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7427. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7428. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7429. }
  7430. else
  7431. {
  7432. hideRowsList.Add(Row + startIndex + HideRows);
  7433. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7434. }
  7435. HideRows += 2;
  7436. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7437. if (leftBindData != null)
  7438. {
  7439. designer.SetDataSource("CPCB", leftBindData.cb);
  7440. designer.SetDataSource("CPRS", leftBindData.rs);
  7441. designer.SetDataSource("CPXS", leftBindData.xs);
  7442. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7443. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7444. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7445. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7446. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7447. }
  7448. else
  7449. {
  7450. hideRowsList.Add(Row + startIndex + HideRows);
  7451. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7452. }
  7453. HideRows += 2;
  7454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7455. if (leftBindData != null)
  7456. {
  7457. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7458. designer.SetDataSource("GWRS", leftBindData.rs);
  7459. designer.SetDataSource("GWXS", leftBindData.xs);
  7460. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7461. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7462. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7463. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7464. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7465. }
  7466. else
  7467. {
  7468. hideRowsList.Add(Row + startIndex + HideRows);
  7469. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7470. }
  7471. HideRows += 2;
  7472. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7473. if (leftBindData != null)
  7474. {
  7475. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7476. designer.SetDataSource("LYJRS", leftBindData.rs);
  7477. designer.SetDataSource("LYJXS", leftBindData.xs);
  7478. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7479. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7480. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7481. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7482. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7483. }
  7484. else
  7485. {
  7486. hideRowsList.Add(Row + startIndex + HideRows);
  7487. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7488. }
  7489. #endregion
  7490. #region A段Right信息
  7491. var right = dto.rightInfo.Find(x => x.Type == "A");
  7492. if (right == null)
  7493. {
  7494. return Ok(jw);
  7495. }
  7496. HideRows += 4;
  7497. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7498. if (rightBindData != null)
  7499. {
  7500. //经济舱 + 双人间 TBR
  7501. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7502. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7503. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7504. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7505. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7506. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7507. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7508. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7509. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7510. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7511. }
  7512. else
  7513. {
  7514. hideRowsList.Add(Row + startIndex + HideRows);
  7515. }
  7516. HideRows += 2;
  7517. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7518. if (rightBindData != null)
  7519. {
  7520. //经济舱 + 单人间 SGR
  7521. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7522. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7523. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7524. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7525. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7526. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7527. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7528. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7529. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7530. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7531. }
  7532. else
  7533. {
  7534. hideRowsList.Add(Row + startIndex + HideRows);
  7535. }
  7536. HideRows += 2;
  7537. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7538. if (rightBindData != null)
  7539. {
  7540. //公务舱 + 单人间 SGR
  7541. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7542. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7543. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7544. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7545. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7546. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7547. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7548. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7549. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7550. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7551. }
  7552. else
  7553. {
  7554. hideRowsList.Add(Row + startIndex + HideRows);
  7555. }
  7556. HideRows += 2;
  7557. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7558. if (rightBindData != null)
  7559. {
  7560. //公务舱 + 小套房 JSES
  7561. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7562. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7563. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7564. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7565. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7566. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7567. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7568. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7569. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7570. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7571. }
  7572. else
  7573. {
  7574. hideRowsList.Add(Row + startIndex + HideRows);
  7575. }
  7576. HideRows += 2;
  7577. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7578. if (rightBindData != null)
  7579. {
  7580. //公务舱 + 小套房 JSES
  7581. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7582. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7583. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7584. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7585. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7586. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7587. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7588. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7589. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7590. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7591. }
  7592. else
  7593. {
  7594. hideRowsList.Add(Row + startIndex + HideRows);
  7595. }
  7596. HideRows += 2;
  7597. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7598. if (rightBindData != null)
  7599. {
  7600. //经济舱 + 大套房
  7601. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7602. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7603. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7604. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7605. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7606. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7607. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7608. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7609. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7610. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7611. }
  7612. else
  7613. {
  7614. hideRowsList.Add(Row + startIndex + HideRows);
  7615. }
  7616. HideRows += 2;
  7617. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7618. if (rightBindData != null)
  7619. {
  7620. //头等舱 + 小套房 JSES
  7621. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  7622. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  7623. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7624. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  7625. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7626. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7627. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7628. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7629. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7630. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7631. }
  7632. else
  7633. {
  7634. hideRowsList.Add(Row + startIndex + HideRows);
  7635. }
  7636. HideRows += 2;
  7637. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7638. if (rightBindData != null)
  7639. {
  7640. //头等舱 + 大套房
  7641. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  7642. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  7643. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7644. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  7645. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7646. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7647. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7648. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7649. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7650. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7651. }
  7652. else
  7653. {
  7654. hideRowsList.Add(Row + startIndex + HideRows);
  7655. }
  7656. #endregion
  7657. #region B段标题清空
  7658. designer.SetDataSource("CostBDRCB", "");
  7659. designer.SetDataSource("CostBRS", "");
  7660. designer.SetDataSource("CostBXS", "");
  7661. designer.SetDataSource("CostBZCB", "");
  7662. designer.SetDataSource("CostBDRBJ", "");
  7663. designer.SetDataSource("CostBZBJ", "");
  7664. designer.SetDataSource("CostBDRLR", "");
  7665. designer.SetDataSource("CostBZLR", "");
  7666. designer.SetDataSource("CostBDRCBOM", "");
  7667. designer.SetDataSource("CostBRSOM", "");
  7668. designer.SetDataSource("CostBZCBOM", "");
  7669. designer.SetDataSource("CostBDRBJOM", "");
  7670. designer.SetDataSource("CostBZBJOM", "");
  7671. designer.SetDataSource("CostBDRLROM", "");
  7672. designer.SetDataSource("CostBZLROM", "");
  7673. #endregion
  7674. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7675. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7676. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7677. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7678. designer.SetDataSource("DJName", "地接(CNY)");
  7679. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7680. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7681. designer.SetDataSource("GWName", "公务(CNY)");
  7682. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7683. designer.SetDataSource("LYJName", "零用金(CNY)");
  7684. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7685. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7686. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7687. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  7688. designer.SetDataSource("BXName", "保险(CNY)");
  7689. designer.SetDataSource("VisaName", "签证(CNY)");
  7690. #region B段基本数据
  7691. if (dto.costType == "B")
  7692. {
  7693. left = dto.leftInfo.Find(x => x.Type == "B");
  7694. if (left == null)
  7695. {
  7696. return Ok(jw);
  7697. }
  7698. #region B段left数据
  7699. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7700. if (leftBindData != null)
  7701. {
  7702. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7703. designer.SetDataSource("BHSRS", leftBindData.rs);
  7704. designer.SetDataSource("BHSXS", leftBindData.xs);
  7705. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7706. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7707. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7708. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7709. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7710. }
  7711. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7712. if (leftBindData != null)
  7713. {
  7714. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7715. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7716. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7717. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7718. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7719. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7720. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7721. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7722. }
  7723. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7724. if (leftBindData != null)
  7725. {
  7726. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7727. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7728. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7729. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7730. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7731. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7732. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7733. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7734. }
  7735. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  7736. if (leftBindData != null)
  7737. {
  7738. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  7739. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  7740. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  7741. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7742. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7743. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7744. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7745. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7746. }
  7747. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7748. if (leftBindData != null)
  7749. {
  7750. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7751. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7752. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7753. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7754. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7755. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7756. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7757. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7758. }
  7759. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7760. if (leftBindData != null)
  7761. {
  7762. designer.SetDataSource("BCPCB", leftBindData.cb);
  7763. designer.SetDataSource("BCPRS", leftBindData.rs);
  7764. designer.SetDataSource("BCPXS", leftBindData.xs);
  7765. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7766. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7767. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7768. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7769. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7770. }
  7771. //TBR
  7772. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7773. if (leftBindData != null)
  7774. {
  7775. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7776. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7777. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7778. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7779. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7780. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7781. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7782. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7783. }
  7784. //SGR
  7785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7786. if (leftBindData != null)
  7787. {
  7788. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7789. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7790. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7791. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7792. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7793. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7794. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7795. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7796. }
  7797. //JS/ES
  7798. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7799. if (leftBindData != null)
  7800. {
  7801. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7802. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7803. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7804. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7805. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7806. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7807. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7808. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7809. }
  7810. //SUITE
  7811. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7812. if (leftBindData != null)
  7813. {
  7814. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7815. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7816. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7817. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7818. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7819. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7820. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7821. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7822. }
  7823. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7824. if (leftBindData != null)
  7825. {
  7826. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7827. designer.SetDataSource("BDJRS", leftBindData.rs);
  7828. designer.SetDataSource("BDJXS", leftBindData.xs);
  7829. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7830. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7831. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7832. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7833. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7834. }
  7835. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7836. if (leftBindData != null)
  7837. {
  7838. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7839. designer.SetDataSource("BGWRS", leftBindData.rs);
  7840. designer.SetDataSource("BGWXS", leftBindData.xs);
  7841. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7842. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7843. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7844. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7845. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7846. }
  7847. #region 优化方案
  7848. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7849. //excelBind.Add("零用金", new {
  7850. //cb="",
  7851. //rs="",
  7852. //xs ="",
  7853. //zcb = "",
  7854. //});
  7855. #endregion
  7856. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7857. if (leftBindData != null)
  7858. {
  7859. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7860. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7861. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7862. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7863. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7864. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7865. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7866. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7867. }
  7868. #endregion
  7869. #region B段Right信息
  7870. right = dto.rightInfo.Find(x => x.Type == "B");
  7871. if (right == null)
  7872. {
  7873. return Ok(jw);
  7874. }
  7875. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7876. if (rightBindData != null)
  7877. {
  7878. //经济舱 + 双人间 TBR
  7879. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7880. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7881. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7882. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7883. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7884. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7885. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7886. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7887. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7888. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7889. }
  7890. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7891. if (rightBindData != null)
  7892. {
  7893. //经济舱 + 单人间 SGR
  7894. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7895. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7896. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7897. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7898. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7899. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7900. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7901. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7902. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7903. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7904. }
  7905. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7906. if (rightBindData != null)
  7907. {
  7908. //公务舱 + 单人间 SGR
  7909. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7910. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7911. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7912. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7913. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7914. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7915. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7916. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7917. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7918. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7919. }
  7920. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7921. if (rightBindData != null)
  7922. {
  7923. //公务舱 + 小套房 JSES
  7924. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7925. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7926. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7927. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7928. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7929. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7930. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7931. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7932. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7933. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7934. }
  7935. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7936. if (rightBindData != null)
  7937. {
  7938. //公务舱 + 小套房 JSES
  7939. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7940. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7941. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7942. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7943. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7944. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7945. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7946. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7947. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7948. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7949. }
  7950. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7951. if (rightBindData != null)
  7952. {
  7953. //经济舱 + 大套房
  7954. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7955. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7956. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7957. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7958. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7959. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7960. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7961. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7962. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7963. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7964. }
  7965. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  7966. if (rightBindData != null)
  7967. {
  7968. //头等舱 + 小套房 JSES
  7969. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  7970. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  7971. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7972. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  7973. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7974. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7975. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7976. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7977. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7978. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7979. }
  7980. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  7981. if (rightBindData != null)
  7982. {
  7983. //头等舱 + 大套房
  7984. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  7985. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  7986. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7987. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  7988. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7989. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7990. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7991. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7992. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7993. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7994. }
  7995. #endregion
  7996. #region 标题
  7997. designer.SetDataSource("CostBDRCB", "单人成本");
  7998. designer.SetDataSource("CostBRS", "人数");
  7999. designer.SetDataSource("CostBXS", "系数");
  8000. designer.SetDataSource("CostBZCB", "总成本");
  8001. designer.SetDataSource("CostBDRBJ", "单人报价");
  8002. designer.SetDataSource("CostBZBJ", "总报价");
  8003. designer.SetDataSource("CostBDRLR", "单人利润");
  8004. designer.SetDataSource("CostBZLR", "总利润");
  8005. designer.SetDataSource("CostBDRCBOM", "单人成本");
  8006. designer.SetDataSource("CostBRSOM", "人数");
  8007. designer.SetDataSource("CostBZCBOM", "总成本");
  8008. designer.SetDataSource("CostBDRBJOM", "单人报价");
  8009. designer.SetDataSource("CostBZBJOM", "总报价");
  8010. designer.SetDataSource("CostBDRLROM", "单人利润");
  8011. designer.SetDataSource("CostBZLROM", "总利润");
  8012. #endregion
  8013. }
  8014. #endregion
  8015. designer.SetDataSource("TzZCB2", TzZCB2);
  8016. designer.SetDataSource("TzZBJ2", TzZBJ2);
  8017. designer.SetDataSource("TzZLR2", TzZLR2);
  8018. string[] dataSourceKeys = new string[]
  8019. {
  8020. "VF",
  8021. "TGS",
  8022. "TGOF",
  8023. "TGM",
  8024. "TGA",
  8025. "TGTF",
  8026. "TGEF",
  8027. "CFM",
  8028. "CFOF",
  8029. "B",
  8030. "L",
  8031. "D",
  8032. "TBR",
  8033. "SGR",
  8034. "JSES",
  8035. "Suite",
  8036. "TV",
  8037. "1L",
  8038. "IF",
  8039. "EF",
  8040. "BRF",
  8041. "TE",
  8042. "TGT",
  8043. "DRVT",
  8044. "PC",
  8045. "TLF",
  8046. "ECT"
  8047. };
  8048. foreach (var item in dataSourceKeys)
  8049. {
  8050. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  8051. if (find != null)
  8052. {
  8053. designer.SetDataSource(item, find.text);
  8054. }
  8055. else
  8056. {
  8057. designer.SetDataSource(item, 0);
  8058. }
  8059. }
  8060. designer.SetDataSource(dt);
  8061. //根据数据源处理生成报表内容
  8062. designer.Process();
  8063. designer.Workbook.Worksheets[0].Name = "清单";
  8064. Worksheet sheet = designer.Workbook.Worksheets[0];
  8065. foreach (var Rowindex in hideRowsList)
  8066. {
  8067. ws.Cells.HideRows(Rowindex, 2);
  8068. }
  8069. byte[] bytes = null;
  8070. string strFileName = di.TeamName + "-团组-成本.xls";
  8071. using (MemoryStream stream = new MemoryStream())
  8072. {
  8073. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  8074. bytes = stream.ToArray();
  8075. }
  8076. return Ok(JsonView(true, "", new
  8077. {
  8078. Data = bytes,
  8079. strFileName,
  8080. }));
  8081. }
  8082. /// <summary>
  8083. /// 导出客户报表
  8084. /// </summary>
  8085. /// <returns></returns>
  8086. [HttpPost]
  8087. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  8088. {
  8089. var jw = JsonView(false);
  8090. if (dto.Diid == 0)
  8091. {
  8092. return Ok(JsonView(false, "请传递团组id"));
  8093. }
  8094. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  8095. if (deleInfo.Code != 0)
  8096. {
  8097. return Ok(JsonView(false, "团组信息查询失败!"));
  8098. }
  8099. var di = deleInfo.Data as DelegationInfoWebView;
  8100. if (di == null)
  8101. {
  8102. return Ok(JsonView(false, "团组信息查询失败!"));
  8103. }
  8104. //文件名
  8105. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8106. //获取模板
  8107. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8108. //载入模板
  8109. Document doc = new Document(tmppath);
  8110. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8111. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8112. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8113. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8114. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8115. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8116. if (AParameter == null)
  8117. {
  8118. return Ok(JsonView(false, "系数不存在!"));
  8119. }
  8120. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8121. , TzAirDesc, TzZCost;
  8122. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8123. = TzAirDesc = TzZCost = string.Empty;
  8124. TzNumber = AParameter.CostTypenumber.ToString();
  8125. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8126. CarGuides1 = dto.CarGuides1;
  8127. Meal = dto.Meal;
  8128. SubsidizedMeals = dto.SubsidizedMeals;
  8129. NightRepair = dto.NightRepair;
  8130. AttractionsTickets = dto.AttractionsTickets;
  8131. MiscellaneousFees = dto.MiscellaneousFees;
  8132. ATip = dto.ATip;
  8133. TzHotelDesc = "";
  8134. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8135. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8136. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8137. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8138. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8139. TzAirDesc = "";
  8140. TzZCost = dto.TzZCost;
  8141. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8142. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8143. var index = 1;
  8144. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8145. foreach (var item in TzHotelDescArr)
  8146. {
  8147. if (AinfoArr != null)
  8148. {
  8149. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8150. if (Ainfo != null)
  8151. {
  8152. if (int.Parse(Ainfo.rs) <= 0)
  8153. {
  8154. continue;
  8155. }
  8156. var hotelText = string.Empty;
  8157. switch (item)
  8158. {
  8159. case "SGR":
  8160. hotelText = "单人间";
  8161. break;
  8162. case "JSES":
  8163. hotelText = "小套房";
  8164. break;
  8165. case "SUITE":
  8166. hotelText = "套房";
  8167. break;
  8168. case "TBR":
  8169. hotelText = "双人间";
  8170. break;
  8171. }
  8172. if (item != "TBR")
  8173. {
  8174. 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";
  8175. }
  8176. else
  8177. {
  8178. 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";
  8179. }
  8180. index++;
  8181. }
  8182. }
  8183. }
  8184. index = 1;
  8185. foreach (var item in TzAirDescArr)
  8186. {
  8187. if (AinfoArr != null)
  8188. {
  8189. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8190. if (Ainfo != null)
  8191. {
  8192. if (int.Parse(Ainfo.rs) <= 0)
  8193. {
  8194. continue;
  8195. }
  8196. 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";
  8197. index++;
  8198. }
  8199. }
  8200. }
  8201. if (dto.costType == "B")
  8202. {
  8203. if (BParameter == null)
  8204. {
  8205. return Ok(JsonView(false, "B段系数不存在!"));
  8206. }
  8207. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8208. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8209. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8210. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8211. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8212. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8213. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8214. foreach (var item in TzHotelDescArr)
  8215. {
  8216. if (AinfoArr != null)
  8217. {
  8218. TzHotelDesc += "B段信息 \r\n";
  8219. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8220. if (Ainfo != null)
  8221. {
  8222. if (int.Parse(Ainfo.rs) <= 0)
  8223. {
  8224. continue;
  8225. }
  8226. var hotelText = string.Empty;
  8227. switch (item)
  8228. {
  8229. case "SGR":
  8230. hotelText = "单人间";
  8231. break;
  8232. case "JSES":
  8233. hotelText = "小套房";
  8234. break;
  8235. case "SUITE":
  8236. hotelText = "套房";
  8237. break;
  8238. case "TBR":
  8239. hotelText = "双人间";
  8240. break;
  8241. }
  8242. if (item != "TBR")
  8243. {
  8244. TzHotelDesc += "(" + index + ".) " + hotelText + " " + Ainfo.rs + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8245. }
  8246. else
  8247. {
  8248. TzHotelDesc += "(" + index + ".) " + hotelText + " " + (int.Parse(Ainfo.rs) / 2) + "间 共" + Ainfo.rs + " " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs)).ToString("#0.00") + "/人........共RMB " + (decimal.Parse(Ainfo.cb) * decimal.Parse(Ainfo.xs) * decimal.Parse(Ainfo.rs)).ToString("#0.00") + "\n";
  8249. }
  8250. index++;
  8251. }
  8252. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8253. }
  8254. }
  8255. index = 1;
  8256. foreach (var item in TzAirDescArr)
  8257. {
  8258. if (AinfoArr != null)
  8259. {
  8260. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8261. if (Ainfo != null)
  8262. {
  8263. if (int.Parse(Ainfo.rs) <= 0)
  8264. {
  8265. continue;
  8266. }
  8267. 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";
  8268. index++;
  8269. }
  8270. }
  8271. }
  8272. }
  8273. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8274. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8275. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8276. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8277. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8278. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8279. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8280. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8281. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8282. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8283. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8284. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8285. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8286. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8287. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8288. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8289. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8290. DickeyValue.Add("TzZCost", TzZCost);
  8291. foreach (var key in DickeyValue.Keys)
  8292. {
  8293. if (doc.Range.Bookmarks[key] != null)
  8294. {
  8295. Bookmark mark = doc.Range.Bookmarks[key];
  8296. mark.Text = DickeyValue[key];
  8297. }
  8298. }
  8299. byte[] bytes = null;
  8300. string strFileName = di.TeamName + "-客户报价.doc";
  8301. using (MemoryStream stream = new MemoryStream())
  8302. {
  8303. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8304. bytes = stream.ToArray();
  8305. }
  8306. return Ok(JsonView(true, "", new
  8307. {
  8308. Data = bytes,
  8309. strFileName,
  8310. }));
  8311. }
  8312. /// <summary>
  8313. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8314. /// </summary>
  8315. /// <param name="dto"></param>
  8316. /// <returns></returns>
  8317. [HttpPost]
  8318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8319. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8320. {
  8321. try
  8322. {
  8323. #region 参数验证
  8324. if (dto.DiId < 0)
  8325. {
  8326. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8327. }
  8328. List<int> cTableIds = new List<int>() {
  8329. 76 ,//酒店预订
  8330. 77 ,//行程
  8331. 79 ,//车/导游地接
  8332. 80 ,//签证
  8333. 81 ,//邀请/公务活
  8334. 82 ,//团组客户保险
  8335. 85 ,//机票预订
  8336. 98 ,//其他款项
  8337. 285 ,//收款退还
  8338. 751 ,//酒店早餐
  8339. 1015 // 超支费用
  8340. };
  8341. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8342. {
  8343. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8344. }
  8345. #endregion
  8346. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8347. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8348. if (_GroupCostParameters.Count <= 0)
  8349. {
  8350. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8351. }
  8352. if (_GroupCostParameters[0].IsShare == 0)
  8353. {
  8354. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8355. }
  8356. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8357. //处理date为空问题
  8358. if (_GroupCosts.Count > 0)
  8359. {
  8360. for (int i = 0; i < _GroupCosts.Count; i++)
  8361. {
  8362. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8363. {
  8364. if (i > 0)
  8365. {
  8366. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8367. }
  8368. }
  8369. }
  8370. }
  8371. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8372. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8373. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8374. string currCode = "";
  8375. #region currCode 验证
  8376. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8377. if (isInt)
  8378. {
  8379. var currData = currDatas.Find(it => it.Id == intCurrency);
  8380. if (currData != null)
  8381. {
  8382. currCode = currData.Name;
  8383. }
  8384. }
  8385. else
  8386. {
  8387. currCode = _GroupCostParameters[0].Currency.Trim();
  8388. }
  8389. #endregion
  8390. //op,酒店单段模式存储
  8391. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8392. {
  8393. CurrencyCode = currCode,
  8394. Rate = _GroupCostParameters[0].Rate,
  8395. CostType = _GroupCostParameters[0].CostType,
  8396. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8397. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8398. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8399. };
  8400. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8401. if (_GroupCostParameters.Count == 2)
  8402. {
  8403. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8404. }
  8405. foreach (var item in _GroupCostParameters)
  8406. {
  8407. decimal _rate = 1;
  8408. decimal _rate1 = item.Rate;
  8409. decimal _scale = 1;
  8410. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8411. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8412. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8413. //if (userInfo != null)
  8414. //{
  8415. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8416. // {
  8417. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8418. // {
  8419. // _scale = 1.00M;
  8420. // }
  8421. // }
  8422. //}
  8423. #endregion
  8424. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8425. {
  8426. CurrencyCode = currCode,
  8427. Rate = _rate1,
  8428. CostType = item.CostType,
  8429. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8430. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8431. CostTypeNumber = item.CostTypenumber
  8432. };
  8433. if (_GroupCostParameters.Count > 1)
  8434. {
  8435. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8436. }
  8437. else
  8438. {
  8439. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8440. }
  8441. if (dto.CTable == 79)//
  8442. {
  8443. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8444. modulePromptInfo.TotalCost = item.DJCB;
  8445. }
  8446. List<string> costTypes = new List<string>() { "A", "B" };
  8447. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8448. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8449. if (_GroupCostsDuplicates.Count() == 1)
  8450. {
  8451. _GroupCostsTypeData = _GroupCosts;
  8452. }
  8453. else
  8454. {
  8455. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8456. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8457. }
  8458. /*
  8459. * 76 酒店预订
  8460. * 77 行程
  8461. * 79 车/导游地接
  8462. * 80 签证
  8463. * 81 邀请/公务活动
  8464. * 82 团组客户保险
  8465. * 85 机票预订
  8466. * 98 其他款项
  8467. * 285 收款退还
  8468. * 751 酒店早餐
  8469. * 1015 超支费用
  8470. */
  8471. switch (dto.CTable)
  8472. {
  8473. case 76: // 酒店预订
  8474. _ModuleSubPromptInfo.AddRange(
  8475. _GroupCostsTypeData.Select(it => new
  8476. {
  8477. it.DAY,
  8478. it.Date,
  8479. it.ACCON,
  8480. it.ITIN,
  8481. it.SGR,
  8482. it.TBR,
  8483. it.JS_ES,
  8484. it.Suite
  8485. })
  8486. );
  8487. break;
  8488. case 79: // 车/导游地接
  8489. _ModuleSubPromptInfo.AddRange(
  8490. _GroupCostsTypeData.Select(it => new
  8491. {
  8492. Date = it.Date, //日期
  8493. CarFee = it.CarCost * _rate * _scale, //车费用
  8494. CarType = it.CarType, //车型
  8495. DriverFee = it.CFS * _rate * _scale, //司机工资
  8496. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  8497. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  8498. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  8499. GuideFee = it.TGS * _rate * _scale, //导游费用
  8500. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  8501. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  8502. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  8503. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  8504. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  8505. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  8506. Breakfast = it.B * _rate * _scale, //早餐费
  8507. Lunch = it.L * _rate * _scale, //午餐费
  8508. Dinner = it.D * _rate * _scale, //晚餐费
  8509. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  8510. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  8511. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  8512. TicketFee = it.EF * _rate * _scale, //门票费
  8513. TicketRemark = it.EFR, //门票费描述
  8514. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8515. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8516. SpentCash = it.PC * _rate * _scale, //零用金
  8517. LeadersFee = it.TLF * _rate * _scale, //领队费
  8518. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  8519. })
  8520. );
  8521. break;
  8522. case 85: // 机票
  8523. List<dynamic> datas = new List<dynamic>();
  8524. datas.Add(
  8525. new
  8526. {
  8527. AirType = "经济舱",
  8528. AirNum = item.JJCRS,
  8529. AirDRCB = item.JJCCB,
  8530. AirZCB = (item.JJCRS * item.JJCCB)
  8531. }
  8532. );
  8533. datas.Add(
  8534. new
  8535. {
  8536. AirType = "公务舱",
  8537. AirNum = item.GWCRS,
  8538. AirDRCB = item.GWCCB,
  8539. AirZCB = (item.GWCRS * item.GWCCB)
  8540. }
  8541. );
  8542. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8543. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8544. modulePromptInfo.Data = new
  8545. {
  8546. airFeeData = datas,
  8547. airInitData = initDatas
  8548. };
  8549. _ModulePromptInfos.Add(modulePromptInfo);
  8550. break;
  8551. default:
  8552. break;
  8553. }
  8554. }
  8555. if (dto.CTable != 85)
  8556. {
  8557. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8558. _ModulePromptInfos.Add(_ModulePromptInfo);
  8559. }
  8560. _view.ModulePromptInfos = _ModulePromptInfos;
  8561. return Ok(JsonView(true, "操作成功!", _view));
  8562. }
  8563. catch (Exception ex)
  8564. {
  8565. return Ok(JsonView(false, ex.Message));
  8566. }
  8567. }
  8568. /// <summary>
  8569. /// 根据黑屏代码重新生成行程
  8570. /// </summary>
  8571. /// <param name="dto"></param>
  8572. /// <returns></returns>
  8573. [HttpPost]
  8574. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8575. {
  8576. var jw = JsonView(false);
  8577. var Create = _GroupCostRepository.
  8578. CreateGroupCostByBlackCode(dto.Diid);
  8579. jw.Msg = Create.Msg;
  8580. if (Create.Code == 0)
  8581. {
  8582. jw.Code = 200;
  8583. jw.Data = new
  8584. {
  8585. groupCost = Create.Data,
  8586. blackCodeIsTrue = true
  8587. };
  8588. }
  8589. else
  8590. {
  8591. jw.Code = 400;
  8592. jw.Data = new
  8593. {
  8594. groupCost = Create.Data,
  8595. blackCodeIsTrue = false,
  8596. };
  8597. }
  8598. return Ok(jw);
  8599. }
  8600. /// <summary>
  8601. /// 成本获取OP历史车费用
  8602. /// </summary>
  8603. /// <param name="dto"></param>
  8604. /// <returns></returns>
  8605. [HttpPost]
  8606. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8607. {
  8608. var jw = JsonView(false);
  8609. try
  8610. {
  8611. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8612. //获取现有所有车的数据
  8613. if (!dto.Param.IsNullOrWhiteSpace())
  8614. {
  8615. string sql = $@"
  8616. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8617. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8618. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8619. WHERE gctggr.IsDel = 0 and gctggrc.SId = 91 AND gdi.IsDel = 0 AND gctggrc.Price != 0 AND (ssd.Id in (1061,1069) or ssd.Id is NULL) AND gctggr.ServiceStartTime is not null
  8620. AND gctggr.ServiceEndTime is not NULL
  8621. ORDER by gctggrc.id DESC
  8622. ";
  8623. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8624. var numeberResult = await Task.Run(() =>
  8625. {
  8626. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8627. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8628. return numberArr;
  8629. });
  8630. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8631. foreach (var item in numeberResult)
  8632. {
  8633. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8634. {
  8635. Country = "数据异常!",
  8636. City = string.Empty,
  8637. };
  8638. item.Area = find.Country + " " + find.City;
  8639. }
  8640. dbResult.AddRange(numeberResult);
  8641. if (dto.Param.Contains("、"))
  8642. {
  8643. var sp = dto.Param.Split("、");
  8644. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8645. .Where(x =>
  8646. {
  8647. return System.Array.Exists(sp, e =>
  8648. {
  8649. bool where = false;
  8650. if (x.Area != null)
  8651. {
  8652. where = x.Area.Contains(e);
  8653. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8654. {
  8655. return false;
  8656. }
  8657. }
  8658. if (x.PriceName != null && !where)
  8659. {
  8660. where = x.PriceName.Contains(e);
  8661. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8662. {
  8663. return false;
  8664. }
  8665. }
  8666. return where;
  8667. });
  8668. }).ToList();
  8669. }
  8670. else
  8671. {
  8672. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8673. .Where(x =>
  8674. {
  8675. bool where = false;
  8676. if (x.Area != null)
  8677. {
  8678. where = x.Area.Contains(dto.Param);
  8679. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8680. {
  8681. return false;
  8682. }
  8683. }
  8684. if (x.PriceName != null && !where)
  8685. {
  8686. where = x.PriceName.Contains(dto.Param);
  8687. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8688. {
  8689. return false;
  8690. }
  8691. }
  8692. return where;
  8693. }
  8694. )
  8695. .ToList();
  8696. }
  8697. }
  8698. var view = dbResult.Select(x =>
  8699. {
  8700. decimal dp = 0.00M;
  8701. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8702. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8703. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8704. {
  8705. if (startB && endB)
  8706. {
  8707. var timesp = endD.Subtract(startD);
  8708. if ((timesp.Days + 1) != 0)
  8709. {
  8710. dp = x.Price / (timesp.Days + 1);
  8711. }
  8712. }
  8713. }
  8714. else
  8715. {
  8716. dp = x.Price;
  8717. }
  8718. return new
  8719. {
  8720. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8721. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8722. x.Area,
  8723. x.id,
  8724. price = x.Price.ToString("F2"),
  8725. x.PriceName,
  8726. x.PriceContent,
  8727. x.TeamName,
  8728. x.DatePrice,
  8729. dayPrice = dp.ToString("F2"),
  8730. };
  8731. }).OrderByDescending(x => x.id).ToList();
  8732. jw = JsonView(true, "获取成功!", view);
  8733. }
  8734. catch (Exception e)
  8735. {
  8736. jw = JsonView(false, e.Message);
  8737. }
  8738. return Ok(jw);
  8739. }
  8740. #endregion
  8741. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8742. /// <summary>
  8743. /// 酒店预订
  8744. /// 酒店费用列表 根据团组Id查询
  8745. /// </summary>
  8746. /// <param name="_dto"></param>
  8747. /// <returns></returns>
  8748. [HttpPost]
  8749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8750. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8751. {
  8752. #region 参数验证
  8753. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8754. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8755. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8756. #region 团组操作权限验证 76 酒店预定模块
  8757. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8758. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8759. #endregion
  8760. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8761. #region 页面操作权限验证
  8762. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8764. #endregion
  8765. #endregion
  8766. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8767. }
  8768. /// <summary>
  8769. /// 酒店预订
  8770. /// 基础数据
  8771. /// </summary>
  8772. /// <param name="_dto"></param>
  8773. /// <returns></returns>
  8774. [HttpPost]
  8775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8776. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8777. {
  8778. #region 参数验证
  8779. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8780. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8781. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8782. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8783. #region 页面操作权限验证
  8784. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8785. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8786. #endregion
  8787. #region 团组操作权限验证 76 酒店预定模块
  8788. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8789. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8790. #endregion
  8791. #endregion
  8792. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8793. }
  8794. /// <summary>
  8795. /// 酒店预订
  8796. /// 创建 入住卷号码
  8797. /// </summary>
  8798. /// <param name="_dto"></param>
  8799. /// <returns></returns>
  8800. [HttpPost]
  8801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8802. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8803. {
  8804. try
  8805. {
  8806. #region 参数验证
  8807. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8808. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8809. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8811. #region 页面操作权限验证
  8812. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8813. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8814. #endregion
  8815. #region 团组操作权限验证 76 酒店预定模块
  8816. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8817. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8818. #endregion
  8819. #endregion
  8820. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8821. if (data.Code != 0)
  8822. {
  8823. return Ok(JsonView(false, data.Msg));
  8824. }
  8825. return Ok(JsonView(true, data.Msg, data.Data));
  8826. }
  8827. catch (Exception ex)
  8828. {
  8829. return Ok(JsonView(false, ex.Message));
  8830. }
  8831. }
  8832. /// <summary>
  8833. /// 酒店预订
  8834. /// 详情
  8835. /// </summary>
  8836. /// <param name="_dto"></param>
  8837. /// <returns></returns>
  8838. [HttpPost]
  8839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8840. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8841. {
  8842. #region 参数验证
  8843. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8844. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8845. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8846. #region 团组操作权限验证 76 酒店预定模块
  8847. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8848. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8849. #endregion
  8850. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8851. #region 页面操作权限验证
  8852. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8853. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8854. #endregion
  8855. #endregion
  8856. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8857. }
  8858. /// <summary>
  8859. /// 酒店预订
  8860. /// Add Or Edit
  8861. /// </summary>
  8862. /// <param name="_dto"></param>
  8863. /// <returns></returns>
  8864. [HttpPost]
  8865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8866. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8867. {
  8868. #region 参数验证
  8869. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8870. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8871. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8872. #region 团组操作权限验证 76 酒店预定模块
  8873. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8874. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8875. #endregion
  8876. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8877. #region 页面操作权限验证
  8878. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8879. if (_dto.Id == 0) // Add
  8880. {
  8881. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8882. }
  8883. else if (_dto.Id > 1) // Edit
  8884. {
  8885. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8886. }
  8887. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8888. #endregion
  8889. #endregion
  8890. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8891. if (_view.Code != 200)
  8892. {
  8893. return Ok(_view);
  8894. }
  8895. #region 应用推送
  8896. try
  8897. {
  8898. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8899. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8900. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8901. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8902. //自动审核
  8903. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8904. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  8905. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  8906. }
  8907. catch (Exception ex)
  8908. {
  8909. }
  8910. #endregion
  8911. return Ok(_view);
  8912. }
  8913. /// <summary>
  8914. /// 酒店自动审核测试
  8915. /// Add Or Edit
  8916. /// </summary>
  8917. /// <param name="_dto"></param>
  8918. /// <returns></returns>
  8919. [HttpPost]
  8920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8921. public async Task<IActionResult> PostHotelAutoAuditTest(int diid,int dataId)
  8922. {
  8923. #region 应用推送
  8924. try
  8925. {
  8926. //自动审核
  8927. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  8928. }
  8929. catch (Exception ex)
  8930. {
  8931. return Ok(JsonView(false, "操作失败"));
  8932. }
  8933. #endregion
  8934. return Ok(JsonView(false,"操作成功"));
  8935. }
  8936. /// <summary>
  8937. /// 酒店预订
  8938. /// Del
  8939. /// </summary>
  8940. /// <param name="_dto"></param>
  8941. /// <returns></returns>
  8942. [HttpPost]
  8943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8944. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8945. {
  8946. #region 参数验证
  8947. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8948. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8949. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8950. #region 团组操作权限验证 76 酒店预定模块
  8951. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8952. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8953. #endregion
  8954. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8955. #region 页面操作权限验证
  8956. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8957. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8958. #endregion
  8959. #endregion
  8960. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8961. }
  8962. /// <summary>
  8963. /// 酒店预订
  8964. /// 生成VOUCHER
  8965. /// 2024.05.06 之前版本
  8966. /// </summary>
  8967. /// <param name="_dto"></param>
  8968. /// <returns></returns>
  8969. [HttpPost]
  8970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8971. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  8972. {
  8973. try
  8974. {
  8975. #region 参数验证
  8976. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8977. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8978. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8979. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  8980. #region 团组操作权限验证 76 酒店预定模块
  8981. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8982. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8983. #endregion
  8984. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8985. #region 页面操作权限验证
  8986. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8987. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8988. #endregion
  8989. #endregion
  8990. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8991. //判断数据是否完整
  8992. if (hr != null)
  8993. {
  8994. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8995. {
  8996. string strFileName = "HotelStatement/";
  8997. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8998. if (dele != null)
  8999. strFileName += dele.TourCode;
  9000. //载入模板
  9001. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  9002. Document doc = new Document(sss);
  9003. DocumentBuilder builder = new DocumentBuilder(doc);
  9004. #region 替换Word模板书签内容
  9005. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  9006. //入住卷预定号码
  9007. if (doc.Range.Bookmarks["VNO"] != null)
  9008. {
  9009. Bookmark mark = doc.Range.Bookmarks["VNO"];
  9010. mark.Text = hr.CheckNumber;
  9011. }
  9012. //酒店时间
  9013. if (doc.Range.Bookmarks["Date"] != null)
  9014. {
  9015. Bookmark mark = doc.Range.Bookmarks["Date"];
  9016. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9017. }
  9018. //团号
  9019. if (doc.Range.Bookmarks["TNo"] != null)
  9020. {
  9021. Bookmark mark = doc.Range.Bookmarks["TNo"];
  9022. mark.Text = dele.TourCode;
  9023. }
  9024. //预定号码
  9025. if (doc.Range.Bookmarks["BookingId"] != null)
  9026. {
  9027. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  9028. mark.Text = hr.ReservationsNo;
  9029. }
  9030. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  9031. {
  9032. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  9033. mark.Text = hr.DetermineNo;
  9034. }
  9035. //酒店城市
  9036. if (doc.Range.Bookmarks["City"] != null)
  9037. {
  9038. Bookmark mark = doc.Range.Bookmarks["City"];
  9039. mark.Text = hr.City;
  9040. }
  9041. //酒店名称
  9042. if (doc.Range.Bookmarks["HName"] != null)
  9043. {
  9044. Bookmark mark = doc.Range.Bookmarks["HName"];
  9045. mark.Text = hr.HotelName;
  9046. }
  9047. //酒店地址
  9048. if (doc.Range.Bookmarks["Address"] != null)
  9049. {
  9050. Bookmark mark = doc.Range.Bookmarks["Address"];
  9051. mark.Text = hr.HotelAddress;
  9052. }
  9053. //酒店电话
  9054. if (doc.Range.Bookmarks["Tel"] != null)
  9055. {
  9056. Bookmark mark = doc.Range.Bookmarks["Tel"];
  9057. mark.Text = hr.HotelTel;
  9058. }
  9059. //酒店传真
  9060. if (doc.Range.Bookmarks["Fax"] != null)
  9061. {
  9062. Bookmark mark = doc.Range.Bookmarks["Fax"];
  9063. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  9064. {
  9065. mark.Text = hr.HotelFax;
  9066. }
  9067. }
  9068. //入住时间
  9069. if (doc.Range.Bookmarks["CIn"] != null)
  9070. {
  9071. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9072. Bookmark mark = doc.Range.Bookmarks["CIn"];
  9073. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  9074. }
  9075. //退房时间
  9076. if (doc.Range.Bookmarks["COut"] != null)
  9077. {
  9078. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9079. Bookmark mark = doc.Range.Bookmarks["COut"];
  9080. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9081. }
  9082. //客户名称
  9083. if (doc.Range.Bookmarks["GName"] != null)
  9084. {
  9085. string guestName = "";
  9086. string[] clients = new string[] { };
  9087. if (hr.GuestName.Contains(","))
  9088. {
  9089. clients = hr.GuestName.Split(",");
  9090. }
  9091. else
  9092. {
  9093. clients = new string[] { hr.GuestName };
  9094. }
  9095. List<int> clientIds_int = new List<int>();
  9096. if (clients.Length > 0)
  9097. {
  9098. foreach (var item in clients)
  9099. {
  9100. if (item.IsNumeric())
  9101. {
  9102. clientIds_int.Add(int.Parse(item));
  9103. }
  9104. }
  9105. }
  9106. if (clientIds_int.Count > 0)
  9107. {
  9108. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  9109. foreach (var client in _clientDatas)
  9110. {
  9111. //男
  9112. if (client.Sex == 0) guestName += $"Mr.";
  9113. //女
  9114. else if (client.Sex == 1) guestName += $"Ms.";
  9115. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  9116. {
  9117. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  9118. }
  9119. //guestName += $"{client.Pinyin},";
  9120. }
  9121. if (guestName.Length > 0)
  9122. {
  9123. guestName = guestName.Substring(0, guestName.Length - 1);
  9124. }
  9125. }
  9126. else
  9127. {
  9128. guestName = hr.GuestName;
  9129. }
  9130. Bookmark mark = doc.Range.Bookmarks["GName"];
  9131. mark.Text = guestName;
  9132. }
  9133. //房间介绍
  9134. if (doc.Range.Bookmarks["ROOM"] != null)
  9135. {
  9136. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  9137. mark.Text = hr.RoomExplanation;
  9138. }
  9139. //报价描述
  9140. if (doc.Range.Bookmarks["NOTE"] != null)
  9141. {
  9142. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9143. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9144. if (ss != null)
  9145. mark.Text = ss.Name;
  9146. }
  9147. //入住时间
  9148. if (doc.Range.Bookmarks["CheckIn"] != null)
  9149. {
  9150. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9151. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9152. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9153. }
  9154. //退房时间
  9155. if (doc.Range.Bookmarks["CheckOut"] != null)
  9156. {
  9157. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9158. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9159. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9160. }
  9161. //日期
  9162. if (doc.Range.Bookmarks["DT"] != null)
  9163. {
  9164. Bookmark mark = doc.Range.Bookmarks["DT"];
  9165. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9166. }
  9167. //名称
  9168. if (doc.Range.Bookmarks["VName"] != null)
  9169. {
  9170. Bookmark mark = doc.Range.Bookmarks["VName"];
  9171. mark.Text = hr.HotelName;
  9172. }
  9173. //号码
  9174. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9175. {
  9176. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9177. mark.Text = hr.CheckNumber;
  9178. }
  9179. #endregion
  9180. strFileName += "VOUCHER.doc";
  9181. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9182. doc.Save(fileDir);
  9183. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9184. return Ok(JsonView(true, "操作成功!", Url));
  9185. }
  9186. else
  9187. {
  9188. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9189. }
  9190. }
  9191. else
  9192. {
  9193. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9194. }
  9195. }
  9196. catch (Exception ex)
  9197. {
  9198. return Ok(JsonView(false, ex.Message));
  9199. }
  9200. }
  9201. /// <summary>
  9202. /// 酒店预订
  9203. /// 生成VOUCHER
  9204. /// 2024.05.06 之后版本
  9205. /// </summary>
  9206. /// <param name="_dto"></param>
  9207. /// <returns></returns>
  9208. [HttpPost]
  9209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9210. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9211. {
  9212. #region 参数验证
  9213. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9214. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9215. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9216. #region 团组操作权限验证 76 酒店预定模块
  9217. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9218. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9219. #endregion
  9220. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9221. #region 页面操作权限验证
  9222. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9223. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9224. #endregion
  9225. #endregion
  9226. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9227. //判断数据是否完整
  9228. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9229. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9230. string strFileName = "HotelStatement/";
  9231. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9232. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9233. #region 数据处理
  9234. List<int> guestIds = new List<int>();
  9235. int index = 0;
  9236. foreach (var item in hrDtas)
  9237. {
  9238. if (item.GuestName.Contains(","))
  9239. {
  9240. string[] guestIdArr = item.GuestName.Split(',');
  9241. foreach (var guestIdStr in guestIdArr)
  9242. {
  9243. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9244. if (guestBool)
  9245. {
  9246. guestIds.Add(guestId);
  9247. }
  9248. }
  9249. }
  9250. else guestNames += item.GuestName;
  9251. var voucherInfo = new HotelVoucherInfoView()
  9252. {
  9253. HotelName = item.HotelName,
  9254. CheckInDate = item.CheckInDate,
  9255. CheckOutDate = item.CheckOutDate,
  9256. ConfirmationNumber = item.DetermineNo.Trim(),
  9257. RoomType = item.RoomExplanation
  9258. };
  9259. vouchers.Add(voucherInfo);
  9260. }
  9261. if (guestIds.Count > 0)
  9262. {
  9263. guestIds = guestIds.Distinct().ToList();
  9264. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9265. if (guestDatas.Count > 0)
  9266. {
  9267. guestNames = "";
  9268. foreach (var guest in guestDatas)
  9269. {
  9270. string guestName = "";
  9271. if (guest.Sex == 0) guestName += @"MR.";
  9272. else if (guest.Sex == 1) guestName += @"MS.";
  9273. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9274. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9275. guestNames += @$"{guestName.Trim()}、";
  9276. }
  9277. if (guestNames.Length > 0)
  9278. {
  9279. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9280. }
  9281. }
  9282. }
  9283. #endregion
  9284. //载入模板
  9285. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9286. Document doc = new Document(sss);
  9287. DocumentBuilder builder = new DocumentBuilder(doc);
  9288. if (doc.Range.Bookmarks["GuestName"] != null)
  9289. {
  9290. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9291. mark.Text = guestNames;
  9292. }
  9293. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9294. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9295. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9296. for (int i = 1; i <= vouchers.Count; i++)
  9297. {
  9298. HotelVoucherInfoView hviv = vouchers[i - 1];
  9299. builder.MoveToCell(0, i, 0, 0);
  9300. builder.Write(hviv.HotelName);
  9301. builder.MoveToCell(0, i, 1, 0);
  9302. builder.Write(hviv.CheckInDate);
  9303. builder.MoveToCell(0, i, 2, 0);
  9304. builder.Write(hviv.CheckOutDate);
  9305. builder.MoveToCell(0, i, 3, 0);
  9306. builder.Write(hviv.RoomType);
  9307. builder.MoveToCell(0, i, 4, 0);
  9308. builder.Write(hviv.ConfirmationNumber);
  9309. }
  9310. //删除多余行
  9311. int currRowIndex = vouchers.Count + 1;
  9312. int delRows = 21 - currRowIndex;
  9313. if (delRows > 0)
  9314. {
  9315. for (int i = 0; i < delRows; i++)
  9316. {
  9317. table.Rows.RemoveAt(currRowIndex);
  9318. //cultivateRowIndex++;
  9319. }
  9320. }
  9321. strFileName += "VOUCHER.docx";
  9322. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9323. doc.Save(fileDir);
  9324. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9325. return Ok(JsonView(true, "操作成功!", Url));
  9326. }
  9327. /// <summary>
  9328. /// 酒店预订
  9329. /// 生成VOUCHER 批量生成
  9330. /// New
  9331. /// </summary>
  9332. /// <param name="_dto"></param>
  9333. /// <returns></returns>
  9334. [HttpPost]
  9335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9336. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  9337. {
  9338. #region 参数验证
  9339. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9340. if (_dto.PageId < 1) _dto.PageId = 28;
  9341. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9342. #region 团组操作权限验证 76 酒店预定模块
  9343. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9344. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9345. #endregion
  9346. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9347. #region 页面操作权限验证
  9348. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9349. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9350. #endregion
  9351. #endregion
  9352. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  9353. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  9354. .OrderBy(x => x.CreateTime)
  9355. .ToListAsync();
  9356. //判断数据是否完整
  9357. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9358. string strFileName = "HotelStatement/";
  9359. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  9360. if (dele != null)
  9361. strFileName += $"{dele.TourCode}_";
  9362. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
  9363. for (int i = 0; i < hrDtas.Count; i++)
  9364. {
  9365. string guestNames = string.Empty;
  9366. List<int> guestIds = new List<int>();
  9367. var item = hrDtas[i];
  9368. //处理客户姓名
  9369. if (item.GuestName.Contains(","))
  9370. {
  9371. string[] guestIdArr = item.GuestName.Split(',');
  9372. foreach (var guestIdStr in guestIdArr)
  9373. if (int.TryParse(guestIdStr, out int guestId))
  9374. guestIds.Add(guestId);
  9375. }
  9376. else guestNames += item.GuestName;
  9377. if (guestIds.Count > 0)
  9378. {
  9379. guestIds = guestIds.Distinct().ToList();
  9380. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  9381. if (guestDatas1.Count > 0)
  9382. {
  9383. guestNames = "";
  9384. foreach (var guest in guestDatas1)
  9385. {
  9386. string guestName = "";
  9387. if (guest.Sex == 0) guestName += @"MR.";
  9388. else if (guest.Sex == 1) guestName += @"MS.";
  9389. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9390. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9391. guestNames += @$"{guestName.Trim()}、";
  9392. }
  9393. if (guestNames.Length > 0)
  9394. {
  9395. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9396. }
  9397. }
  9398. }
  9399. if (!string.IsNullOrEmpty(guestNames))
  9400. {
  9401. hrDtas[i].GuestName = guestNames;
  9402. }
  9403. }
  9404. strFileName += $"{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}_VOUCHER.docx";
  9405. Document doc = new Document();
  9406. DocumentBuilder builder = new DocumentBuilder(doc);
  9407. try
  9408. {
  9409. #region 设置页眉
  9410. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  9411. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  9412. //靠右
  9413. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  9414. // 设置页脚上下边距
  9415. builder.PageSetup.HeaderDistance = 42;
  9416. // 添加页眉线
  9417. Aspose.Words.Border borderHeader = null;
  9418. try
  9419. {
  9420. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  9421. }
  9422. catch (Exception e)
  9423. {
  9424. // TODO Auto-generated catch block
  9425. //e.printStackTrace();
  9426. }
  9427. borderHeader.Shadow = true;
  9428. borderHeader.DistanceFromText = 2;
  9429. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  9430. if (System.IO.File.Exists(voucherHeaderPath))
  9431. {
  9432. //页眉加载图片
  9433. var image = Image.FromFile(voucherHeaderPath);
  9434. builder.InsertImage(image, RelativeHorizontalPosition.Default, 1, RelativeVerticalPosition.Margin, 1, 1.20, 2.70, WrapType.Inline);
  9435. }
  9436. #endregion
  9437. builder.MoveToDocumentStart();
  9438. foreach (var item in hrDtas)
  9439. {
  9440. //标题
  9441. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9442. builder.ParagraphFormat.LineSpacing = 1;
  9443. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9444. //builder.ParagraphFormat.Style.Font.Size = 12;
  9445. //builder.ParagraphFormat.Style.Font.Bold = true;
  9446. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9447. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  9448. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  9449. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  9450. builder.ParagraphFormat.LineSpacing = 1;
  9451. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9452. //builder.ParagraphFormat.Style.Font.Size = 12;
  9453. //builder.ParagraphFormat.Style.Font.Bold = true;
  9454. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  9455. //获取Font对象
  9456. Aspose.Words.Font font = builder.Font;
  9457. //字体大小
  9458. font.Size = 8;
  9459. //是否粗体
  9460. font.Bold = false;
  9461. //下划线样式,None为无下划线
  9462. font.Underline = Underline.None;
  9463. builder.StartTable();
  9464. //RowFormat rowf = builder.RowFormat;
  9465. //rowf.Height = 20;
  9466. // 设置边框颜色
  9467. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  9468. //设置边框样式
  9469. //builder.CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.Double;
  9470. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.None;
  9471. //表格
  9472. #region 第一行
  9473. builder.InsertCell();
  9474. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9475. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9476. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9477. builder.ParagraphFormat.Style.Font.Size = 8;
  9478. builder.ParagraphFormat.Style.Font.Bold = false;
  9479. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9480. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9481. builder.Write("TOUR NO:");
  9482. builder.InsertCell();
  9483. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9484. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9485. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9486. builder.ParagraphFormat.Style.Font.Size = 8;
  9487. builder.ParagraphFormat.Style.Font.Bold = false;
  9488. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9489. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9490. builder.Write($"{dele?.TourCode ?? "-"}");
  9491. builder.InsertCell();
  9492. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9493. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9494. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9495. builder.ParagraphFormat.Style.Font.Size = 8;
  9496. builder.ParagraphFormat.Style.Font.Bold = false;
  9497. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9498. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9499. builder.Write($"CITY:");
  9500. builder.InsertCell();
  9501. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9502. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9503. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9504. builder.ParagraphFormat.Style.Font.Size = 8;
  9505. builder.ParagraphFormat.Style.Font.Bold = false;
  9506. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9507. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9508. builder.Write($"{item.City}");
  9509. builder.EndRow();
  9510. #endregion
  9511. #region 第二行
  9512. builder.InsertCell();
  9513. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9514. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9515. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9516. builder.ParagraphFormat.Style.Font.Size = 8;
  9517. builder.ParagraphFormat.Style.Font.Bold = false;
  9518. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9519. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9520. builder.Write("CONFIRMATION NO:");
  9521. builder.InsertCell();
  9522. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9523. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9524. builder.ParagraphFormat.Style.Font.Size = 8;
  9525. builder.ParagraphFormat.Style.Font.Bold = false;
  9526. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9527. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9528. builder.CellFormat.VerticalMerge = CellMerge.None;
  9529. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9530. builder.Write($"{item.DetermineNo}");
  9531. builder.InsertCell();
  9532. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9533. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9534. builder.InsertCell();
  9535. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9536. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9537. builder.EndRow();
  9538. #endregion
  9539. #region 第三行
  9540. builder.InsertCell();
  9541. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9542. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9543. builder.ParagraphFormat.Style.Font.Size = 8;
  9544. builder.ParagraphFormat.Style.Font.Bold = false;
  9545. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9546. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9547. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9548. builder.Write($"HOTEL NAME:");
  9549. builder.InsertCell();
  9550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9551. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9552. builder.ParagraphFormat.Style.Font.Size = 8;
  9553. builder.ParagraphFormat.Style.Font.Bold = false;
  9554. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9555. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9556. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9557. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9558. builder.Write($"{item.HotelName}");
  9559. builder.InsertCell();
  9560. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9561. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9562. builder.InsertCell();
  9563. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9564. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9565. builder.EndRow();
  9566. #endregion
  9567. #region 第四行
  9568. builder.InsertCell();
  9569. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9570. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9571. builder.ParagraphFormat.Style.Font.Size = 8;
  9572. builder.ParagraphFormat.Style.Font.Bold = false;
  9573. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9574. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9575. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9576. builder.Write($"HOTEL ADDRESS:");
  9577. builder.InsertCell();
  9578. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9579. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9580. builder.ParagraphFormat.Style.Font.Size = 8;
  9581. builder.ParagraphFormat.Style.Font.Bold = false;
  9582. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9583. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9584. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9585. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9586. builder.Write($"{item.HotelAddress}");
  9587. builder.InsertCell();
  9588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9589. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9590. builder.InsertCell();
  9591. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9592. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9593. builder.EndRow();
  9594. #endregion
  9595. #region 第五行
  9596. builder.InsertCell();
  9597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9598. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9599. builder.ParagraphFormat.Style.Font.Size = 8;
  9600. builder.ParagraphFormat.Style.Font.Bold = false;
  9601. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9602. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9603. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9604. builder.Write("TEL:");
  9605. builder.InsertCell();
  9606. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9607. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9608. builder.ParagraphFormat.Style.Font.Size = 8;
  9609. builder.ParagraphFormat.Style.Font.Bold = false;
  9610. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9611. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9612. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9613. builder.Write($"{item.HotelTel}");
  9614. builder.InsertCell();
  9615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9617. builder.ParagraphFormat.Style.Font.Size = 8;
  9618. builder.ParagraphFormat.Style.Font.Bold = false;
  9619. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9622. builder.Write($"FAX:");
  9623. builder.InsertCell();
  9624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9625. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9626. builder.ParagraphFormat.Style.Font.Size = 8;
  9627. builder.ParagraphFormat.Style.Font.Bold = false;
  9628. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9629. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9630. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9631. builder.Write($"{item.HotelFax}");
  9632. builder.EndRow();
  9633. #endregion
  9634. #region 第六行
  9635. builder.InsertCell();
  9636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9637. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9638. builder.ParagraphFormat.Style.Font.Size = 8;
  9639. builder.ParagraphFormat.Style.Font.Bold = false;
  9640. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9643. builder.Write("CHECK IN:");
  9644. builder.InsertCell();
  9645. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9646. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9647. builder.ParagraphFormat.Style.Font.Size = 8;
  9648. builder.ParagraphFormat.Style.Font.Bold = false;
  9649. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9650. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9651. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9652. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  9653. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9654. builder.Write($"{checkInStr}");
  9655. builder.InsertCell();
  9656. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9657. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9658. builder.ParagraphFormat.Style.Font.Size = 8;
  9659. builder.ParagraphFormat.Style.Font.Bold = false;
  9660. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9661. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9662. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9663. builder.Write($"CHECK OUT:");
  9664. builder.InsertCell();
  9665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9666. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9667. builder.ParagraphFormat.Style.Font.Size = 8;
  9668. builder.ParagraphFormat.Style.Font.Bold = false;
  9669. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9670. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9672. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  9673. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  9674. builder.Write($"{checkOutStr}");
  9675. builder.EndRow();
  9676. #endregion
  9677. #region 第七行
  9678. builder.InsertCell();
  9679. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9680. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9681. builder.ParagraphFormat.Style.Font.Size = 8;
  9682. builder.ParagraphFormat.Style.Font.Bold = false;
  9683. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9684. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9685. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9686. builder.Write($"GUEST NAME:");
  9687. builder.InsertCell();
  9688. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9689. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9690. builder.ParagraphFormat.Style.Font.Size = 8;
  9691. builder.ParagraphFormat.Style.Font.Bold = false;
  9692. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9693. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9694. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9695. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9696. builder.Write($"{item.GuestName}");
  9697. builder.InsertCell();
  9698. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9699. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9700. builder.InsertCell();
  9701. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9702. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9703. builder.EndRow();
  9704. #endregion
  9705. #region 第八行
  9706. builder.InsertCell();
  9707. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9708. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9709. builder.ParagraphFormat.Style.Font.Size = 8;
  9710. builder.ParagraphFormat.Style.Font.Bold = false;
  9711. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9712. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9713. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9714. builder.Write($"ROOM TYPE:");
  9715. builder.InsertCell();
  9716. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9717. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9718. builder.ParagraphFormat.Style.Font.Size = 8;
  9719. builder.ParagraphFormat.Style.Font.Bold = false;
  9720. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9721. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9722. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9723. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9724. builder.Write($"{item.RoomExplanation}");
  9725. builder.InsertCell();
  9726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9727. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9728. builder.InsertCell();
  9729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9730. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9731. builder.EndRow();
  9732. #endregion
  9733. #region 第九行
  9734. builder.InsertCell();
  9735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9737. builder.ParagraphFormat.Style.Font.Size = 8;
  9738. builder.ParagraphFormat.Style.Font.Bold = false;
  9739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  9742. builder.Write($"NOTE:");
  9743. builder.InsertCell();
  9744. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9745. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9746. builder.ParagraphFormat.Style.Font.Size = 8;
  9747. builder.ParagraphFormat.Style.Font.Bold = false;
  9748. builder.CellFormat.HorizontalMerge = CellMerge.None;
  9749. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  9750. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  9751. builder.CellFormat.HorizontalMerge = CellMerge.First;
  9752. builder.Write($"ROOM AND TAX ONLY\r\nTHIS SERVICE IS PAYABLE BY BEDSONLINE. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST");
  9753. builder.InsertCell();
  9754. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  9755. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9756. builder.InsertCell();
  9757. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  9758. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  9759. builder.EndRow();
  9760. #endregion
  9761. builder.EndTable();
  9762. builder.Writeln("");
  9763. builder.Writeln("");
  9764. }
  9765. //// 遍历文档中的所有段落
  9766. //foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
  9767. //{
  9768. // // 设置段落的字体样式
  9769. // // 这里我们设置字体为Times New Roman,大小为12,加粗
  9770. // para.ParagraphFormat.Style.Font.Name = "微软雅黑";
  9771. // para.ParagraphFormat.Style.Font.Size = 12;
  9772. // para.ParagraphFormat.Style.Font.Bold = true;
  9773. //}
  9774. }
  9775. catch (Exception ex)
  9776. {
  9777. }
  9778. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9779. doc.Save(fileDir);
  9780. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9781. return Ok(JsonView(true, "操作成功!", Url));
  9782. }
  9783. /// <summary>
  9784. /// 酒店预订
  9785. /// 生成 预定成本 Excel
  9786. /// </summary>
  9787. /// <param name="_dto"></param>
  9788. /// <returns></returns>
  9789. [HttpPost]
  9790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9791. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9792. {
  9793. #region 参数验证
  9794. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9795. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9796. if (!vadalitorRes.IsValid)
  9797. {
  9798. var errors = new StringBuilder();
  9799. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9800. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9801. }
  9802. #region 团组操作权限验证 76 酒店预定模块
  9803. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9804. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9805. #endregion
  9806. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9807. #region 页面操作权限验证
  9808. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9809. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9810. #endregion
  9811. #endregion
  9812. decimal _rate = 1.00M;
  9813. string _currency = "";
  9814. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9815. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9816. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9817. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9818. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9819. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9820. {
  9821. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9822. }
  9823. _currency = _GroupCostParameter.Currency;
  9824. bool isIntType = int.TryParse(_currency, out int currId);
  9825. if (isIntType)
  9826. {
  9827. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9828. }
  9829. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9830. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9831. if (currInfo == null)
  9832. {
  9833. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9834. }
  9835. if (!_currency.ToUpper().Equals("CNY"))
  9836. {
  9837. _rate = _GroupCostParameter.Rate;
  9838. }
  9839. _rate = currInfo.Rate;
  9840. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9841. string strFileName = "HotelStatement/";
  9842. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9843. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9844. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9845. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9846. #region 数据处理
  9847. foreach (var item in hrDtas)
  9848. {
  9849. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9850. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9851. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9852. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9853. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9854. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  9855. string singleRoomFeeStr = string.Empty,
  9856. doubleRoomFeeStr = string.Empty,
  9857. suiteRoomFeeStr = string.Empty,
  9858. otherRoomFeeStr = string.Empty,
  9859. payMoneyStr = string.Empty,
  9860. cardPriceStr = string.Empty;
  9861. if (roomCurr.Equals(_currency))
  9862. {
  9863. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9864. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9865. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9866. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9867. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9868. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9869. }
  9870. else
  9871. {
  9872. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9873. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9874. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9875. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9876. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9877. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9878. }
  9879. string breakfastPriceStr = string.Empty,
  9880. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9881. governmentRentStr = string.Empty,
  9882. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9883. cityTaxStrStr = string.Empty,
  9884. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9885. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9886. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9887. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9888. int payDId = roomInfo?.PayDId ?? 0;
  9889. pcfds.Add(new HotelReservations_PCFD_View()
  9890. {
  9891. City = item.City,
  9892. HotelName = item.HotelName,
  9893. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9894. // SingleRoomCount = item.SingleRoomCount,
  9895. SingleRoomPrice = singleRoomFeeStr,
  9896. // DoubleRoomCount = item.DoubleRoomCount,
  9897. DoubleRoomPrice = doubleRoomFeeStr,
  9898. //SuiteRoomCount = item.SuiteRoomCount,
  9899. SuiteRoomPrice = suiteRoomFeeStr,
  9900. OtherRoomPrice = otherRoomFeeStr,
  9901. //OtherRoomCount = item.OtherRoomCount,
  9902. BreakfastPrice = breakfastPriceStr,
  9903. GovernmentRent = governmentRentStr,
  9904. CityTax = cityTaxStrStr,
  9905. RoomExplanation = item.RoomExplanation,
  9906. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  9907. PayTime = roomInfo?.ConsumptionDate,
  9908. BankNo = roomInfo?.BankNo,
  9909. PayMoney = payMoneyStr,
  9910. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9911. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  9912. CardPrice = cardPriceStr,
  9913. Remark = ccpInfo.Remark
  9914. });
  9915. }
  9916. #endregion
  9917. //载入模板
  9918. WorkbookDesigner designer = new WorkbookDesigner();
  9919. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9920. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9921. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9922. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9923. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9924. designer.SetDataSource("Opertor", userInfo.CnName);
  9925. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9926. dt.TableName = "ViewMyHotelReservations";
  9927. designer.SetDataSource(dt);
  9928. designer.Process();
  9929. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/","").Replace(@"\", "").Trim()}_酒店预订成本_{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  9930. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9931. designer.Workbook.Save(serverPath);
  9932. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9933. #region 删除指定行
  9934. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9935. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9936. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9937. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9938. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9939. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9940. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9941. cssIndex = dt.Columns["CityTax"].Ordinal,
  9942. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9943. remarkIndex = dt.Columns["Remark"].Ordinal;
  9944. //删除指定列
  9945. foreach (DataRow item in dt.Rows)
  9946. {
  9947. string singleStr = item["SingleRoomPrice"].ToString();
  9948. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9949. if (containsDigitButNotZero1) singleDel = false;
  9950. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9951. string doubleStr = item["DoubleRoomPrice"].ToString();
  9952. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9953. if (containsDigitButNotZero2) doubleDel = false;
  9954. string suiteStr = item["SuiteRoomPrice"].ToString();
  9955. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9956. if (containsDigitButNotZero3) suiteDel = false;
  9957. string otherStr = item["OtherRoomPrice"].ToString();
  9958. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9959. if (containsDigitButNotZero4) otherDel = false;
  9960. string zcStr = item["BreakfastPrice"].ToString();
  9961. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9962. if (containsDigitButNotZero5) zcDel = false;
  9963. string dsStr = item["GovernmentRent"].ToString();
  9964. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9965. if (containsDigitButNotZero6) dsDel = false;
  9966. string cssStr = item["CityTax"].ToString();
  9967. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9968. if (containsDigitButNotZero7) cssDel = false;
  9969. string cpStr = item["ConsumptionPatterns"].ToString();
  9970. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9971. string remarkStr = item["Remark"].ToString();
  9972. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9973. }
  9974. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9975. DeleteColumn(serverPath, cpIndex, cpDel);
  9976. DeleteColumn(serverPath, dsIndex, dsDel);
  9977. DeleteColumn(serverPath, cssIndex, cssDel);
  9978. DeleteColumn(serverPath, zcIndex, zcDel);
  9979. DeleteColumn(serverPath, otherIndex, otherDel);
  9980. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9981. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9982. DeleteColumn(serverPath, singleIndex, singleDel);
  9983. #endregion
  9984. //只保留第一个表格
  9985. DeleteSheet(serverPath);
  9986. return Ok(JsonView(true, "操作成功", url = rst));
  9987. }
  9988. /// <summary>
  9989. /// 删除指定列
  9990. /// </summary>
  9991. /// <param name="file"></param>
  9992. /// <param name="columnIndex"></param>
  9993. /// <param name="isDel"></param>
  9994. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9995. {
  9996. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9997. //wb.Save(file);
  9998. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9999. if (sheet1 != null)
  10000. {
  10001. if (isDel)
  10002. {
  10003. Cells cells = sheet1.Cells;
  10004. cells.DeleteColumn(columnIndex);
  10005. }
  10006. }
  10007. wb.Save(file);
  10008. }
  10009. /// <summary>
  10010. /// 删除sheet
  10011. /// </summary>
  10012. /// <param name="file"></param>
  10013. /// <param name="sheetName"></param>
  10014. private void DeleteSheet(string file, string sheetName = "")
  10015. {
  10016. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  10017. //wb.Save(file);
  10018. List<string> sheets = new List<string>();
  10019. foreach (var item in wb.Worksheets)
  10020. {
  10021. sheets.Add(item.Name);
  10022. }
  10023. if (sheets.Count > 0)
  10024. {
  10025. sheets.RemoveAt(0);//不删除第一个sheet
  10026. foreach (var item in sheets)
  10027. {
  10028. wb.Worksheets.RemoveAt(item);
  10029. }
  10030. }
  10031. wb.Save(file);
  10032. }
  10033. /// <summary>
  10034. /// 酒店预订
  10035. /// 确认单
  10036. /// </summary>
  10037. /// <param name="_dto"></param>
  10038. /// <returns></returns>
  10039. [HttpPost]
  10040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10041. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  10042. {
  10043. try
  10044. {
  10045. #region 参数验证
  10046. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  10047. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  10048. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  10049. #region 团组操作权限验证 76 酒店预定模块
  10050. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  10051. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  10052. #endregion
  10053. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10054. #region 页面操作权限验证
  10055. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10056. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10057. #endregion
  10058. #endregion
  10059. //团组信息
  10060. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  10061. //酒店数据
  10062. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  10063. if (listhoteldata.Count < 0)
  10064. {
  10065. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  10066. }
  10067. //利datatable存储
  10068. DataTable dt = new DataTable();
  10069. dt.Columns.Add("CheckInDate", typeof(string));
  10070. dt.Columns.Add("City", typeof(string));
  10071. dt.Columns.Add("Hotel", typeof(string));
  10072. dt.Columns.Add("Room", typeof(string));
  10073. for (int i = 0; i < listhoteldata.Count; i++)
  10074. {
  10075. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  10076. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  10077. while (dayStart < dayEnd)
  10078. {
  10079. string temp = "";
  10080. DataRow row = dt.NewRow();
  10081. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  10082. row["City"] = listhoteldata[i].City;
  10083. row["Hotel"] = listhoteldata[i].HotelName;
  10084. if (listhoteldata[i].SingleRoomCount > 0)
  10085. {
  10086. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  10087. }
  10088. if (listhoteldata[i].DoubleRoomCount > 0)
  10089. {
  10090. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  10091. }
  10092. if (listhoteldata[i].SuiteRoomCount > 0)
  10093. {
  10094. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  10095. }
  10096. if (listhoteldata[i].OtherRoomCount > 0)
  10097. {
  10098. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  10099. }
  10100. row["Room"] = temp;
  10101. dt.Rows.Add(row);
  10102. dayStart = dayStart.AddDays(1);
  10103. }
  10104. }
  10105. Dictionary<string, string> dic = new Dictionary<string, string>();
  10106. dic.Add("Dele", di.TeamName);
  10107. dic.Add("City", di.VisitCountry);
  10108. //模板路径
  10109. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  10110. //载入模板
  10111. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  10112. DocumentBuilder builder = new DocumentBuilder(doc);
  10113. foreach (var key in dic.Keys)
  10114. {
  10115. builder.MoveToBookmark(key);
  10116. builder.Write(dic[key]);
  10117. }
  10118. //获取word里所有表格
  10119. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10120. //获取所填表格的序数
  10121. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10122. var rowStart = tableOne.Rows[0]; //获取第1行
  10123. //循环赋值
  10124. for (int i = 0; i < dt.Rows.Count; i++)
  10125. {
  10126. builder.MoveToCell(0, i + 1, 0, 0);
  10127. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  10128. builder.MoveToCell(0, i + 1, 1, 0);
  10129. builder.Write(dt.Rows[i]["City"].ToString());
  10130. builder.MoveToCell(0, i + 1, 2, 0);
  10131. builder.Write(dt.Rows[i]["Hotel"].ToString());
  10132. builder.MoveToCell(0, i + 1, 3, 0);
  10133. builder.Write(dt.Rows[i]["Room"].ToString());
  10134. }
  10135. //删除多余行
  10136. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  10137. {
  10138. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  10139. }
  10140. string strFileName = di.TeamName + "酒店确认单.doc";
  10141. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  10142. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  10143. return Ok(JsonView(true, "成功", url));
  10144. }
  10145. catch (Exception ex)
  10146. {
  10147. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  10148. }
  10149. }
  10150. #endregion
  10151. #region 团组状态
  10152. /// <summary>
  10153. /// 团组状态列表 Page
  10154. /// </summary>
  10155. /// <param name="dto">团组列表请求dto</param>
  10156. /// <returns></returns>
  10157. [HttpPost]
  10158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10159. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  10160. {
  10161. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10162. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  10163. {
  10164. string sqlWhere = string.Empty;
  10165. if (dto.IsSure == 0) //未完成
  10166. {
  10167. sqlWhere += string.Format(@" And IsSure = 0");
  10168. }
  10169. else if (dto.IsSure == 1) //已完成
  10170. {
  10171. sqlWhere += string.Format(@" And IsSure = 1");
  10172. }
  10173. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  10174. {
  10175. string tj = dto.SearchCriteria;
  10176. 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}%')",
  10177. tj, tj, tj, tj, tj);
  10178. }
  10179. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  10180. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  10181. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  10182. From (
  10183. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  10184. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  10185. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  10186. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  10187. From Grp_DelegationInfo gdi
  10188. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  10189. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  10190. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  10191. Where gdi.IsDel = 0 {0}
  10192. ) temp ", sqlWhere);
  10193. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  10194. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  10195. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  10196. }
  10197. else
  10198. {
  10199. return Ok(JsonView(false, "查询失败"));
  10200. }
  10201. }
  10202. /// <summary>
  10203. /// 团组状态
  10204. /// 设置操作完成
  10205. /// </summary>
  10206. /// <param name="dto">团组列表请求dto</param>
  10207. /// <returns></returns>
  10208. [HttpPost]
  10209. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10210. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  10211. {
  10212. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  10213. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  10214. {
  10215. Id = dto.Id,
  10216. IsSure = 1
  10217. };
  10218. var result = await _sqlSugar.Updateable(_DelegationInfo)
  10219. .UpdateColumns(it => new { it.IsSure })
  10220. .WhereColumns(it => new { it.Id })
  10221. .ExecuteCommandAsync();
  10222. if (result > 0)
  10223. {
  10224. return Ok(JsonView(true, "操作完成!"));
  10225. }
  10226. return Ok(JsonView(false, "操作失败!"));
  10227. }
  10228. #endregion
  10229. #region 保险费用录入
  10230. /// <summary>
  10231. /// 根据团组Id查询保险费用列表
  10232. /// </summary>
  10233. /// <param name="dto"></param>
  10234. /// <returns></returns>
  10235. [HttpPost]
  10236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10237. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  10238. {
  10239. try
  10240. {
  10241. Result groupData = await _customersRep.CustomersByDiId(dto);
  10242. if (groupData.Code != 0)
  10243. {
  10244. return Ok(JsonView(false, groupData.Msg));
  10245. }
  10246. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10247. }
  10248. catch (Exception ex)
  10249. {
  10250. return Ok(JsonView(false, ex.Message));
  10251. }
  10252. }
  10253. /// <summary>
  10254. /// 根据保险费用Id查询保险费用详细
  10255. /// </summary>
  10256. /// <param name="dto"></param>
  10257. /// <returns></returns>
  10258. [HttpPost]
  10259. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10260. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  10261. {
  10262. try
  10263. {
  10264. Result groupData = await _customersRep.CustomersById(dto);
  10265. if (groupData.Code != 0)
  10266. {
  10267. return Ok(JsonView(false, groupData.Msg));
  10268. }
  10269. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10270. }
  10271. catch (Exception ex)
  10272. {
  10273. return Ok(JsonView(false, ex.Message));
  10274. }
  10275. }
  10276. /// <summary>
  10277. /// 保险费用录入页面初始化绑定
  10278. /// </summary>
  10279. /// <param name="dto"></param>
  10280. /// <returns></returns>
  10281. [HttpPost]
  10282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10283. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  10284. {
  10285. try
  10286. {
  10287. Result groupData = await _customersRep.CustomersInitialize(dto);
  10288. if (groupData.Code != 0)
  10289. {
  10290. return Ok(JsonView(false, groupData.Msg));
  10291. }
  10292. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10293. }
  10294. catch (Exception ex)
  10295. {
  10296. return Ok(JsonView(false, ex.Message));
  10297. }
  10298. }
  10299. /// <summary>
  10300. /// 保险费用操作(Status:1.新增,2.修改)
  10301. /// </summary>
  10302. /// <param name="dto"></param>
  10303. /// <returns></returns>
  10304. [HttpPost]
  10305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10306. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  10307. {
  10308. try
  10309. {
  10310. Result groupData = await _customersRep.OpCustomers(dto);
  10311. if (groupData.Code != 0)
  10312. {
  10313. return Ok(JsonView(false, groupData.Msg));
  10314. }
  10315. #region 应用推送
  10316. try
  10317. {
  10318. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10319. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10320. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10321. }
  10322. catch (Exception ex)
  10323. {
  10324. }
  10325. #endregion
  10326. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10327. }
  10328. catch (Exception ex)
  10329. {
  10330. return Ok(JsonView(false, ex.Message));
  10331. }
  10332. }
  10333. /// <summary>
  10334. /// 保险文件上传
  10335. /// </summary>
  10336. /// <param name="file"></param>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10340. public async Task<IActionResult> UploadCus(IFormFile file)
  10341. {
  10342. try
  10343. {
  10344. if (file != null)
  10345. {
  10346. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10347. //文件名称
  10348. string projectFileName = file.FileName;
  10349. //上传的文件的路径
  10350. string filePath = "";
  10351. if (!Directory.Exists(fileDir))
  10352. {
  10353. Directory.CreateDirectory(fileDir);
  10354. }
  10355. //上传的文件的路径
  10356. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  10357. using (FileStream fs = System.IO.File.Create(filePath))
  10358. {
  10359. file.CopyTo(fs);
  10360. fs.Flush();
  10361. }
  10362. return Ok(JsonView(true, "上传成功!", projectFileName));
  10363. }
  10364. else
  10365. {
  10366. return Ok(JsonView(false, "上传失败!"));
  10367. }
  10368. }
  10369. catch (Exception ex)
  10370. {
  10371. return Ok(JsonView(false, "程序错误!"));
  10372. throw;
  10373. }
  10374. }
  10375. /// <summary>
  10376. /// 保险删除指定文件
  10377. /// </summary>
  10378. /// <param name="dto"></param>
  10379. /// <returns></returns>
  10380. [HttpPost]
  10381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10382. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  10383. {
  10384. try
  10385. {
  10386. string filePath = "";
  10387. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  10388. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  10389. //int id = 0;
  10390. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  10391. // 删除该文件
  10392. try
  10393. {
  10394. System.IO.File.Delete(filePath);
  10395. 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()
  10396. {
  10397. Attachment = "",
  10398. }).ExecuteCommandAsync();
  10399. if (result != 0)
  10400. {
  10401. return Ok(JsonView(true, "成功!"));
  10402. }
  10403. else
  10404. {
  10405. return Ok(JsonView(false, "失败!"));
  10406. }
  10407. }
  10408. catch (Exception)
  10409. {
  10410. 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()
  10411. {
  10412. Attachment = "",
  10413. }).ExecuteCommandAsync();
  10414. if (result != 0)
  10415. {
  10416. return Ok(JsonView(true, "成功!"));
  10417. }
  10418. else
  10419. {
  10420. return Ok(JsonView(false, "失败!"));
  10421. }
  10422. }
  10423. }
  10424. catch (Exception ex)
  10425. {
  10426. return Ok(JsonView(false, "程序错误!"));
  10427. throw;
  10428. }
  10429. }
  10430. /// <summary>
  10431. /// 保险费用操作(删除)
  10432. /// </summary>
  10433. /// <param name="dto"></param>
  10434. /// <returns></returns>
  10435. [HttpPost]
  10436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10437. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  10438. {
  10439. try
  10440. {
  10441. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  10442. if (!res)
  10443. {
  10444. return Ok(JsonView(false, "删除失败"));
  10445. }
  10446. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  10447. {
  10448. IsDel = 1,
  10449. DeleteUserId = dto.DeleteUserId,
  10450. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10451. }).ExecuteCommandAsync();
  10452. return Ok(JsonView(true, "删除成功!"));
  10453. }
  10454. catch (Exception ex)
  10455. {
  10456. return Ok(JsonView(false, "程序错误!"));
  10457. throw;
  10458. }
  10459. }
  10460. #endregion
  10461. #region 接团客户名单 PageId 104
  10462. /// <summary>
  10463. /// 接团客户名单
  10464. /// 迁移数据(慎用!)
  10465. /// </summary>
  10466. /// <param name="dto"></param>
  10467. /// <returns></returns>
  10468. [HttpPost]
  10469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10470. public async Task<IActionResult> PostTourClientListChange()
  10471. {
  10472. try
  10473. {
  10474. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  10475. //var groupClinetData1
  10476. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  10477. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  10478. int updateCount = 0;
  10479. if (oldOAClientList.Count > 0)
  10480. {
  10481. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  10482. _sqlSugar.BeginTran();
  10483. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  10484. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  10485. foreach (var item in oldOAClientList)
  10486. {
  10487. int comId = 0;
  10488. string format = "yyyy-MM-dd HH:mm:ss";
  10489. string data11 = "1990-01-01 00:00";
  10490. var data1 = IsValidDate(item.OPdate, format);
  10491. if (data1) data11 = item.OPdate;
  10492. //客户公司验证
  10493. if (!string.IsNullOrEmpty(item.Company))
  10494. {
  10495. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  10496. if (clientComInfo == null) // add
  10497. {
  10498. var addInfo = new Crm_CustomerCompany()
  10499. {
  10500. CompanyAbbreviation = "",
  10501. CompanyFullName = item.Company,
  10502. Address = "",
  10503. PostCodes = "",
  10504. LastedOpUserId = item.OPer,
  10505. LastedOpDt = Convert.ToDateTime(data11),
  10506. CreateUserId = item.OPer,
  10507. CreateTime = Convert.ToDateTime(data11),
  10508. IsDel = 0
  10509. };
  10510. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  10511. if (comId1 > 0) comId = comId1;
  10512. }
  10513. else comId = clientComInfo.Id;
  10514. }
  10515. //客户人员验证
  10516. int clientId = 0;
  10517. string name = item.LastName + item.Name;
  10518. if (!string.IsNullOrEmpty(name))
  10519. {
  10520. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  10521. if (clientInfo == null)
  10522. {
  10523. DateTime? dateTime = null;
  10524. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  10525. if (isDt) dateTime = birthDayDt;
  10526. var addInfo1 = new Crm_DeleClient()
  10527. {
  10528. CrmCompanyId = comId,
  10529. DiId = -1,
  10530. LastName = item.LastName,
  10531. FirstName = item.Name,
  10532. OldName = "",
  10533. Pinyin = item.Pinyin,
  10534. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  10535. Marriage = 0,
  10536. Phone = item.Phone,
  10537. Job = item.Job,
  10538. BirthDay = dateTime
  10539. };
  10540. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  10541. if (clientId1 > 0) clientId = clientId1;
  10542. }
  10543. else clientId = clientInfo.Id;
  10544. }
  10545. if (clientId < 1)
  10546. {
  10547. continue;
  10548. }
  10549. int airType = 0;
  10550. if (item.AirType == "超经舱") airType = 459;
  10551. else if (item.AirType == "公务舱") airType = 458;
  10552. else if (item.AirType == "经济舱") airType = 460;
  10553. else if (item.AirType == "其他") airType = 565;
  10554. else if (item.AirType == "头等舱") airType = 457;
  10555. var _TourClientListEntity = new Grp_TourClientList()
  10556. {
  10557. DiId = item.Diid,
  10558. ClientId = clientId,
  10559. CreateUserId = item.OPer,
  10560. CreateTime = Convert.ToDateTime(data11),
  10561. Remark = item.Remark,
  10562. IsDel = item.Isdel,
  10563. ShippingSpaceTypeId = airType,
  10564. ShippingSpaceSpecialNeeds = item.AirRemark,
  10565. HotelSpecialNeeds = item.RoomType
  10566. };
  10567. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  10568. if (_TourClientList > 0)
  10569. {
  10570. updateCount++;
  10571. }
  10572. }
  10573. _sqlSugar.CommitTran();
  10574. }
  10575. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  10576. }
  10577. catch (Exception ex)
  10578. {
  10579. _sqlSugar.RollbackTran();
  10580. return Ok(JsonView(false, ex.Message));
  10581. }
  10582. return Ok(JsonView(true));
  10583. }
  10584. private bool IsValidDate(string dateString, string format)
  10585. {
  10586. DateTime dateValue;
  10587. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  10588. return valid;
  10589. }
  10590. /// <summary>
  10591. /// 接团客户名单
  10592. /// 根据团组Id查询List
  10593. /// </summary>
  10594. /// <param name="dto"></param>
  10595. /// <returns></returns>
  10596. [HttpPost]
  10597. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10598. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10599. {
  10600. #region 参数验证
  10601. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10602. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10603. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10604. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10605. #region 页面操作权限验证
  10606. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10607. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10608. #endregion
  10609. #endregion
  10610. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10611. if (viewData.Code != 0)
  10612. {
  10613. return Ok(JsonView(false, viewData.Msg));
  10614. }
  10615. return Ok(JsonView(viewData.Data));
  10616. }
  10617. /// <summary>
  10618. /// 接团客户名单
  10619. /// 基础数据 Init
  10620. /// </summary>
  10621. /// <param name="_dto"></param>
  10622. /// <returns></returns>
  10623. [HttpPost]
  10624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10625. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10626. {
  10627. #region 参数验证
  10628. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10629. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10630. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10631. #region 页面操作权限验证
  10632. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10633. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10634. #endregion
  10635. #endregion
  10636. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10637. if (viewData.Code != 0)
  10638. {
  10639. return Ok(JsonView(false, viewData.Msg));
  10640. }
  10641. return Ok(JsonView(viewData.Data));
  10642. }
  10643. /// <summary>
  10644. /// 接团客户名单
  10645. /// 根据 Id查询 Details
  10646. /// </summary>
  10647. /// <param name="_dto"></param>
  10648. /// <returns></returns>
  10649. [HttpPost]
  10650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10651. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10652. {
  10653. #region 参数验证
  10654. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10655. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10656. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10657. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10658. #region 页面操作权限验证
  10659. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10660. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10661. #endregion
  10662. #endregion
  10663. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10664. if (viewData.Code != 0)
  10665. {
  10666. return Ok(JsonView(false, viewData.Msg));
  10667. }
  10668. return Ok(JsonView(viewData.Data));
  10669. }
  10670. /// <summary>
  10671. /// 接团客户名单
  10672. /// Add Or Edit
  10673. /// </summary>
  10674. /// <param name="_dto"></param>
  10675. /// <returns></returns>
  10676. [HttpPost]
  10677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10678. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10679. {
  10680. #region 参数验证
  10681. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10682. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10683. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10684. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10685. #region 页面操作权限验证
  10686. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10687. if (_dto.Id == 0) //添加
  10688. {
  10689. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10690. }
  10691. else if (_dto.Id >= 0) //修改
  10692. {
  10693. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10694. }
  10695. #endregion
  10696. #endregion
  10697. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10698. if (viewData.Code != 0)
  10699. {
  10700. return Ok(JsonView(false, viewData.Msg));
  10701. }
  10702. return Ok(JsonView(true));
  10703. }
  10704. /// <summary>
  10705. /// 接团客户名单
  10706. /// AddMultiple(添加多个)
  10707. /// </summary>
  10708. /// <param name="_dto"></param>
  10709. /// <returns></returns>
  10710. [HttpPost]
  10711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10712. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10713. {
  10714. #region 参数验证
  10715. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10716. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10717. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10718. #region 页面操作权限验证
  10719. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10720. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10721. #endregion
  10722. #endregion
  10723. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10724. if (viewData.Code != 0)
  10725. {
  10726. return Ok(JsonView(false, viewData.Msg));
  10727. }
  10728. return Ok(JsonView(true));
  10729. }
  10730. /// <summary>
  10731. /// 接团客户名单
  10732. /// Del
  10733. /// </summary>
  10734. /// <param name="_dto"></param>
  10735. /// <returns></returns>
  10736. [HttpPost]
  10737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10738. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10739. {
  10740. #region 参数验证
  10741. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10742. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10743. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10744. #region 页面操作权限验证
  10745. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10746. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10747. #endregion
  10748. #endregion
  10749. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10750. if (viewData.Code != 0)
  10751. {
  10752. return Ok(JsonView(false, viewData.Msg));
  10753. }
  10754. return Ok(JsonView(true));
  10755. }
  10756. /// <summary>
  10757. /// 接团客户名单
  10758. /// 文件下载 客户名单
  10759. /// </summary>
  10760. /// <param name="_dto"></param>
  10761. /// <returns></returns>
  10762. [HttpPost]
  10763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10764. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10765. {
  10766. #region 参数验证
  10767. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10768. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10769. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10770. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10771. #region 页面操作权限验证
  10772. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10773. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10774. #endregion
  10775. #endregion
  10776. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10777. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10778. From Grp_TourClientList tcl
  10779. Left Join
  10780. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10781. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10782. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10783. From Crm_DeleClient dc
  10784. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10785. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10786. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10787. Where dc.IsDel = 0) temp
  10788. On temp.DcId =tcl.ClientId
  10789. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10790. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10791. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10792. //载入模板
  10793. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10794. if (_dto.Language == 1)
  10795. {
  10796. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10797. }
  10798. //载入模板
  10799. var doc = new Document(tempPath);
  10800. DocumentBuilder builder = new DocumentBuilder(doc);
  10801. //获取word里所有表格
  10802. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10803. //获取所填表格的序数
  10804. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10805. var rowStart = tableOne.Rows[0]; //获取第1行
  10806. if (_dto.Language == 0)
  10807. {
  10808. //循环赋值
  10809. for (int i = 0; i < DcList.Count; i++)
  10810. {
  10811. builder.MoveToCell(0, i + 1, 0, 0);
  10812. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10813. builder.MoveToCell(0, i + 1, 1, 0);
  10814. int sex = DcList[i].Sex;
  10815. string sexStr = string.Empty;
  10816. if (sex == 0) sexStr = "男";
  10817. else if (sex == 1) sexStr = "女";
  10818. else sexStr = "未设置";
  10819. builder.Write(sexStr);
  10820. builder.MoveToCell(0, i + 1, 2, 0);
  10821. string birthDay = DcList[i].BirthDay;
  10822. string birthDayStr = string.Empty;
  10823. if (!string.IsNullOrEmpty(birthDay))
  10824. {
  10825. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10826. }
  10827. builder.Write(birthDayStr);
  10828. builder.MoveToCell(0, i + 1, 3, 0);
  10829. string company = "";
  10830. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10831. {
  10832. company = DcList[i].CompanyFullName.ToString();
  10833. }
  10834. builder.Write(company);
  10835. builder.MoveToCell(0, i + 1, 4, 0);
  10836. builder.Write(DcList[i].Job);
  10837. }
  10838. }
  10839. else if (_dto.Language == 1)
  10840. {
  10841. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10842. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10843. List<string> transArrayStr = new List<string>();
  10844. string transStrRes1 = "";
  10845. for (int i = 0; i < DcList.Count; i++)
  10846. {
  10847. var dc = DcList[i];
  10848. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  10849. if (dc.Job.Equals("暂无")) dc.Job = "-";
  10850. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  10851. if (DcList.Count - 1 == i) transStrRes1 += str1;
  10852. else transStrRes1 += $"{str1}|";
  10853. }
  10854. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  10855. string transStrRes = "";
  10856. if (transStrRes1.Length > 0 )
  10857. {
  10858. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  10859. }
  10860. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  10861. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  10862. //List<string> transArray = new List<string> { };
  10863. List<TranslateInfo> transArray = new List<TranslateInfo>();
  10864. if (transStrRes.Contains("|"))
  10865. {
  10866. string[] transArray1 = transStrRes.Split('|');
  10867. if (transArray1.Length > 0)
  10868. {
  10869. foreach (var item in transArray1)
  10870. {
  10871. if (item.Contains("&"))
  10872. {
  10873. string[] transArray2 = item.Split('&');
  10874. int index = 0;
  10875. string companyName = "", job = "";
  10876. if (transArray2.Length > 0)
  10877. {
  10878. bool success = int.TryParse(transArray2[0].Trim(), out index);
  10879. if (1 < transArray2.Length) companyName = transArray2[1];
  10880. if (2 < transArray2.Length) job = transArray2[2];
  10881. }
  10882. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  10883. }
  10884. }
  10885. }
  10886. }
  10887. //循环赋值
  10888. for (int i = 0; i < DcList.Count; i++)
  10889. {
  10890. string PYName = "";
  10891. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10892. {
  10893. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10894. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10895. PYName = PY_First + " " + PY_Last;
  10896. }
  10897. else
  10898. {
  10899. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10900. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10901. PYName = PY_First + " " + PY_Last;
  10902. }
  10903. builder.MoveToCell(0, i + 1, 0, 0);
  10904. builder.Write(PYName);
  10905. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10906. builder.MoveToCell(0, i + 1, 1, 0);
  10907. builder.Write(sex);
  10908. DateTime birthDt;
  10909. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10910. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  10911. builder.MoveToCell(0, i + 1, 2, 0);
  10912. builder.Write(birthday);
  10913. string company = string.Empty,job = string.Empty;
  10914. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  10915. if (dcTransInfo != null)
  10916. {
  10917. company = dcTransInfo.CompanyName;
  10918. job = dcTransInfo.Job;
  10919. }
  10920. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10921. {
  10922. //查询对照表
  10923. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10924. if (tempCec != null)
  10925. {
  10926. company = tempCec.enName;
  10927. }
  10928. //翻译
  10929. else
  10930. {
  10931. }
  10932. }
  10933. builder.MoveToCell(0, i + 1, 3, 0);
  10934. builder.Write(company);
  10935. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10936. {
  10937. //查询对照表
  10938. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10939. if (tempPec != null)
  10940. {
  10941. job = tempPec.enName;
  10942. }
  10943. //翻译
  10944. else
  10945. {
  10946. }
  10947. }
  10948. builder.MoveToCell(0, i + 1, 4, 0);
  10949. builder.Write(job);
  10950. }
  10951. }
  10952. //删除多余行
  10953. while (tableOne.Rows.Count > DcList.Count + 1)
  10954. {
  10955. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10956. }
  10957. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10958. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10959. doc.Save(fileDir);
  10960. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10961. return Ok(JsonView(true, "操作成功!", Url));
  10962. }
  10963. private class TranslateInfo
  10964. {
  10965. public int Index { get; set; }
  10966. public string CompanyName { get; set; }
  10967. public string Job { get; set; }
  10968. }
  10969. #endregion
  10970. #region 团组倒推表
  10971. /// <summary>
  10972. /// 倒推表基础数据
  10973. /// Init
  10974. /// </summary>
  10975. /// <param name="dto"></param>
  10976. /// <returns></returns>
  10977. [HttpPost]
  10978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10979. public async Task<IActionResult> PostInvertedListInit()
  10980. {
  10981. var viewData = await _invertedListRep._Init();
  10982. if (viewData.Code != 0)
  10983. {
  10984. return Ok(JsonView(false, viewData.Msg));
  10985. }
  10986. return Ok(JsonView(viewData.Data));
  10987. }
  10988. /// <summary>
  10989. /// 倒推表
  10990. /// Info
  10991. /// </summary>
  10992. /// <param name="dto"></param>
  10993. /// <returns></returns>
  10994. [HttpPost]
  10995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10996. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10997. {
  10998. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10999. if (viewData.Code != 0)
  11000. {
  11001. return Ok(JsonView(false, viewData.Msg));
  11002. }
  11003. return Ok(JsonView(viewData.Data));
  11004. }
  11005. /// <summary>
  11006. /// 倒推表
  11007. /// Create
  11008. /// </summary>
  11009. /// <param name="dto"></param>
  11010. /// <returns></returns>
  11011. [HttpPost]
  11012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11013. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  11014. {
  11015. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  11016. if (viewData.Code != 0)
  11017. {
  11018. return Ok(JsonView(false, viewData.Msg));
  11019. }
  11020. return Ok(JsonView(viewData.Data));
  11021. }
  11022. /// <summary>
  11023. /// 倒推表
  11024. /// Update
  11025. /// </summary>
  11026. /// <param name="dto"></param>
  11027. /// <returns></returns>
  11028. [HttpPost]
  11029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11030. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  11031. {
  11032. var viewData = await _invertedListRep._Update(dto);
  11033. if (viewData.Code != 0)
  11034. {
  11035. return Ok(JsonView(false, viewData.Msg));
  11036. }
  11037. return Ok(JsonView(viewData.Data));
  11038. }
  11039. /// <summary>
  11040. /// 倒推表
  11041. /// File Download
  11042. /// </summary>
  11043. /// <param name="dto"></param>
  11044. /// <returns></returns>
  11045. [HttpPost]
  11046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11047. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  11048. {
  11049. var info2 = await _invertedListRep._Info(1, dto.DiId);
  11050. if (info2.Code != 0)
  11051. {
  11052. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  11053. }
  11054. var info1 = info2.Data as InvertedListInfoView;
  11055. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  11056. string teamName = "";
  11057. if (info != null) teamName = info.TeamName;
  11058. //载入模板
  11059. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  11060. DocumentBuilder builder = new DocumentBuilder(doc);
  11061. //利用键值对存放数据
  11062. Dictionary<string, string> dic = new Dictionary<string, string>();
  11063. dic.Add("TeamName", teamName);
  11064. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  11065. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  11066. dic.Add("BPRemark", info1.ApprovalDataRemark);
  11067. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  11068. dic.Add("SQRemark", info1.ApprovalRemark);
  11069. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  11070. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  11071. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  11072. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  11073. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  11074. dic.Add("QZRemark", info1.VisaInformationRemark);
  11075. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  11076. dic.Add("SQQZRemark", info1.SendVisaRemark);
  11077. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  11078. dic.Add("CQRemark", info1.IssueVisaRemark);
  11079. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  11080. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  11081. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  11082. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  11083. #region 填充word模板书签内容
  11084. foreach (var key in dic.Keys)
  11085. {
  11086. builder.MoveToBookmark(key);
  11087. builder.Write(dic[key]);
  11088. }
  11089. #endregion
  11090. var fileDir = AppSettingsHelper.Get("WordBasePath");
  11091. string fileName = $"{teamName}团出行准备流程表.doc";
  11092. string filePath = fileDir + $@"InvertedList/{fileName}";
  11093. doc.Save(filePath);
  11094. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  11095. return Ok(JsonView(true, "操作成功!", Url));
  11096. }
  11097. #endregion
  11098. #region 三公签证费用(签证费、代办费)
  11099. /// <summary>
  11100. /// 三公签证费用(签证费、代办费)
  11101. /// List
  11102. /// </summary>
  11103. /// <returns></returns>
  11104. [HttpPost]
  11105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11106. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  11107. {
  11108. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  11109. if (_view.Code != 0)
  11110. {
  11111. return Ok(JsonView(false, _view.Msg));
  11112. }
  11113. return Ok(JsonView(true, "操作成功!", _view.Data));
  11114. }
  11115. /// <summary>
  11116. /// 三公签证费用(签证费、代办费)
  11117. /// Add Or Update
  11118. /// </summary>
  11119. /// <returns></returns>
  11120. [HttpPost]
  11121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11122. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  11123. {
  11124. var _view = await _visaFeeInfoRep._Update(_dto);
  11125. if (_view.Code != 0)
  11126. {
  11127. return Ok(JsonView(false, _view.Msg));
  11128. }
  11129. return Ok(JsonView(true, _view.Msg));
  11130. }
  11131. #endregion
  11132. #region 酒店询价
  11133. /// <summary>
  11134. /// 酒店询价
  11135. /// Init
  11136. /// </summary>
  11137. /// <param name="dto"></param>
  11138. /// <returns></returns>
  11139. [HttpPost]
  11140. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11141. public async Task<IActionResult> PostHotelInquiryInit()
  11142. {
  11143. var res = await _hotelInquiryRep._Init();
  11144. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11145. return Ok(JsonView(true, res.Msg, res.Data));
  11146. }
  11147. /// <summary>
  11148. /// 酒店询价
  11149. /// page Item
  11150. /// </summary>
  11151. /// <param name="_dto"></param>
  11152. /// <returns></returns>
  11153. [HttpPost]
  11154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11155. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  11156. {
  11157. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  11158. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11159. var view = res.Data as PageDataViewBase;
  11160. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  11161. }
  11162. /// <summary>
  11163. /// 酒店询价
  11164. /// info
  11165. /// </summary>
  11166. /// <param name="_dto"></param>
  11167. /// <returns></returns>
  11168. [HttpPost]
  11169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11170. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  11171. {
  11172. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  11173. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11174. return Ok(JsonView(true, res.Msg, res.Data));
  11175. }
  11176. /// <summary>
  11177. /// 酒店询价
  11178. /// Add Or Edit
  11179. /// </summary>
  11180. /// <param name="_dto"></param>
  11181. /// <returns></returns>
  11182. [HttpPost]
  11183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11184. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  11185. {
  11186. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  11187. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11188. return Ok(JsonView(true, res.Msg, res.Data));
  11189. }
  11190. /// <summary>
  11191. /// 酒店询价
  11192. /// Del
  11193. /// </summary>
  11194. /// <param name="_dto"></param>
  11195. /// <returns></returns>
  11196. [HttpPost]
  11197. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11198. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  11199. {
  11200. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  11201. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  11202. return Ok(JsonView(true, res.Msg, res.Data));
  11203. }
  11204. #endregion
  11205. #region 下载匹配op行程单
  11206. /// <summary>
  11207. /// 匹配op行程单
  11208. /// Init
  11209. /// </summary>
  11210. /// <param name="dto">团组列表请求dto</param>
  11211. /// <returns></returns>
  11212. [HttpPost]
  11213. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11214. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  11215. {
  11216. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11217. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11218. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  11219. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  11220. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  11221. .Where(it => it.IsDel == 0)
  11222. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  11223. .OrderByDescending(it => it.CreateUserId)
  11224. .ToList();
  11225. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  11226. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11227. var diids = groupInfos.Select(it => it.Id).ToList();
  11228. List<string> countrys = new List<string>();
  11229. foreach (var item in country)
  11230. {
  11231. var data = _groupRepository.FormartTeamName(item);
  11232. var dataArray = _groupRepository.GroupSplitCountry(data);
  11233. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11234. }
  11235. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  11236. List<string> areaArray = new List<string>(); //GetGroupCityLine
  11237. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  11238. foreach (var item in areaItem)
  11239. {
  11240. string areaStr = item.Value;
  11241. if (!string.IsNullOrEmpty(areaStr))
  11242. {
  11243. string[] str1 = areaStr.Split("-");
  11244. if (str1.Length > 0)
  11245. {
  11246. areaArray.AddRange(str1);
  11247. }
  11248. }
  11249. }
  11250. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  11251. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  11252. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  11253. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  11254. .ToList();
  11255. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  11256. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  11257. .Where(it => countriesIds.Contains(it.Id))
  11258. .Select(it => new { it.Id, Name = it.Name_CN })
  11259. .ToList();
  11260. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  11261. .Select(it => it.TeamName).ToList();
  11262. stopwatch.Stop();
  11263. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  11264. }
  11265. ///// <summary>
  11266. ///// 匹配op行程单
  11267. ///// Init 查询区域数据
  11268. ///// </summary>
  11269. ///// <param name="dto">团组列表请求dto</param>
  11270. ///// <returns></returns>
  11271. //[HttpPost]
  11272. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11273. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  11274. //{
  11275. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  11276. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  11277. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  11278. // if (string.IsNullOrEmpty(countriesDataStr))
  11279. // {
  11280. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  11281. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  11282. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  11283. // }
  11284. // else
  11285. // {
  11286. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  11287. // }
  11288. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  11289. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  11290. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  11291. // List<dynamic> childList = new List<dynamic>();
  11292. // int parentId = dto.CountriesId;
  11293. // if (provinceData.Count > 1)
  11294. // {
  11295. // foreach (var item1 in provinceData)
  11296. // {
  11297. // List<dynamic> childList1 = new List<dynamic>();
  11298. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  11299. // foreach (var item2 in citiesData1)
  11300. // {
  11301. // List<dynamic> childList2 = new List<dynamic>();
  11302. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11303. // foreach (var item3 in countiesData1)
  11304. // {
  11305. // childList2.Add(new
  11306. // {
  11307. // id = item3.Id,
  11308. // parentId = item2.Id,
  11309. // level = "district",
  11310. // name = item3.Name_CN,
  11311. // });
  11312. // }
  11313. // childList1.Add(new
  11314. // {
  11315. // id = item2.Id,
  11316. // parentId = item1.Id,
  11317. // level = "city",
  11318. // name = item2.Name_CN,
  11319. // childList = childList2
  11320. // });
  11321. // }
  11322. // childList.Add(new
  11323. // {
  11324. // id = item1.Id,
  11325. // parentId = parentId,
  11326. // level = "province",
  11327. // name = item1.Name_CN,
  11328. // childList = childList1
  11329. // });
  11330. // }
  11331. // //城市
  11332. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  11333. // foreach (var item2 in citiesData2)
  11334. // {
  11335. // List<dynamic> childList22 = new List<dynamic>();
  11336. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11337. // foreach (var item3 in countiesData1)
  11338. // {
  11339. // childList22.Add(new
  11340. // {
  11341. // id = item3.Id,
  11342. // parentId = item2.Id,
  11343. // level = "district",
  11344. // name = item3.Name_CN,
  11345. // });
  11346. // }
  11347. // childList.Add(new
  11348. // {
  11349. // id = item2.Id,
  11350. // parentId = parentId,
  11351. // level = "city",
  11352. // name = item2.Name_CN,
  11353. // childList = childList22
  11354. // });
  11355. // }
  11356. // }
  11357. // else
  11358. // {
  11359. // foreach (var item2 in citiesData)
  11360. // {
  11361. // string cname = item2.Name_CN;
  11362. // List<dynamic> childList1 = new List<dynamic>();
  11363. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  11364. // foreach (var item3 in countiesData1)
  11365. // {
  11366. // childList1.Add(new
  11367. // {
  11368. // Id = item3.Id,
  11369. // parentId = item2.Id,
  11370. // level = "district",
  11371. // name = item3.Name_CN
  11372. // });
  11373. // }
  11374. // childList.Add(new
  11375. // {
  11376. // id = item2.Id,
  11377. // parentId = parentId,
  11378. // level = "city",
  11379. // name = item2.Name_CN,
  11380. // childList = childList1
  11381. // });
  11382. // }
  11383. // }
  11384. // stopwatch.Stop();
  11385. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  11386. //}
  11387. /// <summary>
  11388. /// 匹配op行程单
  11389. /// 接团信息列表 Page
  11390. /// </summary>
  11391. /// <param name="dto">团组列表请求dto</param>
  11392. /// <returns></returns>
  11393. [HttpPost]
  11394. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11395. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  11396. {
  11397. var swatch = new Stopwatch();
  11398. swatch.Start();
  11399. #region 参数验证
  11400. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11401. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11402. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11403. #region 页面操作权限验证
  11404. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11405. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  11406. #endregion
  11407. #endregion
  11408. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11409. {
  11410. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  11411. string sqlWhere = "";
  11412. if (!string.IsNullOrEmpty(dto.Country))
  11413. {
  11414. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  11415. }
  11416. if (!string.IsNullOrEmpty(dto.Area))
  11417. {
  11418. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  11419. }
  11420. if (!string.IsNullOrEmpty(dto.TeamName))
  11421. {
  11422. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  11423. }
  11424. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  11425. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  11426. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  11427. swatch.Stop();
  11428. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  11429. }
  11430. else
  11431. {
  11432. return Ok(JsonView(false, "查询失败"));
  11433. }
  11434. }
  11435. /// <summary>
  11436. /// 匹配op行程单
  11437. /// 行程单下载
  11438. /// </summary>
  11439. /// <param name="dto">团组列表请求dto</param>
  11440. /// <returns></returns>
  11441. [HttpPost]
  11442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11443. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  11444. {
  11445. #region 参数验证
  11446. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  11447. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  11448. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  11449. #region 页面操作权限验证
  11450. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  11451. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  11452. #endregion
  11453. #endregion
  11454. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  11455. {
  11456. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  11457. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  11458. }
  11459. else
  11460. {
  11461. return Ok(JsonView(false, "下载失败!"));
  11462. }
  11463. }
  11464. #endregion
  11465. #region 国家信息 数据 注释
  11466. //[HttpPost]
  11467. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  11468. //{
  11469. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  11470. // foreach (var item in dto)
  11471. // {
  11472. // infos.Add(new Grp_GroupsTaskAssignment()
  11473. // {
  11474. // DIId = item,
  11475. // CTId = 82,
  11476. // UId = 248,
  11477. // IsEnable = 1,
  11478. // CreateUserId = 233,
  11479. // CreateTime = DateTime.Now,
  11480. // IsDel = 0
  11481. // });
  11482. // infos.Add(new Grp_GroupsTaskAssignment()
  11483. // {
  11484. // DIId = item,
  11485. // CTId = 82,
  11486. // UId = 286,
  11487. // IsEnable = 1,
  11488. // CreateUserId = 233,
  11489. // CreateTime = DateTime.Now,
  11490. // IsDel = 0
  11491. // });
  11492. // }
  11493. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  11494. // return Ok("操作成功");
  11495. //}
  11496. //public class paramJsonDto
  11497. //{
  11498. // public List<CountriesInfo> str { get; set; }
  11499. //}
  11500. //[HttpPost]
  11501. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  11502. //{
  11503. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  11504. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  11505. // List<Sys_Cities> cities = new List<Sys_Cities>();
  11506. // List<Sys_Cities> districts = new List<Sys_Cities>();
  11507. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11508. // _sqlSugar.BeginTran();
  11509. // int countitiesIndex = 0;
  11510. // foreach (var item in dto.str)
  11511. // {
  11512. // dynamic data = item.c;
  11513. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  11514. // if (data != null)
  11515. // {
  11516. // countitiesIndex++;
  11517. // foreach (var item1 in data)
  11518. // {
  11519. // string cnname = item1.cn;
  11520. // string enname = item1.en;
  11521. // Sys_Cities provinceInfo = new Sys_Cities()
  11522. // {
  11523. // CountriesId = countriesId,
  11524. // Name_CN = cnname,
  11525. // Name_EN = enname,
  11526. // ParentId = 0,
  11527. // IsCapital = 1,
  11528. // CreateUserId = 208,
  11529. // CreateTime = DateTime.Now,
  11530. // IsDel = 0
  11531. // };
  11532. // if (item1.lv == "province") //省份
  11533. // {
  11534. // provinceInfo.Level = 1;
  11535. // int provinceId = 0;
  11536. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  11537. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  11538. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11539. // var data1 = item1.c;
  11540. // foreach (var item2 in data1)
  11541. // {
  11542. // if (item2.lv == "city")
  11543. // {
  11544. // string citycnname = item2.cn;
  11545. // string cityenname = item2.en;
  11546. // Sys_Cities cityInfo = new Sys_Cities()
  11547. // {
  11548. // CountriesId = countriesId,
  11549. // ParentId = provinceId,
  11550. // Level = 2,
  11551. // Name_CN = citycnname,
  11552. // Name_EN = cityenname,
  11553. // IsCapital = 1,
  11554. // CreateUserId = 208,
  11555. // CreateTime = DateTime.Now,
  11556. // IsDel = 0
  11557. // };
  11558. // if (item2.c != null)
  11559. // {
  11560. // int cityId = 0;
  11561. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  11562. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11563. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  11564. // foreach (var item3 in item2.c)
  11565. // {
  11566. // if (item3.lv == "district")
  11567. // {
  11568. // var districtInfo = new Sys_Cities()
  11569. // {
  11570. // CountriesId = countriesId,
  11571. // Name_CN = item3.cn,
  11572. // Name_EN = item3.en,
  11573. // Level = 3,
  11574. // ParentId = cityId,
  11575. // IsCapital = 1,
  11576. // CreateUserId = 208,
  11577. // CreateTime = DateTime.Now,
  11578. // IsDel = 0
  11579. // };
  11580. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11581. // //{
  11582. // districts.Add(districtInfo);
  11583. // //}
  11584. // }
  11585. // }
  11586. // }
  11587. // else
  11588. // {
  11589. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  11590. // //{
  11591. // cities.Add(cityInfo);
  11592. // //}
  11593. // }
  11594. // }
  11595. // }
  11596. // }
  11597. // else if (item1.lv == "city")//城市
  11598. // {
  11599. // provinceInfo.Level = 2;
  11600. // if (item1.c != null)
  11601. // {
  11602. // int cityId = 0;
  11603. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  11604. // if (citiesInfo != null) cityId = citiesInfo.Id;
  11605. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  11606. // foreach (var item3 in item1.c)
  11607. // {
  11608. // if (item3.lv == "district")
  11609. // {
  11610. // var districtInfo = new Sys_Cities()
  11611. // {
  11612. // CountriesId = countriesId,
  11613. // Name_CN = item3.cn,
  11614. // Name_EN = item3.en,
  11615. // Level = 3,
  11616. // ParentId = cityId,
  11617. // IsCapital = 1,
  11618. // CreateUserId = 208,
  11619. // CreateTime = DateTime.Now,
  11620. // IsDel = 0
  11621. // };
  11622. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11623. // //{
  11624. // districts.Add(districtInfo);
  11625. // //}
  11626. // }
  11627. // }
  11628. // }
  11629. // else
  11630. // {
  11631. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11632. // //{
  11633. // cities.Add(provinceInfo);
  11634. // //}
  11635. // }
  11636. // }
  11637. // }
  11638. // }
  11639. // }
  11640. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11641. // cities = cities.Distinct().ToList();
  11642. // districts = districts.Distinct().ToList();
  11643. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11644. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11645. // cities.AddRange(districts);
  11646. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11647. // //_sqlSugar.RollbackTran();
  11648. // _sqlSugar.CommitTran();
  11649. // return Ok(JsonView(false, "操作成功!"));
  11650. //}
  11651. //[HttpPost]
  11652. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11653. //{
  11654. // List<CountitiesInfo> infos = dto.MyProperty;
  11655. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11656. // _sqlSugar.BeginTran();
  11657. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11658. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11659. // foreach (var item in infos)
  11660. // {
  11661. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11662. // if (countryInfo != null)
  11663. // {
  11664. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11665. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11666. // if (cityInfo1 != null)
  11667. // {
  11668. // cityInfo1.IsCapital = 0;
  11669. // cityInfos.Add(cityInfo1);
  11670. // }
  11671. // }
  11672. // }
  11673. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11674. // .UpdateColumns(it => it.IsCapital)
  11675. // .WhereColumns(it => it.Id)
  11676. // .ExecuteCommand();
  11677. // //_sqlSugar.RollbackTran();
  11678. // _sqlSugar.CommitTran();
  11679. // return Ok(JsonView(false, "操作成功!"));
  11680. //}
  11681. //public class CounrtiesDto
  11682. //{
  11683. // public List<CountitiesInfo> MyProperty { get; set; }
  11684. //}
  11685. //public class CountitiesInfo
  11686. //{
  11687. // /// <summary>
  11688. // /// 圣约翰
  11689. // /// </summary>
  11690. // public string capital_name_chinese { get; set; }
  11691. // /// <summary>
  11692. // ///
  11693. // /// </summary>
  11694. // public string capital_name { get; set; }
  11695. // /// <summary>
  11696. // ///
  11697. // /// </summary>
  11698. // public string country_type { get; set; }
  11699. // /// <summary>
  11700. // /// 安提瓜和巴布达
  11701. // /// </summary>
  11702. // public string country_name_chinese { get; set; }
  11703. // /// <summary>
  11704. // /// 安提瓜和巴布达
  11705. // /// </summary>
  11706. // public string country_name_chinese_short { get; set; }
  11707. // /// <summary>
  11708. // /// 安提瓜和巴布达
  11709. // /// </summary>
  11710. // public string country_name_chinese_UN { get; set; }
  11711. // /// <summary>
  11712. // ///
  11713. // /// </summary>
  11714. // public string country_name_english_abbreviation { get; set; }
  11715. // /// <summary>
  11716. // ///
  11717. // /// </summary>
  11718. // public string country_name_english_formal { get; set; }
  11719. // /// <summary>
  11720. // ///
  11721. // /// </summary>
  11722. // public string country_name_english_UN { get; set; }
  11723. // /// <summary>
  11724. // ///
  11725. // /// </summary>
  11726. // public string continent_name { get; set; }
  11727. // /// <summary>
  11728. // ///
  11729. // /// </summary>
  11730. // public string subregion_name { get; set; }
  11731. // /// <summary>
  11732. // ///
  11733. // /// </summary>
  11734. // public string country_code2 { get; set; }
  11735. // /// <summary>
  11736. // ///
  11737. // /// </summary>
  11738. // public string country_code3 { get; set; }
  11739. // /// <summary>
  11740. // ///
  11741. // /// </summary>
  11742. // public string phone_code { get; set; }
  11743. //}
  11744. //public class CountriesInfo : BasicInfo
  11745. //{
  11746. // public List<CitiesInfo> c { get; set; }
  11747. //}
  11748. //public class CitiesInfo : BasicInfo
  11749. //{
  11750. // public List<AreaInfo> c { get; set; }
  11751. //}
  11752. //public class AreaInfo : BasicInfo
  11753. //{
  11754. // public List<AreaInfo> c { get; set; }
  11755. //}
  11756. //public class BasicInfo
  11757. //{
  11758. // public string code { get; set; }
  11759. // public string cn { get; set; }
  11760. // public string lv { get; set; }
  11761. // public string en { get; set; }
  11762. //}
  11763. #endregion
  11764. #region 查看邀请方
  11765. /// <summary>
  11766. /// 查看邀请方
  11767. /// 邀请方信息 Init
  11768. /// </summary>
  11769. /// <param name="dto"></param>
  11770. /// <returns></returns>
  11771. [HttpPost]
  11772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11773. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  11774. {
  11775. string sqlWhere = string.Empty;
  11776. if (!string.IsNullOrEmpty(dto.Search))
  11777. {
  11778. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  11779. }
  11780. string sql = string.Format($@"Select
  11781. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  11782. Id,
  11783. UnitName
  11784. From Res_InvitationOfficialActivityData
  11785. Where IsDel = 0
  11786. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  11787. RefAsync<int> total = 0;
  11788. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11789. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  11790. }
  11791. /// <summary>
  11792. /// 查看邀请方
  11793. /// 国家信息 Init
  11794. /// </summary>
  11795. /// <param name="dto"></param>
  11796. /// <returns></returns>
  11797. [HttpPost]
  11798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11799. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  11800. {
  11801. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  11802. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  11803. var diids = groupInfos.Select(it => it.Id).ToList();
  11804. List<string> countrys = new List<string>();
  11805. foreach (var item in country)
  11806. {
  11807. var data = _groupRepository.FormartTeamName(item);
  11808. var dataArray = _groupRepository.GroupSplitCountry(data);
  11809. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  11810. }
  11811. countrys = countrys.Distinct().ToList();
  11812. for (int i = 0; i < countrys.Count; i++)
  11813. {
  11814. string item = countrys[i];
  11815. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  11816. {
  11817. countrys.Remove(item);
  11818. i--;
  11819. }
  11820. }
  11821. RefAsync<int> total = 0;
  11822. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  11823. .Where(it => countrys.Contains(it.Name_CN))
  11824. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11825. .Select(it => new { id = it.Id, name = it.Name_CN })
  11826. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11827. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11828. }
  11829. /// <summary>
  11830. /// 查看邀请方
  11831. /// 城市信息 Init
  11832. /// </summary>
  11833. /// <param name="dto"></param>
  11834. /// <returns></returns>
  11835. [HttpPost]
  11836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11837. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  11838. {
  11839. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  11840. RefAsync<int> total = 0;
  11841. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  11842. .Where(it => it.CountriesId == dto.CountiesId)
  11843. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  11844. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  11845. .Select(it => new { id = it.Id, name = it.Name_CN })
  11846. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11847. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  11848. }
  11849. /// <summary>
  11850. /// 查看邀请方
  11851. /// 团组名称 Init
  11852. /// </summary>
  11853. /// <param name="dto"></param>
  11854. /// <returns></returns>
  11855. [HttpPost]
  11856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11857. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  11858. {
  11859. var watch = new Stopwatch();
  11860. watch.Start();
  11861. RefAsync<int> total = 0;
  11862. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  11863. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  11864. .Where((oa, di) => oa.IsDel == 0)
  11865. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  11866. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  11867. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  11868. .Distinct()
  11869. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11870. watch.Stop();
  11871. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  11872. }
  11873. /// <summary>
  11874. /// 查看邀请方
  11875. /// 团组 & 邀请方信息
  11876. /// </summary>
  11877. /// <param name="dto"></param>
  11878. /// <returns></returns>
  11879. [HttpPost]
  11880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11881. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  11882. {
  11883. var watch = new Stopwatch();
  11884. watch.Start();
  11885. RefAsync<int> total = 0;
  11886. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  11887. .AS("Grp_DelegationInfo")
  11888. .Includes(x => x.InvitingInfos)
  11889. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  11890. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  11891. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  11892. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  11893. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  11894. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  11895. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11896. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  11897. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  11898. infos.ForEach(x =>
  11899. {
  11900. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  11901. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  11902. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  11903. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  11904. });
  11905. watch.Stop();
  11906. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  11907. }
  11908. #endregion
  11909. #region 报批行程
  11910. /// <summary>
  11911. /// 报批行程初始化
  11912. /// </summary>
  11913. /// <param name="dto"></param>
  11914. /// <returns></returns>
  11915. [HttpPost]
  11916. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11917. {
  11918. const int chiNumber = 5;
  11919. var jw = JsonView(false);
  11920. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11921. var group = groupList.First();
  11922. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11923. group = groupList.First(x => x.Id == diid);
  11924. if (group == null)
  11925. {
  11926. jw.Msg = "暂无团组!";
  11927. return Ok(jw);
  11928. }
  11929. var data = new
  11930. {
  11931. groupList = groupList.Select(x => new
  11932. {
  11933. x.TeamName,
  11934. x.Id
  11935. }),
  11936. content = new ArrayList(),
  11937. groupInfo = new
  11938. {
  11939. group.VisitDays,
  11940. group.TourCode,
  11941. group.VisitPNumber,
  11942. group.TeamName,
  11943. group.Id,
  11944. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  11945. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  11946. },
  11947. };
  11948. var resultArr = new ArrayList();
  11949. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11950. if (content.Count == 0)
  11951. {
  11952. var stay = "-";
  11953. var cityPath = "-";
  11954. //添加城市路径以及住宿地
  11955. //黑屏代码数据
  11956. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11957. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11958. {
  11959. jw = JsonView(true, "黑屏代码有误!", data);
  11960. return Ok(jw);
  11961. }
  11962. foreach (DataRow row in dtBlack.Rows)
  11963. {
  11964. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11965. {
  11966. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  11967. return Ok(jw);
  11968. }
  11969. }
  11970. //黑屏代码获取时间区间
  11971. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11972. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11973. _sqlSugar.BeginTran();
  11974. for (int i = 0; i < timeArr.Count; i++)
  11975. {
  11976. stay = "-";
  11977. cityPath = "-";
  11978. DateTime NewData = DateTime.Parse(timeArr[i]);
  11979. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11980. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11981. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11982. if (tbSelect.Length > 0)
  11983. {
  11984. List<string> threeCodeStr = new List<string>();
  11985. foreach (var item in tbSelect)
  11986. {
  11987. var threeCode = item["Three"].ToString() ?? "";
  11988. if (threeCode.Length == 6)
  11989. {
  11990. var start = threeCode.Substring(0, 3);
  11991. var end = threeCode.Substring(3, 3);
  11992. if (threeCodeStr.Count == 0)
  11993. {
  11994. threeCodeStr.Add(start);
  11995. threeCodeStr.Add(end);
  11996. }
  11997. else
  11998. {
  11999. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12000. {
  12001. threeCodeStr.Add(end);
  12002. }
  12003. else
  12004. {
  12005. threeCodeStr.Add(start);
  12006. threeCodeStr.Add(end);
  12007. }
  12008. }
  12009. }
  12010. }
  12011. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12012. var last = threeCodeStr.Last();
  12013. foreach (var item in threeCodeStr)
  12014. {
  12015. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12016. if (item.Equals(last))
  12017. {
  12018. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12019. }
  12020. }
  12021. cityPath = cityPath.Trim('-');
  12022. }
  12023. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12024. appro.Diid = diid ?? -1;
  12025. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12026. appro.Id = thisId;
  12027. appro.CreateUserId = dto.UserId;
  12028. appro.CreateTime = DateTime.Now;
  12029. content.Add(appro);
  12030. }
  12031. _sqlSugar.CommitTran();
  12032. }
  12033. foreach (var x in content)
  12034. {
  12035. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  12036. if (chiList.Count < chiNumber)
  12037. {
  12038. for (int i = chiList.Count; i < chiNumber; i++)
  12039. {
  12040. chiList.Add(new Grp_ApprovalTravelDetails());
  12041. }
  12042. }
  12043. resultArr.Add(new
  12044. {
  12045. x.Id,
  12046. x.Date,
  12047. x.Diid,
  12048. chiList = chiList.Select(x1 => new
  12049. {
  12050. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12051. x1.Details,
  12052. x1.ParentId,
  12053. x1.Id
  12054. })
  12055. });
  12056. }
  12057. data = data with
  12058. {
  12059. content = resultArr,
  12060. };
  12061. jw = JsonView(true, "获取成功!", data);
  12062. return Ok(jw);
  12063. }
  12064. /// <summary>
  12065. /// 报批行程删除
  12066. /// </summary>
  12067. /// <param name="dto"></param>
  12068. /// <returns></returns>
  12069. [HttpPost]
  12070. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  12071. {
  12072. var jw = JsonView(false);
  12073. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12074. if (group == null)
  12075. {
  12076. jw.Msg = "团组参数有误!";
  12077. return Ok(jw);
  12078. }
  12079. try
  12080. {
  12081. _sqlSugar.BeginTran();
  12082. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  12083. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  12084. {
  12085. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12086. DeleteUserId = dto.uesrId,
  12087. IsDel = 1
  12088. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  12089. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  12090. {
  12091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12092. DeleteUserId = dto.uesrId,
  12093. IsDel = 1
  12094. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  12095. _sqlSugar.CommitTran();
  12096. jw = JsonView(true, "删除成功");
  12097. }
  12098. catch (Exception ex)
  12099. {
  12100. jw = JsonView(false, ex.Message);
  12101. }
  12102. return Ok(jw);
  12103. }
  12104. /// <summary>
  12105. /// 报批行程保存
  12106. /// </summary>
  12107. /// <param name="dto"></param>
  12108. /// <returns></returns>
  12109. [HttpPost]
  12110. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  12111. {
  12112. var jw = JsonView(false);
  12113. var Find = dto.Arr.Find(x => x.id == 0);
  12114. if (Find != null)
  12115. {
  12116. jw.Msg = "生成的ID为0!";
  12117. return Ok(jw);
  12118. }
  12119. foreach (var item in dto.Arr)
  12120. {
  12121. foreach (var chi in item.chiList)
  12122. {
  12123. if (chi.parentId == 0)
  12124. {
  12125. chi.parentId = item.id;
  12126. }
  12127. }
  12128. }
  12129. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  12130. _sqlSugar.BeginTran();
  12131. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  12132. {
  12133. var parentIds = dto.Arr.Select(x => x.id).ToList();
  12134. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  12135. {
  12136. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  12137. DeleteUserId = dto.UserId,
  12138. IsDel = 1
  12139. }).ExecuteCommand();
  12140. }
  12141. try
  12142. {
  12143. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  12144. {
  12145. CreateTime = DateTime.Now,
  12146. CreateUserId = dto.UserId,
  12147. Details = x.details,
  12148. ParentId = x.parentId,
  12149. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12150. Remark = "",
  12151. IsDel = 0
  12152. }).ToList()).ExecuteCommand();
  12153. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  12154. {
  12155. Id = x.id,
  12156. Details = x.details,
  12157. ParentId = x.parentId,
  12158. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  12159. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  12160. {
  12161. Details = x.Details,
  12162. ParentId = x.ParentId,
  12163. Time = x.Time
  12164. }).ExecuteCommand();
  12165. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  12166. {
  12167. Id = x.id,
  12168. Date = x.date,
  12169. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  12170. {
  12171. Date = x.Date
  12172. }).ExecuteCommand();
  12173. _sqlSugar.CommitTran();
  12174. jw = JsonView(true, "保存成功!");
  12175. }
  12176. catch (Exception ex)
  12177. {
  12178. _sqlSugar.RollbackTran();
  12179. jw = JsonView(false, "保存失败!" + ex.Message);
  12180. }
  12181. return Ok(jw);
  12182. }
  12183. /// <summary>
  12184. /// 报批行程生成
  12185. /// </summary>
  12186. /// <param name="dto"></param>
  12187. /// <returns></returns>
  12188. [HttpPost]
  12189. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  12190. {
  12191. var jw = JsonView(false);
  12192. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12193. if (group == null)
  12194. {
  12195. jw.Msg = "暂无该团组!";
  12196. return Ok(jw);
  12197. }
  12198. //黑屏代码数据
  12199. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  12200. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  12201. {
  12202. jw.Msg = "黑屏代码有误!";
  12203. return Ok(jw);
  12204. }
  12205. foreach (DataRow row in dtBlack.Rows)
  12206. {
  12207. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  12208. {
  12209. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  12210. return Ok(jw);
  12211. }
  12212. }
  12213. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  12214. var resultArr = new ArrayList();
  12215. if (officialActivitiesArr.Count == 0)
  12216. {
  12217. jw.Msg = "暂无公务出访信息!";
  12218. return Ok(jw);
  12219. }
  12220. try
  12221. {
  12222. _sqlSugar.BeginTran();
  12223. DeleteApprovalJourney(new
  12224. Domain.Dtos.Groups.DeleteApprovalJourney
  12225. {
  12226. Diid = dto.Diid,
  12227. uesrId = dto.Userid
  12228. });
  12229. var stay = "-";
  12230. var cityPath = "-";
  12231. //添加城市路径以及住宿地
  12232. //黑屏代码获取时间区间
  12233. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  12234. var empty = "【未收入该三字码!请机票同事录入】";
  12235. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  12236. for (int i = 0; i < timeArr.Count; i++)
  12237. {
  12238. stay = "-";
  12239. cityPath = "-";
  12240. var chiarr = new List<Grp_ApprovalTravelDetails>();
  12241. DateTime NewData = DateTime.Parse(timeArr[i]);
  12242. var gwinfo = officialActivitiesArr.Where(x => DateTime.TryParse(x.Date, out DateTime gwData) && gwData.ToString("yyyy-MM-dd") == NewData.ToString("yyyy-MM-dd")).OrderBy(x => x.Time).ToList();
  12243. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  12244. if (tbSelect.Length > 0)
  12245. {
  12246. List<string> threeCodeStr = new List<string>();
  12247. bool isTrade = false;
  12248. string trip = string.Empty;
  12249. var rowLast = tbSelect.Last();
  12250. var rowFirst = tbSelect.First();
  12251. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  12252. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  12253. var takeOffTime = DateTime.Parse(timeArr[i]);
  12254. var fallToTime = DateTime.Parse(timeArr[i]);
  12255. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  12256. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  12257. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  12258. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  12259. foreach (var item in tbSelect)
  12260. {
  12261. var start = string.Empty;
  12262. var end = string.Empty;
  12263. var threeCode = item["Three"].ToString() ?? "";
  12264. if (threeCode.Length == 6)
  12265. {
  12266. start = threeCode.Substring(0, 3);
  12267. end = threeCode.Substring(3, 3);
  12268. if (threeCodeStr.Count == 0)
  12269. {
  12270. threeCodeStr.Add(start);
  12271. threeCodeStr.Add(end);
  12272. }
  12273. else
  12274. {
  12275. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  12276. {
  12277. threeCodeStr.Add(end);
  12278. }
  12279. else
  12280. {
  12281. threeCodeStr.Add(start);
  12282. threeCodeStr.Add(end);
  12283. }
  12284. }
  12285. }
  12286. //处理机票信息
  12287. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  12288. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  12289. if (start_Object == null)
  12290. {
  12291. start_Object = new Res_ThreeCode()
  12292. {
  12293. AirPort = empty,
  12294. AirPort_En = empty,
  12295. City = empty,
  12296. Country = empty,
  12297. Four = empty,
  12298. Three = empty,
  12299. };
  12300. }
  12301. if (end_Object == null)
  12302. {
  12303. end_Object = new Res_ThreeCode()
  12304. {
  12305. AirPort = empty,
  12306. AirPort_En = empty,
  12307. City = empty,
  12308. Country = empty,
  12309. Four = empty,
  12310. Three = empty,
  12311. };
  12312. }
  12313. //机型判断
  12314. string airModel = item["AirModel"].ToString();
  12315. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  12316. string flightTime = item["FlightTime"].ToString();
  12317. if (flightTime!.Contains(":"))
  12318. {
  12319. flightTime = flightTime.Replace(":", "小时");
  12320. flightTime += "分钟";
  12321. }
  12322. if (flightTime.Contains("H"))
  12323. {
  12324. flightTime = flightTime.Replace("H", "小时");
  12325. }
  12326. if (flightTime.Contains("M"))
  12327. {
  12328. flightTime = flightTime.Replace("M", "分钟");
  12329. }
  12330. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  12331. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  12332. {
  12333. flightTime = flightDataTime.Hour > 0
  12334. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  12335. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  12336. ? flightDataTime.Minute.ToString() + "分钟" : "";
  12337. }
  12338. //航班号
  12339. string flightcode = item["Fliagtcode"].ToString();
  12340. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  12341. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  12342. if (aircompany == null)
  12343. {
  12344. aircompany = new Res_AirCompany
  12345. {
  12346. CnName = hsEmpty,
  12347. EnName = hsEmpty,
  12348. ShortCode = hsEmpty,
  12349. };
  12350. }
  12351. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  12352. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  12353. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  12354. if (isTrade)
  12355. {
  12356. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  12357. }
  12358. else
  12359. {
  12360. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  12361. }
  12362. }
  12363. chiarr.Add(new Grp_ApprovalTravelDetails
  12364. {
  12365. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  12366. CreateTime = DateTime.Now,
  12367. CreateUserId = dto.Userid,
  12368. ParentId = 0,
  12369. Details = trip
  12370. });
  12371. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  12372. var last = threeCodeStr.Last();
  12373. foreach (var item in threeCodeStr)
  12374. {
  12375. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  12376. if (item.Equals(last))
  12377. {
  12378. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  12379. }
  12380. }
  12381. cityPath = cityPath.Trim('-');
  12382. }
  12383. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  12384. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  12385. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  12386. appro.Diid = dto.Diid;
  12387. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  12388. appro.Id = thisId;
  12389. appro.CreateUserId = dto.Userid;
  12390. appro.CreateTime = DateTime.Now;
  12391. foreach (var item in gwinfo)
  12392. {
  12393. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  12394. chi.Details = "拜访" + item.Client;
  12395. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  12396. {
  12397. chi.Details += "," + item.ReqSample;
  12398. }
  12399. chi.ParentId = thisId;
  12400. chi.Time = item.Time;
  12401. chiarr.Add(chi);
  12402. }
  12403. if (chiarr.Count < 5)
  12404. {
  12405. for (int j = chiarr.Count; j < 5; j++)
  12406. {
  12407. chiarr.Add(new
  12408. Grp_ApprovalTravelDetails());
  12409. }
  12410. }
  12411. resultArr.Add(new
  12412. {
  12413. appro.Id,
  12414. appro.Date,
  12415. appro.Diid,
  12416. chiList = chiarr.Select(x1 => new
  12417. {
  12418. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  12419. x1.Details,
  12420. x1.ParentId,
  12421. x1.Id
  12422. })
  12423. });
  12424. }
  12425. _sqlSugar.CommitTran();
  12426. jw = JsonView(true, "生成成功!", resultArr);
  12427. }
  12428. catch (Exception ex)
  12429. {
  12430. jw.Code = 400;
  12431. jw.Msg = "生成失败!" + ex.Message;
  12432. }
  12433. return Ok(jw);
  12434. }
  12435. /// <summary>
  12436. /// 报批行程word导出
  12437. /// </summary>
  12438. /// <param name="dto"></param>
  12439. /// <returns></returns>
  12440. [HttpPost]
  12441. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  12442. {
  12443. var jw = JsonView(false);
  12444. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  12445. if (group == null)
  12446. {
  12447. jw.Msg = "暂无该团组!";
  12448. return Ok(jw);
  12449. }
  12450. //模板路径
  12451. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  12452. //载入模板
  12453. Document doc = new Document(tempPath);
  12454. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12455. //获取所填表格的序数
  12456. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  12457. Aspose.Words.Tables.Row titleRowClone = null;
  12458. Aspose.Words.Tables.Row CenterRowClone = null;
  12459. int index = 0;
  12460. int indexChi = 0;
  12461. int SetIndex = 0;
  12462. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  12463. //获取数据,放到datatable
  12464. foreach (var item in ApprovalTravelArr)
  12465. {
  12466. if (index > 0)
  12467. {
  12468. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  12469. tableOne.AppendChild(titleRowClone);
  12470. }
  12471. var textTime = item.Date;
  12472. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  12473. SetCells(tableOne, doc, SetIndex, 0, textTime);
  12474. SetIndex++;
  12475. if (ChiRep.Count > 0)
  12476. {
  12477. foreach (var itemChi in ChiRep)
  12478. {
  12479. var txtTime = itemChi.Time;
  12480. var txtDetail = itemChi.Details;
  12481. if (indexChi > 0)
  12482. {
  12483. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12484. tableOne.AppendChild(CenterRowClone);
  12485. }
  12486. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  12487. {
  12488. SetCells(tableOne, doc, SetIndex, 0, "");
  12489. SetCells(tableOne, doc, SetIndex, 1, "");
  12490. indexChi++;
  12491. SetIndex++;
  12492. break;
  12493. }
  12494. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  12495. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  12496. indexChi++;
  12497. SetIndex++;
  12498. }
  12499. }
  12500. else
  12501. {
  12502. if (indexChi > 0)
  12503. {
  12504. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  12505. tableOne.AppendChild(CenterRowClone);
  12506. }
  12507. SetCells(tableOne, doc, SetIndex, 0, "");
  12508. SetCells(tableOne, doc, SetIndex, 1, "");
  12509. indexChi++;
  12510. SetIndex++;
  12511. }
  12512. index++;
  12513. }
  12514. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  12515. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12516. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  12517. jw.Code = 200;
  12518. jw.Msg = "";
  12519. return Ok(jw);
  12520. }
  12521. private string intToString(int numberVal)
  12522. {
  12523. string numberval = numberVal.ToString();
  12524. Dictionary<char, string> Number = new Dictionary<char, string>();
  12525. Number.Add('1', "一");
  12526. Number.Add('2', "二");
  12527. Number.Add('3', "三");
  12528. Number.Add('4', "四");
  12529. Number.Add('5', "五");
  12530. Number.Add('6', "六");
  12531. Number.Add('7', "七");
  12532. Number.Add('8', "八");
  12533. Number.Add('9', "九");
  12534. string stringNumberVal = string.Empty;
  12535. for (int i = 0; i < numberval.Length; i++)
  12536. {
  12537. if (i == 0)
  12538. {
  12539. stringNumberVal += Number[numberval[i]];
  12540. }
  12541. else if (i >= 1)
  12542. {
  12543. if (numberval[i] == '0')
  12544. {
  12545. stringNumberVal = "十";
  12546. }
  12547. else
  12548. {
  12549. stringNumberVal += "十" + Number[numberval[i]];
  12550. }
  12551. }
  12552. }
  12553. return stringNumberVal;
  12554. }
  12555. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  12556. {
  12557. //获取table中的某个单元格,从0开始
  12558. Cell lshCell = table.Rows[rows].Cells[cells];
  12559. //将单元格中段落移除
  12560. foreach (Node item in lshCell.Paragraphs)
  12561. {
  12562. lshCell.Paragraphs.Remove(item);
  12563. }
  12564. if (val.Contains("\r\n"))
  12565. {
  12566. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  12567. foreach (var item in spArr)
  12568. {
  12569. //新建一个段落
  12570. Paragraph p = new Paragraph(doc);
  12571. var r = new Run(doc, item);
  12572. //把设置的值赋给之前新建的段落
  12573. p.AppendChild(r);
  12574. //将此段落加到单元格内
  12575. lshCell.AppendChild(p);
  12576. }
  12577. }
  12578. else
  12579. {
  12580. //新建一个段落
  12581. Paragraph p = new Paragraph(doc);
  12582. var r = new Run(doc, val);
  12583. //把设置的值赋给之前新建的段落
  12584. p.AppendChild(r);
  12585. //将此段落加到单元格内
  12586. lshCell.AppendChild(p);
  12587. }
  12588. }
  12589. [HttpPost]
  12590. public async Task<IActionResult> ServerHttp(string paramStr)
  12591. {
  12592. paramStr = paramStr.TrimEnd('\'');
  12593. paramStr = paramStr.TrimStart('\'');
  12594. JsonView jw = JsonView(false);
  12595. JObject param = JObject.Parse(paramStr);
  12596. if (!param.ContainsKey("url"))
  12597. {
  12598. jw.Msg = "url null";
  12599. return Ok(jw);
  12600. }
  12601. string url = param["url"]!.ToString();
  12602. var methon = "get";
  12603. Dictionary<string, string> bodyValues = null;
  12604. Dictionary<string, string> headValues = null;
  12605. if (param.ContainsKey("methon"))
  12606. {
  12607. methon = param["methon"]!.ToString();
  12608. }
  12609. if (param.ContainsKey("header"))
  12610. {
  12611. var header = param["header"]!.ToString();
  12612. JObject headerJobject = JObject.Parse(header);
  12613. headValues = new Dictionary<string, string>();
  12614. foreach (JProperty item in headerJobject.Properties())
  12615. {
  12616. var value = item.Value.ToString();
  12617. var head = item.Path;
  12618. headValues.Add(head, value);
  12619. }
  12620. }
  12621. if (param.ContainsKey("body"))
  12622. {
  12623. var body = param["body"]!.ToString();
  12624. bodyValues = new Dictionary<string, string>();
  12625. JObject bodyJobject = JObject.Parse(body);
  12626. foreach (JProperty item in bodyJobject.Properties())
  12627. {
  12628. var value = item.Value.ToString();
  12629. var head = item.Path;
  12630. bodyValues.Add(head, value);
  12631. }
  12632. }
  12633. HttpClient client = new HttpClient();
  12634. string responseString = string.Empty;
  12635. if (param.ContainsKey("isJson"))
  12636. {
  12637. }
  12638. if (headValues != null)
  12639. {
  12640. foreach (var item in headValues.Keys)
  12641. {
  12642. client.DefaultRequestHeaders.Add(item, headValues[item]);
  12643. }
  12644. }
  12645. try
  12646. {
  12647. if (methon == "get")
  12648. {
  12649. responseString = await client.GetStringAsync(url);
  12650. }
  12651. else if (methon == "post")
  12652. {
  12653. if (bodyValues == null)
  12654. {
  12655. jw.Msg = "methon post body null";
  12656. return Ok(jw);
  12657. }
  12658. // 数据转化为 key=val 格式
  12659. var content = new FormUrlEncodedContent(bodyValues);
  12660. var response = await client.PostAsync(url, content);
  12661. // 获取数据
  12662. responseString = await response.Content.ReadAsStringAsync();
  12663. }
  12664. else
  12665. {
  12666. jw.Msg = "methon error";
  12667. }
  12668. jw = JsonView(true, "success", responseString);
  12669. }
  12670. catch (Exception ex)
  12671. {
  12672. jw.Msg = "error " + ex.Message;
  12673. jw.Data = ex.StackTrace;
  12674. }
  12675. finally
  12676. {
  12677. client.Dispose();
  12678. }
  12679. return Ok(jw);
  12680. }
  12681. #endregion
  12682. // /// <summary>
  12683. // ///
  12684. // /// </summary>
  12685. // /// <param name="_dto"></param>
  12686. // /// <returns></returns>
  12687. // [HttpPost]
  12688. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12689. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12690. // {
  12691. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12692. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  12693. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  12694. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12695. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  12696. // dic_psg.Add("客人", 974);
  12697. // dic_psg.Add("司机", 975);
  12698. // dic_psg.Add("导游", 976);
  12699. // dic_psg.Add("公司内部人员", 977);
  12700. // dic_psg.Add("司机/导游/公司内部人员", 978);
  12701. // foreach (var item in list_visa)
  12702. // {
  12703. // Grp_VisaInfo temp = new Grp_VisaInfo();
  12704. // temp.Id = item.Id;
  12705. // temp.DIId = item.DIId;
  12706. // temp.VisaClient = item.VisaClient;
  12707. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  12708. // temp.VisaCurrency = item.VisaCurrency;
  12709. // temp.IsThird = item.IsThird;
  12710. // if (dic_psg.ContainsKey(item.PassengerType))
  12711. // {
  12712. // temp.PassengerType = dic_psg[item.PassengerType];
  12713. // }
  12714. // else {
  12715. // temp.PassengerType = -1;
  12716. // }
  12717. // temp.VisaNumber = item.VisaNumber;
  12718. // temp.VisaFreeNumber = item.VisaFreeNumber;
  12719. // temp.CreateUserId = item.Operators;
  12720. // DateTime dt_ct;
  12721. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  12722. // if (b_ct)
  12723. // {
  12724. // temp.CreateTime = dt_ct;
  12725. // }
  12726. // else
  12727. // {
  12728. // temp.CreateTime = DateTime.Now;
  12729. // }
  12730. // temp.DeleteTime = "";
  12731. // temp.DeleteUserId = 0;
  12732. // temp.Remark = item.Remark;
  12733. // if (string.IsNullOrEmpty(temp.Remark)) {
  12734. // temp.Remark = "";
  12735. // }
  12736. // temp.IsDel = item.IsDel;
  12737. // temp.VisaDescription = item.VisaAttachment;
  12738. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  12739. //([Id]
  12740. // ,[DIId]
  12741. // ,[VisaClient]
  12742. // ,[VisaPrice]
  12743. // ,[VisaCurrency]
  12744. // ,[IsThird]
  12745. // ,[PassengerType]
  12746. // ,[VisaNumber]
  12747. // ,[VisaFreeNumber]
  12748. // ,[CreateUserId]
  12749. // ,[CreateTime]
  12750. // ,[DeleteTime]
  12751. // ,[DeleteUserId]
  12752. // ,[Remark]
  12753. // ,[IsDel]
  12754. // ,[visaDescription])
  12755. // VALUES
  12756. // ({0},{1},'{2}',{3},{4}
  12757. //,{5},{6},{7},{8},{9}
  12758. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  12759. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  12760. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  12761. //);
  12762. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  12763. // }
  12764. // return Ok(JsonView(true, "操作成功!"));
  12765. // }
  12766. /// <summary>
  12767. /// 123132123
  12768. /// </summary>
  12769. /// <param name="_dto"></param>
  12770. /// <returns></returns>
  12771. [HttpPost]
  12772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12773. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  12774. {
  12775. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  12776. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  12777. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  12778. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  12779. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  12780. dicDetail.Add(789, 1034);
  12781. dicDetail.Add(790, 1035);
  12782. dicDetail.Add(791, 1036);
  12783. dicDetail.Add(792, 1037);
  12784. dicDetail.Add(793, 1038);
  12785. dicDetail.Add(794, 1039);
  12786. dicDetail.Add(795, 1040);
  12787. dicDetail.Add(796, 1041);
  12788. dicDetail.Add(797, 1042);
  12789. dicDetail.Add(798, 1043);
  12790. dicDetail.Add(801, 1044);
  12791. dicDetail.Add(802, 1045);
  12792. dicDetail.Add(803, 1046);
  12793. Dictionary<int, int> dic = new Dictionary<int, int>();
  12794. dic.Add(806, 1027);
  12795. dic.Add(807, 1028);
  12796. dic.Add(808, 1029);
  12797. dic.Add(809, 1030);
  12798. dic.Add(810, 1031);
  12799. dic.Add(811, 1032);
  12800. dic.Add(812, 1033);
  12801. foreach (var item in list_visa)
  12802. {
  12803. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  12804. temp.Coefficient = item.coefficient;
  12805. DateTime dtCrt;
  12806. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  12807. if (b1)
  12808. {
  12809. temp.CreateTime = dtCrt;
  12810. }
  12811. else
  12812. {
  12813. temp.CreateTime = DateTime.Now;
  12814. }
  12815. temp.CreateUserId = item.Operators;
  12816. temp.DeleteTime = "";
  12817. temp.DeleteUserId = 0;
  12818. temp.DiId = int.Parse(item.DIID);
  12819. temp.FilePath = item.FilePath;
  12820. temp.IsDel = item.IsDel;
  12821. temp.Price = item.Price;
  12822. temp.PriceCount = 1;
  12823. temp.PriceCurrency = item.Currency;
  12824. int detailId = 0;
  12825. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  12826. {
  12827. detailId = dicDetail[item.PriceTypeDetail];
  12828. }
  12829. temp.PriceDetailType = detailId;
  12830. temp.PriceDt = DateTime.Now;
  12831. temp.PriceName = item.PriceName;
  12832. temp.PriceSum = item.Price;
  12833. int tid = 0;
  12834. if (dic.ContainsKey(item.PriceType))
  12835. {
  12836. tid = dic[item.PriceType];
  12837. }
  12838. temp.PriceType = tid;
  12839. temp.Remark = item.Remark;
  12840. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  12841. }
  12842. return Ok(JsonView(true, "操作成功!"));
  12843. }
  12844. }
  12845. }