GroupsController.cs 620 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591
  1. using Aspose.Cells;
  2. using Aspose.Cells.Drawing.Texts;
  3. using Aspose.Words;
  4. using Aspose.Words.Tables;
  5. using NPOI.Util;
  6. using OASystem.API.OAMethodLib;
  7. using OASystem.API.OAMethodLib.File;
  8. using OASystem.Domain.Dtos.Groups;
  9. using OASystem.Domain.Entities.Groups;
  10. using OASystem.Domain.ViewModels.Groups;
  11. using OASystem.Infrastructure.Repositories.Groups;
  12. using TencentCloud.Ocr.V20181119.Models;
  13. using OASystem.Infrastructure.Tools;
  14. using System.Web;
  15. using System.Data;
  16. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  17. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  18. using Cell = Aspose.Words.Tables.Cell;
  19. using Row = Aspose.Words.Tables.Row;
  20. using System.Runtime.Intrinsics.Arm;
  21. using Microsoft.AspNetCore.Mvc.Filters;
  22. using OASystem.Domain.Entities.Customer;
  23. using NPOI.SS.Formula.Functions;
  24. using OASystem.Domain.Dtos.CRM;
  25. using System.Diagnostics;
  26. using MathNet.Numerics.Statistics.Mcmc;
  27. using AlibabaCloud.OpenApiClient.Models;
  28. using System;
  29. using NPOI.HPSF;
  30. using SqlSugar;
  31. using System.Collections;
  32. using Org.BouncyCastle.Ocsp;
  33. using System.Globalization;
  34. using static QRCoder.PayloadGenerator;
  35. using Bookmark = Aspose.Words.Bookmark;
  36. using Aspose.Words.Fields;
  37. using NPOI.POIFS.FileSystem;
  38. using Microsoft.AspNetCore.Mvc.ViewEngines;
  39. using OASystem.Domain.ViewModels.QiYeWeChat;
  40. using OASystem.Domain.Entities.Financial;
  41. using NPOI.POIFS.Crypt.Dsig;
  42. using System.Diagnostics.Eventing.Reader;
  43. using System.IO;
  44. using StackExchange.Redis;
  45. using Org.BouncyCastle.Utilities;
  46. using Aspose.Words.Drawing;
  47. using Aspose.Cells.Charts;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using Quartz.Util;
  50. using Google.Protobuf.WellKnownTypes;
  51. using Microsoft.AspNetCore.SignalR;
  52. using OASystem.API.OAMethodLib.Hub.HubClients;
  53. using OASystem.API.OAMethodLib.Hub.Hubs;
  54. using System.Collections.Generic;
  55. using OASystem.API.OAMethodLib.JuHeAPI;
  56. using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
  57. using SixLabors.Fonts.Tables.AdvancedTypographic;
  58. using Microsoft.EntityFrameworkCore;
  59. using System.Security.Cryptography.Xml;
  60. using MathNet.Numerics;
  61. using System.Security.Policy;
  62. using System.Xml;
  63. using OASystem.Domain.Dtos.QiYeWeChat;
  64. using static NPOI.POIFS.Crypt.CryptoFunctions;
  65. using Aspose.Words.Lists;
  66. using OASystem.API.OAMethodLib.YouDaoAPI;
  67. using NPOI.XSSF.Streaming.Values;
  68. using OASystem.API.OAMethodLib.Quartz.Business;
  69. using System.Linq;
  70. using NPOI.POIFS.NIO;
  71. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  72. using OASystem.Domain.ViewModels.Statistics;
  73. using NPOI.XSSF.Model;
  74. using NetTaste;
  75. using Microsoft.AspNetCore.Http;
  76. using EyeSoft.Collections.Generic;
  77. using NPOI.HSSF.Util;
  78. using NPOI.HSSF.UserModel;
  79. using NPOI.SS.UserModel;
  80. using NPOI.XSSF.UserModel;
  81. using MySqlX.XDevAPI.Relational;
  82. using SqlSugar.Extensions;
  83. using Table = Aspose.Words.Tables.Table;
  84. using Aspose.Cells.Tables;
  85. using NPOI.SS.Util;
  86. using RestSharp.Extensions;
  87. using Microsoft.AspNetCore.WebUtilities;
  88. using K4os.Compression.LZ4.Internal;
  89. using static Pipelines.Sockets.Unofficial.SocketConnection;
  90. using System.Diagnostics.PerformanceData;
  91. using System.Drawing.Printing;
  92. using OASystem.Domain.Dtos.FileDto;
  93. using Microsoft.VisualBasic;
  94. namespace OASystem.API.Controllers
  95. {
  96. /// <summary>
  97. /// 团组相关
  98. /// </summary>
  99. //[Authorize]
  100. [Route("api/[controller]/[action]")]
  101. public class GroupsController : ControllerBase
  102. {
  103. private readonly GrpScheduleRepository _grpScheduleRep;
  104. private readonly IMapper _mapper;
  105. private readonly DelegationInfoRepository _groupRepository;
  106. private readonly TaskAssignmentRepository _taskAssignmentRep;
  107. private readonly AirTicketResRepository _airTicketResRep;
  108. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  109. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  110. private readonly DelegationEnDataRepository _delegationEnDataRep;
  111. private readonly DelegationVisaRepository _delegationVisaRep;
  112. private readonly VisaPriceRepository _visaPriceRep;
  113. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  114. private readonly HotelPriceRepository _hotelPriceRep;
  115. private readonly CustomersRepository _customersRep;
  116. private readonly MessageRepository _message;
  117. private readonly SqlSugarClient _sqlSugar;
  118. private readonly TourClientListRepository _tourClientListRep;
  119. private readonly TeamRateRepository _teamRateRep;
  120. #region 成本相关
  121. private readonly CheckBoxsRepository _checkBoxs;
  122. private readonly GroupCostRepository _GroupCostRepository;
  123. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  124. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  125. #endregion
  126. private readonly SetDataRepository _setDataRep;
  127. private string url;
  128. private string path;
  129. private readonly EnterExitCostRepository _enterExitCostRep;
  130. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  131. private readonly UsersRepository _usersRep;
  132. private readonly IJuHeApiService _juHeApi;
  133. private readonly InvertedListRepository _invertedListRep;
  134. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  135. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  136. private readonly ThreeCodeRepository _threeCodeRepository;
  137. private readonly HotelInquiryRepository _hotelInquiryRep;
  138. private readonly FeeAuditRepository _feeAuditRep;
  139. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  140. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  141. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  142. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  143. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  144. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  145. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  146. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  147. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  148. {
  149. _mapper = mapper;
  150. _grpScheduleRep = grpScheduleRep;
  151. _groupRepository = groupRepository;
  152. _taskAssignmentRep = taskAssignmentRep;
  153. _airTicketResRep = airTicketResRep;
  154. _sqlSugar = sqlSugar;
  155. url = AppSettingsHelper.Get("ExcelBaseUrl");
  156. path = AppSettingsHelper.Get("ExcelBasePath");
  157. if (!System.IO.Directory.Exists(path))
  158. {
  159. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  160. }
  161. _decreasePaymentsRep = decreasePaymentsRep;
  162. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  163. _delegationEnDataRep = delegationEnDataRep;
  164. _enterExitCostRep = enterExitCostRep;
  165. _delegationVisaRep = delegationVisaRep;
  166. _message = message;
  167. _visaPriceRep = visaPriceRep;
  168. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  169. _checkBoxs = checkBoxs;
  170. _GroupCostRepository = GroupCostRepository;
  171. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  172. _GroupCostParameterRepository = GroupCostParameterRepository;
  173. _hotelPriceRep = hotelPriceRep;
  174. _customersRep = customersRep;
  175. _setDataRep = setDataRep;
  176. _tourClientListRep = tourClientListRep;
  177. _teamRateRep = teamRateRep;
  178. _hubContext = hubContext;
  179. _usersRep = usersRep;
  180. _juHeApi = juHeApi;
  181. _invertedListRep = invertedListRep;
  182. _visaFeeInfoRep = visaFeeInfoRep;
  183. _ticketBlackCodeRep = ticketBlackCodeRep;
  184. _hotelInquiryRep = hotelInquiryRep;
  185. _threeCodeRepository = threeCodeRepository;
  186. _feeAuditRep = feeAuditRep;
  187. }
  188. #region 流程管控
  189. /// <summary>
  190. /// 获取团组流程管控信息
  191. /// </summary>
  192. /// <param name="paras">参数Json字符串</param>
  193. /// <returns></returns>
  194. [HttpPost]
  195. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  196. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  197. {
  198. if (string.IsNullOrEmpty(_jsonDto.Paras))
  199. {
  200. return Ok(JsonView(false, "参数为空"));
  201. }
  202. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  203. if (_ScheduleDto != null)
  204. {
  205. if (_ScheduleDto.SearchType == 2)//获取列表
  206. {
  207. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  208. return Ok(JsonView(_grpScheduleViewList));
  209. }
  210. else//获取对象
  211. {
  212. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  213. if (_grpScheduleView != null)
  214. {
  215. return Ok(JsonView(_grpScheduleView));
  216. }
  217. }
  218. }
  219. else
  220. {
  221. return Ok(JsonView(false, "参数反序列化失败"));
  222. }
  223. return Ok(JsonView(false, "暂无数据!"));
  224. }
  225. /// <summary>
  226. /// 修改团组流程管控详细表数据
  227. /// </summary>
  228. /// <param name="paras"></param>
  229. /// <returns></returns>
  230. [HttpPost]
  231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  232. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  233. {
  234. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  235. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  236. .SetColumns(it => it.Duty == _detail.Duty)
  237. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  238. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  239. .SetColumns(it => it.JobContent == _detail.JobContent)
  240. .SetColumns(it => it.Remark == _detail.Remark)
  241. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  242. .Where(s => s.Id == dto.Id)
  243. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  244. .ExecuteCommandAsync();
  245. if (result > 0)
  246. {
  247. return Ok(JsonView(true, "保存成功!"));
  248. }
  249. return Ok(JsonView(false, "保存失败!"));
  250. }
  251. /// <summary>
  252. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  253. /// </summary>
  254. /// <param name="dto"></param>
  255. /// <returns></returns>
  256. [HttpPost]
  257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  258. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  259. {
  260. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  261. _detail.IsDel = 1;
  262. _detail.DeleteUserId = dto.Duty;
  263. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  264. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  265. .SetColumns(it => it.IsDel == _detail.IsDel)
  266. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  267. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  268. .Where(it => it.Id == dto.Id)
  269. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  270. //.WhereColumns(s => s.Id == dto.Id)
  271. .ExecuteCommandAsync();
  272. if (result > 0)
  273. {
  274. return Ok(JsonView(true, "删除成功!"));
  275. }
  276. return Ok(JsonView(false, "删除失败!"));
  277. }
  278. /// <summary>
  279. /// 增加团组流程管控详细表数据
  280. /// </summary>
  281. /// <param name="dto"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  286. {
  287. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  288. if (DateTime.Now < _detail.ExpectBeginDt)
  289. {
  290. _detail.StepStatus = 0;
  291. }
  292. else
  293. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  294. _detail.StepStatus = 1;
  295. }
  296. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  297. if (result > 0)
  298. {
  299. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  300. return Ok(JsonView(true, "添加成功!", _result));
  301. }
  302. return Ok(JsonView(false, "添加失败!"));
  303. }
  304. #endregion
  305. #region 团组基本信息
  306. /// <summary>
  307. /// 接团信息列表
  308. /// </summary>
  309. /// <param name="dto">团组列表请求dto</param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  313. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  314. {
  315. var groupData = await _groupRepository.GetGroupList(dto);
  316. if (groupData.Code != 0)
  317. {
  318. return Ok(JsonView(false, groupData.Msg));
  319. }
  320. return Ok(JsonView(groupData.Data));
  321. }
  322. /// <summary>
  323. /// 接团信息列表 Page
  324. /// </summary>
  325. /// <param name="dto">团组列表请求dto</param>
  326. /// <returns></returns>
  327. [HttpPost]
  328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  329. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  330. {
  331. #region 参数验证
  332. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  333. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  334. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  335. #region 页面操作权限验证
  336. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  337. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  338. #endregion
  339. #endregion
  340. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  341. {
  342. string sqlWhere = string.Empty;
  343. if (dto.IsSure == 0) //未完成
  344. {
  345. sqlWhere += string.Format(@" And IsSure = 0");
  346. }
  347. else if (dto.IsSure == 1) //已完成
  348. {
  349. sqlWhere += string.Format(@" And IsSure = 1");
  350. }
  351. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  352. {
  353. string tj = dto.SearchCriteria;
  354. 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}%')",
  355. tj, tj, tj, tj, tj);
  356. }
  357. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  358. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  359. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  360. JietuanOperator,IsSure,CreateTime
  361. From (
  362. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  363. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  364. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  365. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  366. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  367. From Grp_DelegationInfo gdi
  368. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  369. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  370. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  371. Where gdi.IsDel = 0 {0}
  372. ) temp", sqlWhere);
  373. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  374. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  375. #region 处理所属部门
  376. /*
  377. * 1.sq 和 gyy 等显示 市场部
  378. * 2.王鸽和主管及张总还有管理员号统一国交部
  379. * 2-1. 4 管理员 ,21 张海麟
  380. */
  381. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  382. List<int> userIds1 = new List<int>() { 4, 21 };
  383. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  384. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  385. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  386. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  387. .ToList();
  388. foreach (var item in _DelegationList)
  389. {
  390. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  391. }
  392. #endregion
  393. var _view = new
  394. {
  395. PageFuncAuth = pageFunAuthView,
  396. Data = _DelegationList
  397. };
  398. return Ok(JsonView(true, "查询成功!", _view, total));
  399. }
  400. else
  401. {
  402. return Ok(JsonView(false, "查询失败"));
  403. }
  404. }
  405. /// <summary>
  406. /// 团组列表
  407. /// </summary>
  408. /// <returns></returns>
  409. [HttpPost]
  410. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  411. {
  412. #region 参数验证
  413. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  414. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  415. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  416. #region 页面操作权限验证
  417. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  418. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  419. #endregion
  420. #endregion
  421. if (dto.PortType != 1 && dto.PortType != 2)
  422. {
  423. return Ok(JsonView(false, "查询失败!"));
  424. }
  425. string orderbyStr = "order by gdi.CreateTime Desc";
  426. string sqlWhere = string.Empty;
  427. if (dto.IsSure == 0) //未完成
  428. {
  429. sqlWhere += string.Format(@" And IsSure = 0");
  430. }
  431. else if (dto.IsSure == 1) //已完成
  432. {
  433. sqlWhere += string.Format(@" And IsSure = 1");
  434. }
  435. //团组类型
  436. if (dto.TeamDid > 0)
  437. {
  438. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  439. }
  440. //团组名称
  441. if (!string.IsNullOrEmpty(dto.TeamName))
  442. {
  443. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  444. }
  445. //客户名称
  446. if (!string.IsNullOrEmpty(dto.ClientName))
  447. {
  448. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  449. }
  450. //客户单位
  451. if (!string.IsNullOrEmpty(dto.ClientUnit))
  452. {
  453. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  454. }
  455. //出访时间
  456. if (!string.IsNullOrEmpty(dto.visitDataTime))
  457. {
  458. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  459. orderbyStr = "order by gdi.VisitDate";
  460. }
  461. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  462. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  463. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  464. JietuanOperator,IsSure,CreateTime
  465. From (
  466. Select row_number() over({0}) as Row_Number,
  467. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  468. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  469. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  470. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  471. From Grp_DelegationInfo gdi
  472. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  473. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  474. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  475. Where gdi.IsDel = 0 {1}
  476. ) temp ", orderbyStr, sqlWhere);
  477. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  478. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  479. #region 处理所属部门
  480. /*
  481. * 1.sq 和 gyy 等显示 市场部
  482. * 2.王鸽和主管及张总还有管理员号统一国交部
  483. * 2-1. 4 管理员 ,21 张海麟
  484. */
  485. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  486. List<int> userIds1 = new List<int>() { 4, 21 };
  487. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  488. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  489. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  490. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  491. .ToList();
  492. foreach (var item in _DelegationList)
  493. {
  494. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  495. }
  496. #endregion
  497. var _view = new
  498. {
  499. PageFuncAuth = pageFunAuthView,
  500. Data = _DelegationList
  501. };
  502. return Ok(JsonView(true, "查询成功!", _view, total));
  503. }
  504. /// <summary>
  505. /// 接团信息详情
  506. /// </summary>
  507. /// <param name="dto">团组info请求dto</param>
  508. /// <returns></returns>
  509. [HttpPost]
  510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  511. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  512. {
  513. var groupData = await _groupRepository.GetGroupInfo(dto);
  514. if (groupData.Code != 0)
  515. {
  516. return Ok(JsonView(false, groupData.Msg));
  517. }
  518. return Ok(JsonView(groupData.Data));
  519. }
  520. /// <summary>
  521. /// 接团信息 编辑添加
  522. /// 基础信息数据源
  523. /// </summary>
  524. /// <param name="dto"></param>
  525. /// <returns></returns>
  526. [HttpPost]
  527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  528. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  529. {
  530. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  531. if (groupData.Code != 0)
  532. {
  533. return Ok(JsonView(false, groupData.Msg));
  534. }
  535. return Ok(JsonView(groupData.Data));
  536. }
  537. /// <summary>
  538. /// 接团信息 操作(增改)
  539. /// </summary>
  540. /// <param name="dto"></param>
  541. /// <returns></returns>
  542. [HttpPost]
  543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  544. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  545. {
  546. try
  547. {
  548. var groupData = await _groupRepository.GroupOperation(dto);
  549. if (groupData.Code != 0)
  550. {
  551. return Ok(JsonView(false, groupData.Msg));
  552. }
  553. int diId = 0;
  554. //添加时 默认加入团组汇率
  555. if (dto.Status == 1) //添加
  556. {
  557. diId = groupData.Data;
  558. //添加默认币种
  559. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  560. //默认分配权限
  561. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  562. //消息提示 王鸽 主管号
  563. List<int> _managerIds = new List<int>() { 22, 32 };
  564. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  565. if (userIds.Count > 0)
  566. {
  567. userIds.Add(208);
  568. //创建团组管控
  569. GroupStepForDelegation.CreateWorkStep(diId);
  570. //发送消息
  571. string groupName = dto.TeamName;
  572. string createGroupUser = string.Empty;
  573. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  574. if (userInfo != null) createGroupUser = userInfo.CnName;
  575. string title = $"系统通知";
  576. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  577. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  578. }
  579. //默认创建倒推表
  580. await _invertedListRep._Create(dto.UserId, diId);
  581. }
  582. else if (dto.Status == 2)
  583. {
  584. diId = dto.Id;
  585. }
  586. return Ok(JsonView(true, "操作成功!", diId));
  587. }
  588. catch (Exception ex)
  589. {
  590. Logs("[response]" + JsonConvert.SerializeObject(dto));
  591. Logs(ex.Message);
  592. return Ok(JsonView(false, ex.Message));
  593. }
  594. }
  595. /// <summary>
  596. /// 接团流程操作(增改)
  597. /// 安卓端使用 建团时添加客户名单
  598. /// </summary>
  599. /// <param name="dto"></param>
  600. /// <returns></returns>
  601. [HttpPost]
  602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  603. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  604. {
  605. try
  606. {
  607. #region 参数验证
  608. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  609. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  610. #region 页面操作权限验证
  611. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  612. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  613. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  614. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  615. #endregion
  616. #endregion
  617. _sqlSugar.BeginTran();
  618. var _dto = new GroupOperationDto();
  619. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  620. var groupData = await _groupRepository.GroupOperation(_dto);
  621. if (groupData.Code != 0)
  622. {
  623. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  624. }
  625. int diId = 0;
  626. //添加时 默认加入团组汇率
  627. if (dto.Status == 1) //添加
  628. {
  629. diId = groupData.Data;
  630. //添加默认币种
  631. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  632. //默认分配权限
  633. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  634. //消息提示 王鸽 主管号
  635. List<int> _managerIds = new List<int>() { 22, 32 };
  636. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  637. if (userIds.Count > 0)
  638. {
  639. userIds.Add(208);
  640. //创建团组管控
  641. GroupStepForDelegation.CreateWorkStep(diId);
  642. //发送消息
  643. string groupName = dto.TeamName;
  644. string createGroupUser = string.Empty;
  645. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  646. if (userInfo != null) createGroupUser = userInfo.CnName;
  647. string title = $"系统通知";
  648. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  649. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  650. }
  651. }
  652. if (dto.Status == 2)
  653. {
  654. diId = dto.Id;
  655. if (diId == 0)
  656. {
  657. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  658. }
  659. }
  660. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  661. if (viewData.Code != 0)
  662. {
  663. _sqlSugar.RollbackTran();
  664. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  665. }
  666. _sqlSugar.CommitTran();
  667. return Ok(JsonView(true, "添加成功"));
  668. }
  669. catch (Exception ex)
  670. {
  671. _sqlSugar.RollbackTran();
  672. return Ok(JsonView(false, ex.Message));
  673. }
  674. }
  675. /// <summary>
  676. /// 接团信息 操作(删除)
  677. /// </summary>
  678. /// <param name="dto"></param>
  679. /// <returns></returns>
  680. [HttpPost]
  681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  682. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  683. {
  684. try
  685. {
  686. var groupData = await _groupRepository.GroupDel(dto);
  687. if (groupData.Code != 0)
  688. {
  689. return Ok(JsonView(false, groupData.Msg));
  690. }
  691. return Ok(JsonView(true));
  692. }
  693. catch (Exception ex)
  694. {
  695. Logs("[response]" + JsonConvert.SerializeObject(dto));
  696. Logs(ex.Message);
  697. return Ok(JsonView(false, ex.Message));
  698. }
  699. }
  700. /// <summary>
  701. /// 获取团组销售报价号
  702. /// 团组添加时 使用
  703. /// </summary>
  704. /// <returns></returns>
  705. [HttpPost]
  706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  707. public async Task<IActionResult> GetGroupSalesQuoteNo()
  708. {
  709. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  710. if (groupData.Code != 0)
  711. {
  712. return Ok(JsonView(false, groupData.Msg));
  713. }
  714. object salesQuoteNo = new
  715. {
  716. SalesQuoteNo = groupData.Data
  717. };
  718. return Ok(JsonView(salesQuoteNo));
  719. }
  720. /// <summary>
  721. /// 设置确认出团
  722. /// </summary>
  723. /// <param name="dto"></param>
  724. /// <returns></returns>
  725. [HttpPost]
  726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  727. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  728. {
  729. var groupData = await _groupRepository.ConfirmationGroup(dto);
  730. if (groupData.Code != 0)
  731. {
  732. return Ok(JsonView(false, groupData.Msg));
  733. }
  734. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  735. #region OA消息推送
  736. try
  737. {
  738. string groupName = groupInfo.TeamName;
  739. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  740. List<int> userIds = new List<int>();
  741. listUser.ForEach(s => userIds.Add(s.Id));
  742. string title = $"系统通知";
  743. string content = $"团组[{groupName}]已确认出团!";
  744. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  745. }
  746. catch (Exception ex)
  747. {
  748. }
  749. #endregion
  750. #region 应用推送
  751. try
  752. {
  753. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  754. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  755. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  756. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  757. {
  758. List<string> userList = new List<string>() { users.QiyeChatUserId };
  759. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  760. }
  761. }
  762. catch (Exception ex)
  763. {
  764. }
  765. #endregion
  766. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  767. return Ok(JsonView(true, "操作成功!", groupData.Data));
  768. }
  769. /// <summary>
  770. /// 获取团组名称data And 签证国别Data
  771. /// </summary>
  772. /// <param name="dto"></param>
  773. /// <returns></returns>
  774. [HttpPost]
  775. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  776. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  777. {
  778. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  779. if (groupData.Code != 0)
  780. {
  781. return Ok(JsonView(false, groupData.Msg));
  782. }
  783. return Ok(JsonView(groupData.Data));
  784. }
  785. /// <summary>
  786. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  787. /// </summary>
  788. /// <returns></returns>
  789. [HttpPost]
  790. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  791. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  792. {
  793. try
  794. {
  795. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  796. if (groupData.Code != 0)
  797. {
  798. return Ok(JsonView(false, groupData.Msg));
  799. }
  800. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  801. }
  802. catch (Exception ex)
  803. {
  804. return Ok(JsonView(false, "程序错误!"));
  805. throw;
  806. }
  807. }
  808. #endregion
  809. #region 团组&签证
  810. /// <summary>
  811. /// 根据团组Id获取签证客户信息List
  812. /// </summary>
  813. /// <param name="dto">请求dto</param>
  814. /// <returns></returns>
  815. [HttpPost]
  816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  817. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  818. {
  819. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  820. if (groupData.Code != 0)
  821. {
  822. return Ok(JsonView(false, groupData.Msg));
  823. }
  824. return Ok(JsonView(groupData.Data));
  825. }
  826. /// <summary>
  827. /// IOS获取团组签证拍照上传进度01(团组列表)
  828. /// </summary>
  829. /// <param name="dto">请求dto</param>
  830. /// <returns></returns>
  831. [HttpPost]
  832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  833. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  834. {
  835. if (dto == null)
  836. {
  837. return Ok(JsonView(false, "参数为空"));
  838. }
  839. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  840. return Ok(JsonView(visaList));
  841. }
  842. /// <summary>
  843. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  844. /// </summary>
  845. /// <returns></returns>
  846. [HttpPost]
  847. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  848. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  849. {
  850. if (dto == null)
  851. {
  852. return Ok(JsonView(false, "请求错误:"));
  853. }
  854. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  855. return Ok(JsonView(list));
  856. }
  857. /// <summary>
  858. /// IOS获取团组签证拍照上传进度03(相册)
  859. /// </summary>
  860. /// <returns></returns>
  861. [HttpPost]
  862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  863. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  864. {
  865. if (dto == null)
  866. {
  867. return Ok(JsonView(false, "请求错误:"));
  868. }
  869. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  870. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  871. list.ForEach(s => s.url = url);
  872. return Ok(JsonView(list));
  873. }
  874. /// <summary>
  875. /// IOS获取团组签证拍照上传进度04(图片上传)
  876. /// </summary>
  877. /// <param name="dto"></param>
  878. /// <returns></returns>
  879. [HttpPost]
  880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  881. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  882. {
  883. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  884. //if (!string.IsNullOrEmpty(result))
  885. //{
  886. //}
  887. //else {
  888. // return Ok(JsonView(false, "上传失败"));
  889. //}
  890. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  891. int sucNum = 0;
  892. try
  893. {
  894. foreach (var item in dto.base64DataList)
  895. {
  896. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  897. string result = decodeBase64ToImage(item, imageName);
  898. if (!string.IsNullOrEmpty(result))
  899. {
  900. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  901. pic.CreateUserId = dto.CreateUserId;
  902. pic.PicName = imageName;
  903. pic.PicPath = result;
  904. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  905. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  906. if (insertResult > 0)
  907. {
  908. sucNum++;
  909. }
  910. }
  911. }
  912. }
  913. catch (Exception ex)
  914. {
  915. return Ok(JsonView(false, ex.Message));
  916. }
  917. string msg = string.Format(@"成功上传{0}张", sucNum);
  918. return Ok(JsonView(true, msg));
  919. }
  920. private string decodeBase64ToImage(string base64DataURL, string imgName)
  921. {
  922. string filename = "";//声明一个string类型的相对路径
  923. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  924. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  925. try//会有异常抛出,try,catch一下
  926. {
  927. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  928. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  929. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  930. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  931. //文件名称
  932. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  933. //上传的文件的路径
  934. string filePath = "";
  935. if (!Directory.Exists(fileDir))
  936. {
  937. Directory.CreateDirectory(fileDir);
  938. }
  939. //上传的文件的路径
  940. filePath = fileDir + filename;
  941. //string url = HttpRuntime.AppDomainAppPath.ToString();
  942. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  943. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  944. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  945. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  946. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  947. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  948. ms.Close();//关闭当前流,并释放所有与之关联的资源
  949. bitmap.Dispose();
  950. }
  951. catch (Exception e)
  952. {
  953. string massage = e.Message;
  954. Logs("IOS图片上传Error:" + massage);
  955. //filename = e.Message;
  956. }
  957. return filename;//返回相对路径
  958. }
  959. /// <summary>
  960. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  961. /// </summary>
  962. /// <param name="dto"></param>
  963. /// <returns></returns>
  964. [HttpPost]
  965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  966. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  967. {
  968. if (dto == null)
  969. {
  970. return Ok(JsonView(false, "请求错误:"));
  971. }
  972. string msg = "参数错误";
  973. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  974. {
  975. try
  976. {
  977. //_delegationVisaRep.BeginTran();
  978. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  979. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  980. .Where(s => s.Id == dto.visaProgressCustomerId)
  981. .ExecuteCommandAsync();
  982. if (updCount > 0 && dto.publishCode == 1)
  983. {
  984. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  985. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  986. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  987. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  988. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  989. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  990. if (groupData == null)
  991. {
  992. _delegationVisaRep.RollbackTran();
  993. }
  994. string title = string.Format(@"[签证进度更新]");
  995. string content = string.Format(@"测试文本");
  996. bool rst = await _message.AddMsg(new MessageDto()
  997. {
  998. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  999. IssuerId = dto.publisher,
  1000. Title = title,
  1001. Content = content,
  1002. ReleaseTime = DateTime.Now,
  1003. UIdList = new List<int> {
  1004. 234
  1005. }
  1006. });
  1007. if (rst)
  1008. {
  1009. return Ok(JsonView(true, "发送通知成功"));
  1010. }
  1011. }
  1012. //_delegationVisaRep.CommitTran();
  1013. }
  1014. catch (Exception)
  1015. {
  1016. //_delegationVisaRep.RollbackTran();
  1017. }
  1018. }
  1019. return Ok(JsonView(true, msg));
  1020. }
  1021. #endregion
  1022. #region 团组任务分配
  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> GetTaskAssignmen()
  1031. {
  1032. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  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. /// </summary>
  1042. /// <param name="dto"></param>
  1043. /// <returns></returns>
  1044. [HttpPost]
  1045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1046. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1047. {
  1048. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1049. if (groupData.Code != 0)
  1050. {
  1051. return Ok(JsonView(false, groupData.Msg));
  1052. }
  1053. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1054. }
  1055. /// <summary>
  1056. /// 团组任务分配操作
  1057. /// </summary>
  1058. /// <param name="dto"></param>
  1059. /// <returns></returns>
  1060. [HttpPost]
  1061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1062. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1063. {
  1064. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1065. if (groupData.Code != 0)
  1066. {
  1067. return Ok(JsonView(false, groupData.Msg));
  1068. }
  1069. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1070. }
  1071. #endregion
  1072. #region 团组费用审核
  1073. /// <summary>
  1074. /// 费用审核
  1075. /// 团组列表 Page
  1076. /// </summary>
  1077. /// <param name="_dto">团组列表请求dto</param>
  1078. /// <returns></returns>
  1079. [HttpPost]
  1080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1081. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1082. {
  1083. #region 参数验证
  1084. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1085. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1086. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1087. #region 页面操作权限验证
  1088. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1089. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1090. #endregion
  1091. #endregion
  1092. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1093. {
  1094. string sqlWhere = string.Empty;
  1095. if (_dto.IsSure == 0) //未完成
  1096. {
  1097. sqlWhere += string.Format(@" And IsSure = 0");
  1098. }
  1099. else if (_dto.IsSure == 1) //已完成
  1100. {
  1101. sqlWhere += string.Format(@" And IsSure = 1");
  1102. }
  1103. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1104. {
  1105. string tj = _dto.SearchCriteria;
  1106. 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}%')",
  1107. tj, tj, tj, tj, tj);
  1108. }
  1109. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1110. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1111. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1112. From (
  1113. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1114. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1115. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1116. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1117. From Grp_DelegationInfo gdi
  1118. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1119. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1120. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1121. Where gdi.IsDel = 0 {0}
  1122. ) temp ", sqlWhere);
  1123. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1124. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1125. var _view = new
  1126. {
  1127. PageFuncAuth = pageFunAuthView,
  1128. Data = _DelegationList
  1129. };
  1130. return Ok(JsonView(true, "查询成功!", _view, total));
  1131. }
  1132. else
  1133. {
  1134. return Ok(JsonView(false, "查询失败"));
  1135. }
  1136. }
  1137. /// <summary>
  1138. /// 获取团组费用审核
  1139. /// </summary>
  1140. /// <param name="paras">参数Json字符串</param>
  1141. /// <returns></returns>
  1142. [HttpPost]
  1143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1144. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1145. {
  1146. try
  1147. {
  1148. #region 参数验证
  1149. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1150. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1151. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1152. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1153. #region 页面操作权限验证
  1154. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1155. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1156. #endregion
  1157. #endregion
  1158. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1159. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1160. #region 费用清单
  1161. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1162. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1163. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1164. List<Grp_CreditCardPayment> entityList = _groupRepository
  1165. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1166. .Where(exp.ToExpression())
  1167. .ToList();
  1168. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1169. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1170. /*
  1171. * 76://酒店预订
  1172. */
  1173. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1174. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1175. .ToListAsync();
  1176. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1177. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1178. .ToListAsync();
  1179. /*
  1180. * 79://车/导游地接
  1181. */
  1182. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1183. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1184. .ToListAsync();
  1185. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1186. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1187. .ToListAsync();
  1188. /*
  1189. * 80: //签证
  1190. */
  1191. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1192. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1193. .ToListAsync();
  1194. /*
  1195. *81: //邀请/公务活动
  1196. */
  1197. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1198. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1199. .ToListAsync();
  1200. /*
  1201. * 82: //团组客户保险
  1202. */
  1203. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1204. /*
  1205. * Lable = 85 机票预订
  1206. */
  1207. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1208. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1209. .ToListAsync();
  1210. /*
  1211. * 85 机票预定
  1212. */
  1213. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1214. /*
  1215. * 98 其他款项
  1216. */
  1217. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1218. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1219. .ToListAsync();
  1220. /*
  1221. * 285:收款退还
  1222. */
  1223. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1224. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1225. .ToListAsync();
  1226. /*
  1227. * 1015: //超支费用
  1228. */
  1229. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1230. /*
  1231. * 币种信息
  1232. */
  1233. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1234. /*
  1235. * 车/导游地接 费用类型
  1236. */
  1237. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1238. /*
  1239. * 车/导游地接 费用类型
  1240. */
  1241. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1242. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1243. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1244. /*
  1245. * 用户信息
  1246. */
  1247. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1248. /*
  1249. * 费用模块
  1250. */
  1251. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1252. string priceModule = string.Empty;
  1253. if (sdPriceName != null)
  1254. {
  1255. priceModule = sdPriceName.Name;
  1256. }
  1257. /*
  1258. * 成本信息
  1259. */
  1260. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1261. decimal _groupRate = 0.0000M;
  1262. string _groupCurrencyCode = "-";
  1263. if (groupCost != null)
  1264. {
  1265. _groupRate = groupCost.Rate;
  1266. if (int.TryParse(groupCost.Currency, out int _currency))
  1267. {
  1268. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1269. }
  1270. else _groupCurrencyCode = groupCost.Currency;
  1271. }
  1272. string costContentSql = $"Select * From Grp_GroupCost";
  1273. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1274. //处理日期为空的天数
  1275. for (int i = 0; i < groupCostDetails.Count; i++)
  1276. if (i != 0)
  1277. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1278. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1279. /*
  1280. * 处理详情数据
  1281. */
  1282. foreach (var entity in entityList)
  1283. {
  1284. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1285. _detail.Id = entity.Id;
  1286. _detail.PriceName = priceModule;
  1287. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1288. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1289. /*
  1290. * 应付款金额
  1291. */
  1292. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1293. string PaymentCurrency_WaitPay = "Unknown";
  1294. string hotelCurrncyCode = "Unknown";
  1295. string hotelCurrncyName = "Unknown";
  1296. if (sdPaymentCurrency_WaitPay != null)
  1297. {
  1298. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1299. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1300. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1301. if (hotelCurrncyCode.Equals("CNY"))
  1302. {
  1303. entity.DayRate = 1.0000M;
  1304. }
  1305. }
  1306. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1307. /*
  1308. * 此次付款金额
  1309. */
  1310. decimal CurrPayStr = 0;
  1311. if (entity.PayPercentage == 0)
  1312. {
  1313. if (entity.PayThenMoney != 0)
  1314. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1315. }
  1316. else
  1317. {
  1318. if (entity.PayMoney != 0)
  1319. {
  1320. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1321. }
  1322. }
  1323. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1324. /*
  1325. * 剩余尾款
  1326. */
  1327. decimal BalanceStr = 0;
  1328. if (CurrPayStr != 0)
  1329. {
  1330. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1331. BalanceStr = 0;
  1332. else
  1333. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1334. }
  1335. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1336. /*
  1337. * Bus名称
  1338. */
  1339. _detail.BusName = "待增加";
  1340. /*
  1341. *费用所属
  1342. */
  1343. switch (entity.CTable)
  1344. {
  1345. case 76://酒店预订
  1346. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1347. if (hotelReservations != null)
  1348. {
  1349. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1350. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1351. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1352. string roomFeeStr = "", roomFeestr1 = "";
  1353. //是否比较房型价格
  1354. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1355. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1356. if (hotelReservations.SingleRoomPrice > 0)
  1357. { roomFeestr1 += $"单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}"; __isSingle = true; }
  1358. if (hotelReservations.DoubleRoomPrice > 0)
  1359. { roomFeestr1 += $"双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}"; __isDouble = true; }
  1360. if (hotelReservations.SuiteRoomPrice > 0)
  1361. { roomFeestr1 += $"套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}"; __isSuite = true; }
  1362. if (hotelReservations.OtherRoomPrice > 0)
  1363. { roomFeestr1 += $"其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}"; __isOther = true; }
  1364. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1365. else roomFeeStr += " 0.00 * 0";
  1366. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1367. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1368. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1369. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1370. /*
  1371. * 费用类型
  1372. * 1:房费
  1373. * 2:早餐
  1374. * 3:地税
  1375. * 4:城市税
  1376. * </summary>
  1377. */
  1378. //地税
  1379. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1380. if (governmentRentData != null)
  1381. {
  1382. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1383. governmentRentFee = governmentRentData.Price;
  1384. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1385. if (governmentRentCurrData != null)
  1386. {
  1387. governmentRentCode = governmentRentCurrData.Name;
  1388. governmentRentName = $"({governmentRentCurrData.Remark})";
  1389. }
  1390. }
  1391. //城市税
  1392. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1393. if (cityTaxData != null)
  1394. {
  1395. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1396. cityTaxFee = cityTaxData.Price;
  1397. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1398. if (cityTaxCurrData != null)
  1399. {
  1400. cityTaxCode = cityTaxCurrData.Name;
  1401. cityTaxName = $"({cityTaxCurrData.Remark})";
  1402. }
  1403. }
  1404. //酒店早餐
  1405. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1406. if (breakfastData != null)
  1407. {
  1408. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1409. breakfastFee = breakfastData.Price;
  1410. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1411. if (breakfastCurrData != null)
  1412. {
  1413. breakfastCode = breakfastCurrData.Name;
  1414. breakfastName = $"({breakfastCurrData.Remark})";
  1415. }
  1416. }
  1417. //房间费用
  1418. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1419. if (roomData != null)
  1420. {
  1421. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1422. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1423. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1424. roomFee = roomData.Price;
  1425. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1426. if (roomCurrData != null)
  1427. {
  1428. roomCode = roomCurrData.Name;
  1429. roomName = $"({roomCurrData.Remark})";
  1430. }
  1431. }
  1432. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1433. string hotelCostStr = "";
  1434. decimal hotelCsotTotal = 0.00M;
  1435. if (groupCost != null)
  1436. {
  1437. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1438. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1439. }
  1440. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1441. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1442. string hotelCost_day = "";
  1443. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1444. foreach (var item in hotelCostDetails1)
  1445. {
  1446. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1447. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1448. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1449. else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1450. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1451. else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1452. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1453. else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1454. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1455. else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1456. hotelCost_day += @$"</br>";
  1457. }
  1458. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1459. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1460. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1461. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1462. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1463. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1464. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1465. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1466. $"房间说明: {hotelReservations.Remark} <br/>" +
  1467. $"房间费用: {roomCode} {roomName} 当时汇率 {roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接代付:{roomBool}<br/><br/>" +
  1468. $"{hotelBreakfastStr}" +
  1469. $"{hotelGovernmentRentStr}" +
  1470. $"{hotelCityTaxStr}";
  1471. _detail.PriceNameContent = hotelReservations.HotelName;
  1472. }
  1473. break;
  1474. case 79://车/导游地接
  1475. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1476. if (touristGuideGroundReservations != null)
  1477. {
  1478. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1479. {
  1480. _detail.BusName = touristGuideGroundReservations.BusName;
  1481. }
  1482. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1483. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1484. //if (isInt)
  1485. //{
  1486. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1487. // if (cityInfo != null)
  1488. // {
  1489. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1490. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1491. // if (carFeeItem != null)
  1492. // {
  1493. // nameContent += $@"({carFeeItem.Name})";
  1494. // }
  1495. // _detail.PriceNameContent = nameContent;
  1496. // }
  1497. //}
  1498. //else
  1499. //{
  1500. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1501. //}
  1502. var touristGuideGroundReservationsContents =
  1503. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1504. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1505. foreach (var item in touristGuideGroundReservationsContents)
  1506. {
  1507. string typeName = "Unknown";
  1508. string carCurrencyCode = "Unknown";
  1509. string carCurrencyName = "Unknown";
  1510. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1511. if (carTypeData != null) typeName = carTypeData.Name;
  1512. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1513. if (currencyData != null)
  1514. {
  1515. carCurrencyCode = currencyData.Name;
  1516. carCurrencyName = currencyData.Remark;
  1517. }
  1518. string opCostStr = string.Empty;
  1519. decimal opCostTypePrice = 0.00M;
  1520. #region 处理成本各项费用
  1521. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1522. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1523. if (opCost.Count > 0)
  1524. {
  1525. switch (item.SId)
  1526. {
  1527. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1528. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1529. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1530. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1531. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1532. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1533. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1534. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1535. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1536. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1537. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1538. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1539. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1540. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1541. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1542. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1543. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1544. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1545. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1546. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1547. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1548. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1549. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1550. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1551. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1552. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1553. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1554. }
  1555. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1556. }
  1557. #endregion
  1558. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1559. $"{typeName}{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")}) {opCostStr}<br/>" +
  1560. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1561. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1562. }
  1563. _detail.PriceMsgContent = priceMsg;
  1564. }
  1565. break;
  1566. case 80: //签证
  1567. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1568. if (visaInfo != null)
  1569. {
  1570. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1571. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1572. }
  1573. break;
  1574. case 81: //邀请/公务活动
  1575. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1576. if (_ioa != null)
  1577. {
  1578. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1579. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1580. sendCurrName = "Unknown", //快递费用币种 Name
  1581. sendCurrCode = "Unknown", //快递费用币种 Code
  1582. eventsCurrName = "Unknown", //公务活动费币种 Name
  1583. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1584. translateCurrName = "Unknown", //公务翻译费 Name
  1585. translateCurrCode = "Unknown"; //公务翻译费 Code
  1586. #region 处理费用币种
  1587. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1588. if (inviteCurrData != null)
  1589. {
  1590. inviteCurrName = inviteCurrData.Remark;
  1591. inviteCurrCode = inviteCurrData.Name;
  1592. }
  1593. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1594. if (sendCurrData != null)
  1595. {
  1596. sendCurrName = sendCurrData.Remark;
  1597. sendCurrCode = sendCurrData.Name;
  1598. }
  1599. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1600. if (eventsCurrData != null)
  1601. {
  1602. eventsCurrName = eventsCurrData.Remark;
  1603. eventsCurrCode = eventsCurrData.Name;
  1604. }
  1605. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1606. if (translateCurrData != null)
  1607. {
  1608. translateCurrName = translateCurrData.Remark;
  1609. translateCurrCode = translateCurrData.Name;
  1610. }
  1611. #endregion
  1612. _detail.PriceNameContent = _ioa.InviterArea;
  1613. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1614. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1615. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1616. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1617. $@"备注:" + _ioa.Remark + "<br/>";
  1618. }
  1619. break;
  1620. case 82: //团组客户保险
  1621. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1622. if (customers != null)
  1623. {
  1624. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1625. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1626. }
  1627. break;
  1628. case 85: //机票预订
  1629. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1630. if (jpRes != null)
  1631. {
  1632. string FlightsDescription = jpRes.FlightsDescription;
  1633. string PriceDescription = jpRes.PriceDescription;
  1634. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1635. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1636. }
  1637. break;
  1638. case 98://其他款项
  1639. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1640. if (gdpRes != null)
  1641. {
  1642. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1643. _detail.PriceNameContent = gdpRes.PriceName;
  1644. }
  1645. break;
  1646. case 285://收款退还
  1647. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1648. if (refundAndOtherMoney != null)
  1649. {
  1650. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1651. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1652. }
  1653. break;
  1654. case 751://酒店早餐
  1655. break;
  1656. case 1015://超支费用
  1657. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1658. if (groupExtraCost != null)
  1659. {
  1660. _detail.PriceNameContent = groupExtraCost.PriceName;
  1661. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1662. }
  1663. break;
  1664. default:
  1665. break;
  1666. }
  1667. /*
  1668. * 申请人
  1669. */
  1670. string operatorName = " - ";
  1671. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1672. if (_opUser != null)
  1673. {
  1674. operatorName = _opUser.CnName;
  1675. }
  1676. _detail.OperatorName = operatorName;
  1677. /*
  1678. * 审核人
  1679. */
  1680. string auditOperatorName = "Unknown";
  1681. if (entity.AuditGMOperate == 0)
  1682. auditOperatorName = " - ";
  1683. else if (entity.AuditGMOperate == 4)
  1684. auditOperatorName = "自动审核";
  1685. else
  1686. {
  1687. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1688. if (_adUser != null)
  1689. {
  1690. auditOperatorName = _adUser.CnName;
  1691. }
  1692. }
  1693. _detail.AuditOperatorName = auditOperatorName;
  1694. /*
  1695. * 超预算比例
  1696. */
  1697. string overBudgetStr = "";
  1698. if (entity.ExceedBudget == -1)
  1699. overBudgetStr = sdPriceName.Name + "尚无预算";
  1700. else if (entity.ExceedBudget == 0)
  1701. {
  1702. if (entity.CTable == 76 || entity.CTable == 79)
  1703. {
  1704. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1705. else overBudgetStr = "超预算";
  1706. }
  1707. else
  1708. {
  1709. overBudgetStr = "未超预算";
  1710. }
  1711. }
  1712. else
  1713. overBudgetStr = entity.ExceedBudget.ToString("P");
  1714. _detail.OverBudget = overBudgetStr;
  1715. /*
  1716. * 费用总计
  1717. */
  1718. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1719. {
  1720. CurrencyId = entity.PaymentCurrency,
  1721. CurrencyName = PaymentCurrency_WaitPay,
  1722. AmountPayable = entity.PayMoney,
  1723. ThisPayment = CurrPayStr,
  1724. BalancePayment = BalanceStr,
  1725. AuditedFunds = CurrPayStr
  1726. });
  1727. _detail.IsAuditGM = entity.IsAuditGM;
  1728. detailList.Add(_detail);
  1729. }
  1730. #endregion
  1731. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1732. /*
  1733. * 下方描述处理
  1734. */
  1735. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1736. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1737. if (ccpCurrencyPrice != null)
  1738. {
  1739. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1740. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1741. }
  1742. else
  1743. {
  1744. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1745. }
  1746. string amountPayableStr = string.Format(@"应付款总金额: ");
  1747. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1748. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1749. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1750. foreach (var item in nonDuplicat)
  1751. {
  1752. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1753. if (strs.Count > 0)
  1754. {
  1755. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1756. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1757. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1758. //单独处理此次付款金额
  1759. if (item.CurrencyId == 836) //人民币
  1760. {
  1761. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1762. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1763. }
  1764. else
  1765. {
  1766. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1767. }
  1768. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1769. //单独处理已审核费用
  1770. if (item.CurrencyId == 836) //人民币
  1771. {
  1772. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1773. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1774. }
  1775. else
  1776. {
  1777. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1778. }
  1779. }
  1780. }
  1781. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1782. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1783. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1784. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1785. var _view1 = new
  1786. {
  1787. PageFuncAuth = pageFunAuthView,
  1788. Data = _view
  1789. };
  1790. return Ok(JsonView(_view1));
  1791. }
  1792. catch (Exception ex)
  1793. {
  1794. return Ok(JsonView(false, ex.Message));
  1795. }
  1796. }
  1797. /// <summary>
  1798. /// 费用审核
  1799. /// 修改团组费用审核状态
  1800. /// </summary>
  1801. /// <param name="_dto">参数Json字符串</param>
  1802. /// <returns></returns>
  1803. [HttpPost]
  1804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1805. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1806. {
  1807. #region 参数验证
  1808. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1809. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1810. #endregion
  1811. #region 页面操作权限验证
  1812. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1813. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1814. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1815. #endregion
  1816. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1817. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1818. DateTime dtNow = DateTime.Now;
  1819. _groupRepository.BeginTran();
  1820. int rst = 0;
  1821. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1822. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1823. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1824. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1825. List<dynamic> msgDatas = new List<dynamic>();
  1826. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1827. foreach (var item in idList)
  1828. {
  1829. int CreditId = int.Parse(item);
  1830. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1831. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1832. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1833. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1834. .Where(s => s.Id == CreditId)
  1835. .ExecuteCommandAsync();
  1836. if (result < 1)
  1837. {
  1838. rst = -1;
  1839. _groupRepository.RollbackTran();
  1840. return Ok(JsonView(false, "操作失败并回滚!"));
  1841. }
  1842. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1843. if (creditData != null)
  1844. {
  1845. #region 应用通知配置
  1846. try
  1847. {
  1848. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1849. }
  1850. catch (Exception ex)
  1851. {
  1852. }
  1853. #endregion
  1854. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1855. string groupNameStr = string.Empty;
  1856. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1857. if (groupData != null) groupNameStr = groupData.TeamName;
  1858. string creditTypeStr = string.Empty;
  1859. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1860. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1861. string creditCurrency = string.Empty;
  1862. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1863. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1864. if (creditCurrency.Equals("CNY"))
  1865. {
  1866. creditData.DayRate = 1.0000M;
  1867. }
  1868. if (creditData.PayPercentage == 0.00M)
  1869. {
  1870. creditData.PayPercentage = 100M;
  1871. }
  1872. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1873. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1874. string msgContent = "";
  1875. if (creditCurrency.Equals("CNY"))
  1876. {
  1877. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1878. }
  1879. else
  1880. {
  1881. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1882. }
  1883. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1884. }
  1885. }
  1886. if (rst == 0)
  1887. {
  1888. _groupRepository.CommitTran();
  1889. foreach (var item in msgDatas)
  1890. {
  1891. //发送消息
  1892. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1893. }
  1894. #region 应用推送
  1895. try
  1896. {
  1897. foreach (var ccpId in dic_ccp_user.Keys)
  1898. {
  1899. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1900. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1901. }
  1902. }
  1903. catch (Exception)
  1904. {
  1905. }
  1906. #endregion
  1907. return Ok(JsonView(true, "操作成功!"));
  1908. }
  1909. return Ok(JsonView(false, "操作失败!"));
  1910. }
  1911. #endregion
  1912. #region 机票费用录入
  1913. /// <summary>
  1914. /// 机票录入当前登录人可操作团组
  1915. /// </summary>
  1916. /// <param name="dto"></param>
  1917. /// <returns></returns>
  1918. [HttpPost]
  1919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1920. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1921. {
  1922. try
  1923. {
  1924. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1925. if (groupData.Code != 0)
  1926. {
  1927. return Ok(JsonView(false, groupData.Msg));
  1928. }
  1929. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1930. }
  1931. catch (Exception ex)
  1932. {
  1933. return Ok(JsonView(false, "程序错误!"));
  1934. throw;
  1935. }
  1936. }
  1937. /// <summary>
  1938. /// 机票费用录入列表
  1939. /// </summary>
  1940. /// <param name="dto"></param>
  1941. /// <returns></returns>
  1942. [HttpPost]
  1943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1944. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1945. {
  1946. try
  1947. {
  1948. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1949. if (groupData.Code != 0)
  1950. {
  1951. return Ok(JsonView(false, groupData.Msg));
  1952. }
  1953. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1954. }
  1955. catch (Exception ex)
  1956. {
  1957. return Ok(JsonView(false, ex.Message));
  1958. throw;
  1959. }
  1960. }
  1961. /// <summary>
  1962. /// 根据id查询费用录入信息
  1963. /// </summary>
  1964. /// <param name="dto"></param>
  1965. /// <returns></returns>
  1966. [HttpPost]
  1967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1968. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1969. {
  1970. try
  1971. {
  1972. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1973. if (groupData.Code != 0)
  1974. {
  1975. return Ok(JsonView(false, groupData.Msg));
  1976. }
  1977. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1978. }
  1979. catch (Exception ex)
  1980. {
  1981. return Ok(JsonView(false, "程序错误!"));
  1982. throw;
  1983. }
  1984. }
  1985. /// <summary>
  1986. /// 机票费用录入操作(Status:1.新增,2.修改)
  1987. /// </summary>
  1988. /// <param name="dto"></param>
  1989. /// <returns></returns>
  1990. [HttpPost]
  1991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1992. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1993. {
  1994. try
  1995. {
  1996. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1997. if (groupData.Code != 0)
  1998. {
  1999. return Ok(JsonView(false, groupData.Msg));
  2000. }
  2001. #region 应用推送
  2002. try
  2003. {
  2004. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2005. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2006. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2007. }
  2008. catch (Exception ex)
  2009. {
  2010. }
  2011. #endregion
  2012. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2013. }
  2014. catch (Exception ex)
  2015. {
  2016. return Ok(JsonView(false, "程序错误!"));
  2017. throw;
  2018. }
  2019. }
  2020. /// <summary>
  2021. /// 根据舱位类型查询接团客户名单信息
  2022. /// </summary>
  2023. /// <param name="dto"></param>
  2024. /// <returns></returns>
  2025. [HttpPost]
  2026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2027. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2028. {
  2029. try
  2030. {
  2031. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2032. if (crm_Groups.Count != 0)
  2033. {
  2034. List<dynamic> Customer = new List<dynamic>();
  2035. foreach (var item in crm_Groups)
  2036. {
  2037. var data = new
  2038. {
  2039. Id = item.Id,
  2040. Pinyin = item.Pinyin,
  2041. Name = item.LastName + item.FirstName
  2042. };
  2043. Customer.Add(data);
  2044. }
  2045. return Ok(JsonView(true, "查询成功!", Customer));
  2046. }
  2047. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2048. }
  2049. catch (Exception ex)
  2050. {
  2051. return Ok(JsonView(false, "程序错误!"));
  2052. throw;
  2053. }
  2054. }
  2055. /// <summary>
  2056. /// 根据团号获取客户信息
  2057. /// </summary>
  2058. /// <param name="dto"></param>
  2059. /// <returns></returns>
  2060. [HttpPost]
  2061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2062. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2063. {
  2064. var jw = JsonView(false);
  2065. if (dto.DIID < 1)
  2066. {
  2067. jw.Msg += "请输入正确的diid";
  2068. return Ok(jw);
  2069. }
  2070. var arr = getSimplClientList(dto.DIID);
  2071. jw = JsonView(true, "获取成功!", arr);
  2072. return Ok(jw);
  2073. }
  2074. private List<SimplClientInfo> getSimplClientList(int diId)
  2075. {
  2076. 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);
  2077. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2078. return arr;
  2079. }
  2080. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2081. {
  2082. string result = origin;
  2083. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2084. {
  2085. string[] temparr = origin.Split(',');
  2086. string fistrStr = temparr[0];
  2087. int count = temparr.Count();
  2088. int tempId;
  2089. bool success = int.TryParse(fistrStr, out tempId);
  2090. if (success)
  2091. {
  2092. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2093. if (tempInfo != null)
  2094. {
  2095. if (count > 1)
  2096. {
  2097. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2098. }
  2099. else
  2100. {
  2101. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2102. }
  2103. }
  2104. }
  2105. }
  2106. return result;
  2107. }
  2108. /// <summary>
  2109. /// 机票费用录入,删除
  2110. /// </summary>
  2111. /// <param name="dto"></param>
  2112. /// <returns></returns>
  2113. [HttpPost]
  2114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2115. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2116. {
  2117. try
  2118. {
  2119. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2120. if (res)
  2121. {
  2122. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2123. {
  2124. IsDel = 1,
  2125. DeleteUserId = dto.DeleteUserId,
  2126. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2127. }).ExecuteCommandAsync();
  2128. return Ok(JsonView(true, "删除成功!"));
  2129. }
  2130. return Ok(JsonView(false, "删除失败!"));
  2131. }
  2132. catch (Exception ex)
  2133. {
  2134. return Ok(JsonView(false, "程序错误!"));
  2135. throw;
  2136. }
  2137. }
  2138. /// <summary>
  2139. /// 导出机票录入报表
  2140. /// </summary>
  2141. /// <param name="dto"></param>
  2142. /// <returns></returns>
  2143. [HttpPost]
  2144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2145. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2146. {
  2147. try
  2148. {
  2149. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2150. if (groupData.Code != 0)
  2151. {
  2152. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2153. }
  2154. else
  2155. {
  2156. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2157. if (AirTicketReservations.Count != 0)
  2158. {
  2159. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2160. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2161. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2162. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2163. WorkbookDesigner designer = new WorkbookDesigner();
  2164. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2165. decimal countCost = 0;
  2166. foreach (var item in AirTicketReservations)
  2167. {
  2168. #region 处理客人姓名
  2169. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2170. item.ClientName = clientNames;
  2171. #endregion
  2172. if (item.BankType == "其他")
  2173. {
  2174. item.BankNo = "--";
  2175. }
  2176. else
  2177. {
  2178. if (!string.IsNullOrEmpty(item.BankType))
  2179. {
  2180. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2181. }
  2182. }
  2183. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2184. item.Price = System.Decimal.Round(item.Price, 2);
  2185. countCost += Convert.ToDecimal(item.Price);
  2186. }
  2187. designer.SetDataSource("Export", AirTicketReservations);
  2188. designer.SetDataSource("ExportDiCode", diCode);
  2189. designer.SetDataSource("ExportDiName", diName);
  2190. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2191. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2192. designer.Process();
  2193. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2194. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2195. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2196. return Ok(JsonView(true, "成功", url = rst));
  2197. }
  2198. else
  2199. {
  2200. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2201. }
  2202. }
  2203. }
  2204. catch (Exception ex)
  2205. {
  2206. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2207. throw;
  2208. }
  2209. }
  2210. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2211. /// <summary>
  2212. /// 行程单导出
  2213. /// </summary>
  2214. /// <param name="dto"></param>
  2215. /// <returns></returns>
  2216. [HttpPost]
  2217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2218. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2219. {
  2220. try
  2221. {
  2222. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2223. if (groupData.Code != 0)
  2224. {
  2225. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2226. }
  2227. else
  2228. {
  2229. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2230. if (dto.Language == "CN")
  2231. {
  2232. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2233. DocumentBuilder builder = new DocumentBuilder(doc);
  2234. int tableIndex = 0;//表格索引
  2235. //得到文档中的第一个表格
  2236. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2237. foreach (var item in _AirTicketReservations)
  2238. {
  2239. #region 处理固定数据
  2240. string[] FlightsCode = item.FlightsCode.Split('/');
  2241. if (FlightsCode.Length != 0)
  2242. {
  2243. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2244. if (_AirCompany != null)
  2245. {
  2246. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2247. }
  2248. else
  2249. {
  2250. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2251. }
  2252. }
  2253. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2254. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2255. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2256. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2257. string name = "";
  2258. foreach (string clientName in nameArray)
  2259. {
  2260. if (!name.Contains(clientName))
  2261. {
  2262. name += clientName + ",";
  2263. }
  2264. }
  2265. if (!string.IsNullOrWhiteSpace(name))
  2266. {
  2267. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2268. }
  2269. else
  2270. {
  2271. table.Range.Bookmarks["ClientName"].Text = "--";
  2272. }
  2273. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2274. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2275. table.Range.Bookmarks["JointTicket"].Text = "--";
  2276. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2277. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2278. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2279. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2280. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2281. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2282. #endregion
  2283. #region 循环数据处理
  2284. List<AirInfo> airs = new List<AirInfo>();
  2285. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2286. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2287. for (int i = 0; i < FlightsCode.Length; i++)
  2288. {
  2289. AirInfo air = new AirInfo();
  2290. string[] tempstr = DayArray[i]
  2291. .Replace("\r\n", string.Empty)
  2292. .Replace("\\r\\n", string.Empty)
  2293. .TrimStart().TrimEnd()
  2294. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2295. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2296. string starCity = "";
  2297. if (star_Three != null)
  2298. {
  2299. starCity = star_Three.AirPort;
  2300. }
  2301. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2302. string EndCity = "";
  2303. if (End_Three != null)
  2304. {
  2305. EndCity = End_Three.AirPort;
  2306. }
  2307. air.Destination = starCity + "/" + EndCity;
  2308. air.Flight = FlightsCode[i];
  2309. air.SeatingClass = item.CTypeName;
  2310. string dateTime = tempstr[2];
  2311. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2312. air.FlightDate = DateTemp;
  2313. air.DepartureTime = tempstr[5];
  2314. air.LandingTime = tempstr[6];
  2315. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2316. air.TicketStatus = "--";
  2317. air.Luggage = "--";
  2318. air.DepartureTerminal = "--";
  2319. air.LandingTerminal = "--";
  2320. airs.Add(air);
  2321. }
  2322. int row = 13;
  2323. for (int i = 0; i < airs.Count; i++)
  2324. {
  2325. if (airs.Count > 2)
  2326. {
  2327. for (int j = 0; j < airs.Count - 2; j++)
  2328. {
  2329. var CopyRow = table.Rows[12].Clone(true);
  2330. table.Rows.Add(CopyRow);
  2331. }
  2332. }
  2333. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2334. int index = 0;
  2335. foreach (PropertyInfo property in properties)
  2336. {
  2337. string value = property.GetValue(airs[i]).ToString();
  2338. Cell ishcel0 = table.Rows[row].Cells[index];
  2339. Paragraph p = new Paragraph(doc);
  2340. string s = value;
  2341. p.AppendChild(new Run(doc, s));
  2342. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2343. ishcel0.AppendChild(p);
  2344. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2345. index++;
  2346. }
  2347. row++;
  2348. }
  2349. #endregion
  2350. Paragraph lastParagraph = new Paragraph(doc);
  2351. //第一个表格末尾加段落
  2352. table.ParentNode.InsertAfter(lastParagraph, table);
  2353. //复制第一个表格
  2354. Table cloneTable = (Table)table.Clone(true);
  2355. //在文档末尾段落后面加入复制的表格
  2356. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2357. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2358. {
  2359. int rownewsIndex = 13;
  2360. for (int i = 0; i < 2; i++)
  2361. {
  2362. var CopyRow = table.Rows[12].Clone(true);
  2363. table.Rows.RemoveAt(13);
  2364. table.Rows.Add(CopyRow);
  2365. rownewsIndex++;
  2366. }
  2367. }
  2368. else
  2369. {
  2370. table.Rows.RemoveAt(12);
  2371. }
  2372. cloneTable.Rows.RemoveAt(12);
  2373. }
  2374. if (_AirTicketReservations.Count != 0)
  2375. {
  2376. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2377. if (FlightsCode.Length != 0)
  2378. {
  2379. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2380. if (_AirCompany != null)
  2381. {
  2382. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2383. }
  2384. else
  2385. {
  2386. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2387. }
  2388. }
  2389. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2390. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2391. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2392. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2393. string name = "";
  2394. foreach (string clientName in nameArray)
  2395. {
  2396. if (!name.Contains(clientName))
  2397. {
  2398. name += clientName + ",";
  2399. }
  2400. }
  2401. if (!string.IsNullOrWhiteSpace(name))
  2402. {
  2403. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2404. }
  2405. else
  2406. {
  2407. table.Range.Bookmarks["ClientName"].Text = "--";
  2408. }
  2409. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2410. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2411. table.Range.Bookmarks["JointTicket"].Text = "--";
  2412. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2413. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2414. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2415. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2416. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2417. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2418. }
  2419. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2420. //保存合并后的文档
  2421. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2422. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2423. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2424. return Ok(JsonView(true, "成功!", rst));
  2425. }
  2426. else
  2427. {
  2428. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2429. DocumentBuilder builder = new DocumentBuilder(doc);
  2430. int tableIndex = 0;//表格索引
  2431. //得到文档中的第一个表格
  2432. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2433. List<string> texts = new List<string>();
  2434. foreach (var item in _AirTicketReservations)
  2435. {
  2436. string[] FlightsCode = item.FlightsCode.Split('/');
  2437. if (FlightsCode.Length != 0)
  2438. {
  2439. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2440. if (_AirCompany != null)
  2441. {
  2442. if (!transDic.ContainsKey(_AirCompany.CnName))
  2443. {
  2444. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2445. }
  2446. }
  2447. else
  2448. {
  2449. if (!transDic.ContainsKey("--"))
  2450. {
  2451. transDic.Add("--", "--");
  2452. }
  2453. }
  2454. }
  2455. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2456. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2457. string name = "";
  2458. foreach (string clientName in nameArray)
  2459. {
  2460. name += clientName + ",";
  2461. }
  2462. if (!texts.Contains(name))
  2463. {
  2464. texts.Add(name);
  2465. }
  2466. List<AirInfo> airs = new List<AirInfo>();
  2467. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2468. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2469. for (int i = 0; i < FlightsCode.Length; i++)
  2470. {
  2471. AirInfo air = new AirInfo();
  2472. string[] tempstr = DayArray[i]
  2473. .Replace("\r\n", string.Empty)
  2474. .Replace("\\r\\n", string.Empty)
  2475. .TrimStart().TrimEnd()
  2476. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2477. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2478. if (star_Three != null)
  2479. {
  2480. if (!transDic.ContainsKey(star_Three.AirPort))
  2481. {
  2482. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2483. }
  2484. }
  2485. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2486. if (End_Three != null)
  2487. {
  2488. if (!transDic.ContainsKey(End_Three.AirPort))
  2489. {
  2490. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2491. }
  2492. }
  2493. if (!texts.Contains(item.CTypeName))
  2494. {
  2495. texts.Add(item.CTypeName);
  2496. }
  2497. }
  2498. }
  2499. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2500. if (transData.Count > 0)
  2501. {
  2502. foreach (TranslateResult item in transData)
  2503. {
  2504. if (!transDic.ContainsKey(item.Query))
  2505. {
  2506. transDic.Add(item.Query, item.Translation);
  2507. }
  2508. }
  2509. }
  2510. foreach (var item in _AirTicketReservations)
  2511. {
  2512. #region 处理固定数据
  2513. string[] FlightsCode = item.FlightsCode.Split('/');
  2514. if (FlightsCode.Length != 0)
  2515. {
  2516. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2517. if (_AirCompany != null)
  2518. {
  2519. string str = "--";
  2520. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2521. if (!string.IsNullOrEmpty(translateResult))
  2522. {
  2523. str = translateResult;
  2524. str = _airTicketResRep.Processing(str);
  2525. }
  2526. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2527. }
  2528. else
  2529. {
  2530. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2531. }
  2532. }
  2533. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2534. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2535. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2536. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2537. string names = "";
  2538. foreach (string clientName in nameArray)
  2539. {
  2540. names += clientName + ",";
  2541. }
  2542. if (!string.IsNullOrWhiteSpace(names))
  2543. {
  2544. string str = "--";
  2545. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2546. if (!string.IsNullOrEmpty(translateResult))
  2547. {
  2548. str = translateResult;
  2549. str = _airTicketResRep.Processing(str);
  2550. }
  2551. table.Range.Bookmarks["ClientName"].Text = str;
  2552. }
  2553. else
  2554. {
  2555. table.Range.Bookmarks["ClientName"].Text = "--";
  2556. }
  2557. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2558. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2559. table.Range.Bookmarks["JointTicket"].Text = "--";
  2560. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2561. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2562. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2563. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2564. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2565. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2566. #endregion
  2567. #region 循环数据处理
  2568. List<AirInfo> airs = new List<AirInfo>();
  2569. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2570. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2571. for (int i = 0; i < FlightsCode.Length; i++)
  2572. {
  2573. AirInfo air = new AirInfo();
  2574. string[] tempstr = DayArray[i]
  2575. .Replace("\r\n", string.Empty)
  2576. .Replace("\\r\\n", string.Empty)
  2577. .TrimStart().TrimEnd()
  2578. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2579. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2580. string starCity = "";
  2581. if (star_Three != null)
  2582. {
  2583. string str2 = "--";
  2584. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2585. if (!string.IsNullOrEmpty(translateResult2))
  2586. {
  2587. str2 = translateResult2;
  2588. str2 = _airTicketResRep.Processing(str2);
  2589. }
  2590. starCity = str2;
  2591. }
  2592. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2593. string EndCity = "";
  2594. if (End_Three != null)
  2595. {
  2596. string str1 = "--";
  2597. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2598. if (!string.IsNullOrEmpty(translateResult1))
  2599. {
  2600. str1 = translateResult1;
  2601. str1 = _airTicketResRep.Processing(str1);
  2602. }
  2603. EndCity = str1;
  2604. }
  2605. air.Destination = starCity + "/" + EndCity;
  2606. air.Flight = FlightsCode[i];
  2607. string str = "--";
  2608. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2609. if (!string.IsNullOrEmpty(translateResult))
  2610. {
  2611. str = translateResult;
  2612. str = _airTicketResRep.Processing(str);
  2613. }
  2614. air.SeatingClass = str;
  2615. string dateTime = tempstr[2];
  2616. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2617. air.FlightDate = DateTemp;
  2618. air.DepartureTime = tempstr[5];
  2619. air.LandingTime = tempstr[6];
  2620. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2621. air.TicketStatus = "--";
  2622. air.Luggage = "--";
  2623. air.DepartureTerminal = "--";
  2624. air.LandingTerminal = "--";
  2625. airs.Add(air);
  2626. }
  2627. int row = 13;
  2628. for (int i = 0; i < airs.Count; i++)
  2629. {
  2630. if (airs.Count > 2)
  2631. {
  2632. for (int j = 0; j < airs.Count - 2; j++)
  2633. {
  2634. var CopyRow = table.Rows[12].Clone(true);
  2635. table.Rows.Add(CopyRow);
  2636. }
  2637. }
  2638. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2639. int index = 0;
  2640. foreach (PropertyInfo property in properties)
  2641. {
  2642. string value = property.GetValue(airs[i]).ToString();
  2643. Cell ishcel0 = table.Rows[row].Cells[index];
  2644. Paragraph p = new Paragraph(doc);
  2645. string s = value;
  2646. p.AppendChild(new Run(doc, s));
  2647. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2648. ishcel0.AppendChild(p);
  2649. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2650. //ishcel0.CellFormat.VerticalAlignment=
  2651. index++;
  2652. }
  2653. row++;
  2654. }
  2655. #endregion
  2656. Paragraph lastParagraph = new Paragraph(doc);
  2657. //第一个表格末尾加段落
  2658. table.ParentNode.InsertAfter(lastParagraph, table);
  2659. //复制第一个表格
  2660. Table cloneTable = (Table)table.Clone(true);
  2661. //在文档末尾段落后面加入复制的表格
  2662. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2663. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2664. {
  2665. int rownewsIndex = 13;
  2666. for (int i = 0; i < 2; i++)
  2667. {
  2668. var CopyRow = table.Rows[12].Clone(true);
  2669. table.Rows.RemoveAt(13);
  2670. table.Rows.Add(CopyRow);
  2671. rownewsIndex++;
  2672. }
  2673. }
  2674. else
  2675. {
  2676. table.Rows.RemoveAt(12);
  2677. }
  2678. cloneTable.Rows.RemoveAt(12);
  2679. }
  2680. if (_AirTicketReservations.Count != 0)
  2681. {
  2682. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2683. if (FlightsCode.Length != 0)
  2684. {
  2685. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2686. if (_AirCompany != null)
  2687. {
  2688. string str = "--";
  2689. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2690. if (!string.IsNullOrEmpty(translateResult))
  2691. {
  2692. str = translateResult;
  2693. str = _airTicketResRep.Processing(str);
  2694. }
  2695. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2696. }
  2697. else
  2698. {
  2699. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2700. }
  2701. }
  2702. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2703. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2704. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2705. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2706. string names = "";
  2707. foreach (string clientName in nameArray)
  2708. {
  2709. names += clientName + ",";
  2710. }
  2711. if (!string.IsNullOrWhiteSpace(names))
  2712. {
  2713. string str = "--";
  2714. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2715. if (!string.IsNullOrEmpty(translateResult))
  2716. {
  2717. str = translateResult;
  2718. str = _airTicketResRep.Processing(str);
  2719. }
  2720. table.Range.Bookmarks["ClientName"].Text = str;
  2721. }
  2722. else
  2723. {
  2724. table.Range.Bookmarks["ClientName"].Text = "--";
  2725. }
  2726. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2727. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2728. table.Range.Bookmarks["JointTicket"].Text = "--";
  2729. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2730. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2731. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2732. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2733. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2734. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2735. }
  2736. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2737. //保存合并后的文档
  2738. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2739. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2740. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2741. return Ok(JsonView(true, "成功!", rst));
  2742. }
  2743. }
  2744. }
  2745. catch (Exception ex)
  2746. {
  2747. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2748. throw;
  2749. }
  2750. }
  2751. #endregion
  2752. #region 团组增减款项 --> 其他款项
  2753. /// <summary>
  2754. /// 团组增减款项下拉框绑定
  2755. /// </summary>
  2756. /// <param name="dto"></param>
  2757. /// <returns></returns>
  2758. [HttpPost]
  2759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2760. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2761. {
  2762. #region 参数验证
  2763. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2764. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2765. #endregion
  2766. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2767. }
  2768. /// <summary>
  2769. /// 根据团组Id查询团组增减款项
  2770. /// </summary>
  2771. /// <param name="dto"></param>
  2772. /// <returns></returns>
  2773. [HttpPost]
  2774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2775. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2776. {
  2777. #region 参数验证
  2778. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2779. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2780. #endregion
  2781. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2782. }
  2783. /// <summary>
  2784. /// 团组增减款项操作(Status:1.新增,2.修改)
  2785. /// </summary>
  2786. /// <param name="dto"></param>
  2787. /// <returns></returns>
  2788. [HttpPost]
  2789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2790. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2791. {
  2792. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2793. if (groupData.Code != 200)
  2794. {
  2795. return Ok(JsonView(false, groupData.Msg));
  2796. }
  2797. #region 应用推送
  2798. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2799. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2800. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2801. #endregion
  2802. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2803. }
  2804. /// <summary>
  2805. /// 团组增减款项操作 删除
  2806. /// </summary>
  2807. /// <param name="dto"></param>
  2808. /// <returns></returns>
  2809. [HttpPost]
  2810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2811. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2812. {
  2813. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2814. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2815. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2816. if (res.Code == 0)
  2817. {
  2818. return Ok(JsonView(true, "删除成功!"));
  2819. }
  2820. return Ok(JsonView(false, "删除失败!"));
  2821. }
  2822. /// <summary>
  2823. /// 根据团组增减款项Id查询
  2824. /// </summary>
  2825. /// <param name="dto"></param>
  2826. /// <returns></returns>
  2827. [HttpPost]
  2828. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2829. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2830. {
  2831. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2832. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2833. }
  2834. /// <summary>
  2835. /// 查询供应商名称
  2836. /// </summary>
  2837. /// <param name="dto"></param>
  2838. /// <returns></returns>
  2839. [HttpPost]
  2840. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2841. {
  2842. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2843. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2844. ?? new List<Grp_DecreasePayments>();
  2845. dbResult = dbResult.Distinct(new
  2846. ProductComparer()).ToList();
  2847. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2848. {
  2849. x.Id,
  2850. x.SupplierAddress,
  2851. x.SupplierArea,
  2852. x.SupplierContact,
  2853. x.SupplierContactNumber,
  2854. x.SupplierEmail,
  2855. x.SupplierName,
  2856. x.SupplierSocialAccount,
  2857. x.SupplierTypeId,
  2858. }).ToList());
  2859. return Ok(jw);
  2860. }
  2861. #endregion
  2862. #region 文件上传、删除
  2863. /// <summary>
  2864. /// region 文件上传 可以带参数
  2865. /// </summary>
  2866. /// <param name="file"></param>
  2867. /// <returns></returns>
  2868. [HttpPost]
  2869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2870. public async Task<IActionResult> UploadProject(IFormFile file)
  2871. {
  2872. try
  2873. {
  2874. var TypeName = Request.Headers["TypeName"].ToString();
  2875. if (file != null)
  2876. {
  2877. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2878. //文件名称
  2879. string projectFileName = file.FileName;
  2880. //上传的文件的路径
  2881. string filePath = "";
  2882. if (TypeName == "A")//A代表团组增减款项
  2883. {
  2884. if (!Directory.Exists(fileDir))
  2885. {
  2886. Directory.CreateDirectory(fileDir);
  2887. }
  2888. //上传的文件的路径
  2889. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2890. }
  2891. else if (TypeName == "B")//B代表商邀相关文件
  2892. {
  2893. if (!Directory.Exists(fileDir))
  2894. {
  2895. Directory.CreateDirectory(fileDir);
  2896. }
  2897. //上传的文件的路径
  2898. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2899. }
  2900. using (FileStream fs = System.IO.File.Create(filePath))
  2901. {
  2902. file.CopyTo(fs);
  2903. fs.Flush();
  2904. }
  2905. return Ok(JsonView(true, "上传成功!", projectFileName));
  2906. }
  2907. else
  2908. {
  2909. return Ok(JsonView(false, "上传失败!"));
  2910. }
  2911. }
  2912. catch (Exception ex)
  2913. {
  2914. return Ok(JsonView(false, "程序错误!"));
  2915. throw;
  2916. }
  2917. }
  2918. /// <summary>
  2919. /// 删除指定文件
  2920. /// </summary>
  2921. /// <param name="dto"></param>
  2922. /// <returns></returns>
  2923. [HttpPost]
  2924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2925. public async Task<IActionResult> DelFile(DelFileDto dto)
  2926. {
  2927. try
  2928. {
  2929. var TypeName = Request.Headers["TypeName"].ToString();
  2930. string filePath = "";
  2931. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2932. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2933. int id = 0;
  2934. if (TypeName == "A")
  2935. {
  2936. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2937. // 删除该文件
  2938. System.IO.File.Delete(filePath);
  2939. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2940. }
  2941. else if (TypeName == "B")
  2942. {
  2943. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2944. // 删除该文件
  2945. System.IO.File.Delete(filePath);
  2946. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2947. }
  2948. if (id != 0)
  2949. {
  2950. return Ok(JsonView(true, "成功!"));
  2951. }
  2952. else
  2953. {
  2954. return Ok(JsonView(false, "失败!"));
  2955. }
  2956. }
  2957. catch (Exception ex)
  2958. {
  2959. return Ok(JsonView(false, "程序错误!"));
  2960. throw;
  2961. }
  2962. }
  2963. #endregion
  2964. #region 商邀费用录入
  2965. /// <summary>
  2966. /// 根据团组Id查询商邀费用列表
  2967. /// </summary>
  2968. /// <param name="dto"></param>
  2969. /// <returns></returns>
  2970. [HttpPost]
  2971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2972. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2973. {
  2974. try
  2975. {
  2976. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2977. if (groupData.Code != 0)
  2978. {
  2979. return Ok(JsonView(false, groupData.Msg));
  2980. }
  2981. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2982. }
  2983. catch (Exception ex)
  2984. {
  2985. return Ok(JsonView(false, "程序错误!"));
  2986. throw;
  2987. }
  2988. }
  2989. //
  2990. /// <summary>
  2991. /// 商邀费用 Info Page 基础数据源
  2992. /// </summary>
  2993. /// <param name="dto"></param>
  2994. /// <returns></returns>
  2995. [HttpPost]
  2996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2997. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2998. {
  2999. try
  3000. {
  3001. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3002. if (groupData.Code != 0)
  3003. {
  3004. return Ok(JsonView(false, groupData.Msg));
  3005. }
  3006. return Ok(JsonView(true, "操作成功", groupData.Data));
  3007. }
  3008. catch (Exception ex)
  3009. {
  3010. return Ok(JsonView(false, ex.Message));
  3011. throw;
  3012. }
  3013. }
  3014. /// <summary>
  3015. /// 根据商邀费用ID查询C表和商邀费用数据
  3016. /// </summary>
  3017. /// <param name="dto"></param>
  3018. /// <returns></returns>
  3019. [HttpPost]
  3020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3021. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3022. {
  3023. try
  3024. {
  3025. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3026. if (groupData.Code != 0)
  3027. {
  3028. return Ok(JsonView(false, groupData.Msg));
  3029. }
  3030. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3031. }
  3032. catch (Exception ex)
  3033. {
  3034. return Ok(JsonView(false, ex.Message));
  3035. throw;
  3036. }
  3037. }
  3038. /// <summary>
  3039. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3040. /// </summary>
  3041. /// <param name="dto"></param>
  3042. /// <returns></returns>
  3043. [HttpPost]
  3044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3045. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  3046. {
  3047. try
  3048. {
  3049. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  3050. if (groupData.Code != 0)
  3051. {
  3052. return Ok(JsonView(false, groupData.Msg));
  3053. }
  3054. #region 应用推送
  3055. try
  3056. {
  3057. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3058. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3059. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3060. }
  3061. catch (Exception ex)
  3062. {
  3063. }
  3064. #endregion
  3065. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3066. }
  3067. catch (Exception ex)
  3068. {
  3069. return Ok(JsonView(false, "程序错误!"));
  3070. throw;
  3071. }
  3072. }
  3073. /// <summary>
  3074. /// 商邀删除
  3075. /// </summary>
  3076. /// <param name="dto"></param>
  3077. /// <returns></returns>
  3078. [HttpPost]
  3079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3080. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  3081. {
  3082. try
  3083. {
  3084. _sqlSugar.BeginTran();
  3085. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3086. .SetColumns(it => new Grp_InvitationOfficialActivities()
  3087. {
  3088. IsDel = 1,
  3089. DeleteUserId = dto.DeleteUserId,
  3090. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3091. })
  3092. .Where(it => it.Id == dto.Id)
  3093. .ExecuteCommand();
  3094. if (res1 > 0)
  3095. {
  3096. int _diId = 0;
  3097. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  3098. if (_ioaInfo != null)
  3099. {
  3100. _diId = _ioaInfo.DiId;
  3101. }
  3102. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  3103. .SetColumns(a => new Grp_CreditCardPayment()
  3104. {
  3105. IsDel = 1,
  3106. DeleteUserId = dto.DeleteUserId,
  3107. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  3108. })
  3109. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  3110. .ExecuteCommand();
  3111. if (res2 > 0)
  3112. {
  3113. _sqlSugar.CommitTran();
  3114. return Ok(JsonView(true, "删除成功!"));
  3115. }
  3116. }
  3117. _sqlSugar.RollbackTran();
  3118. return Ok(JsonView(false, "删除失败"));
  3119. }
  3120. catch (Exception ex)
  3121. {
  3122. _sqlSugar.RollbackTran();
  3123. return Ok(JsonView(false, ex.Message));
  3124. }
  3125. }
  3126. /// <summary>
  3127. /// 团组模块文件上传
  3128. /// </summary>
  3129. /// <param name="dto"></param>
  3130. /// <returns></returns>
  3131. [HttpPost]
  3132. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  3133. {
  3134. var jw = JsonView(false);
  3135. if (dto.File == null)
  3136. {
  3137. jw.Msg = "无文件信息!";
  3138. return Ok(jw);
  3139. }
  3140. var nameSp = dto.File.FileName.Split(".");
  3141. if (nameSp.Length < 2)
  3142. {
  3143. jw.Msg = "拓展名称有误!";
  3144. return Ok(jw);
  3145. }
  3146. var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  3147. if (!existsName.Contains(nameSp[1].ToUpper()))
  3148. {
  3149. jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  3150. return Ok(jw);
  3151. }
  3152. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  3153. if (Ctable == null)
  3154. {
  3155. jw.Msg = "Ctable指向有误!";
  3156. return Ok(jw);
  3157. }
  3158. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  3159. if (groupInfo == null)
  3160. {
  3161. jw.Msg = "团组信息不存在!";
  3162. return Ok(jw);
  3163. }
  3164. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  3165. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3166. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  3167. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  3168. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  3169. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  3170. try
  3171. {
  3172. if (!Directory.Exists(fileBase))
  3173. {
  3174. Directory.CreateDirectory(fileBase);
  3175. }
  3176. var saveFilePath = fileBase +"\\"+ dto.File.FileName;
  3177. Grp_GroupModelFile file = new Grp_GroupModelFile()
  3178. {
  3179. Cid = dto.Cid,
  3180. CreateTime = DateTime.Now,
  3181. CreateUserId = dto.Userid,
  3182. Ctable = dto.Ctable,
  3183. Diid = dto.Diid,
  3184. IsDel = 0,
  3185. FilePath = saveFilePath,
  3186. };
  3187. using (FileStream fs = System.IO.File.Create(saveFilePath))
  3188. {
  3189. dto.File.CopyTo(fs);
  3190. fs.Flush();
  3191. }
  3192. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(file).ExecuteCommand();
  3193. jw = JsonView(true, "保存成功!", new
  3194. {
  3195. url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  3196. });
  3197. }
  3198. catch (Exception ex)
  3199. {
  3200. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  3201. {
  3202. url = ""
  3203. }) ;
  3204. }
  3205. return Ok(jw);
  3206. }
  3207. #endregion
  3208. #region 团组英文资料
  3209. /// <summary>
  3210. /// 查询团组英文所有资料
  3211. /// </summary>
  3212. /// <param name="dto"></param>
  3213. /// <returns></returns>
  3214. [HttpPost]
  3215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3216. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3217. {
  3218. try
  3219. {
  3220. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3221. if (groupData.Code != 0)
  3222. {
  3223. return Ok(JsonView(false, groupData.Msg));
  3224. }
  3225. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3226. }
  3227. catch (Exception ex)
  3228. {
  3229. return Ok(JsonView(false, "程序错误!"));
  3230. throw;
  3231. }
  3232. }
  3233. /// <summary>
  3234. /// 团组英文资料操作(Status:1.新增,2.修改)
  3235. /// </summary>
  3236. /// <param name="dto"></param>
  3237. /// <returns></returns>
  3238. [HttpPost]
  3239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3240. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3241. {
  3242. try
  3243. {
  3244. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3245. if (groupData.Code != 0)
  3246. {
  3247. return Ok(JsonView(false, groupData.Msg));
  3248. }
  3249. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3250. }
  3251. catch (Exception ex)
  3252. {
  3253. return Ok(JsonView(false, "程序错误!"));
  3254. throw;
  3255. }
  3256. }
  3257. /// <summary>
  3258. /// 团组英文资料Id查询数据
  3259. /// </summary>
  3260. /// <param name="dto"></param>
  3261. /// <returns></returns>
  3262. [HttpPost]
  3263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3264. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3265. {
  3266. try
  3267. {
  3268. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3269. if (_DelegationEnData != null)
  3270. {
  3271. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3272. }
  3273. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3274. }
  3275. catch (Exception ex)
  3276. {
  3277. return Ok(JsonView(false, "程序错误!"));
  3278. throw;
  3279. }
  3280. }
  3281. /// <summary>
  3282. /// 团组英文资料删除
  3283. /// </summary>
  3284. /// <param name="dto"></param>
  3285. /// <returns></returns>
  3286. [HttpPost]
  3287. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3288. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3289. {
  3290. try
  3291. {
  3292. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3293. if (!res)
  3294. {
  3295. return Ok(JsonView(false, "删除失败"));
  3296. }
  3297. return Ok(JsonView(true, "删除成功!"));
  3298. }
  3299. catch (Exception ex)
  3300. {
  3301. return Ok(JsonView(false, "程序错误!"));
  3302. throw;
  3303. }
  3304. }
  3305. #endregion
  3306. #region 导出邀请函
  3307. /// <summary>
  3308. /// 导出邀请函页面初始化
  3309. /// </summary>
  3310. /// <param name="dto"></param>
  3311. /// <returns></returns>
  3312. [HttpPost]
  3313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3314. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3315. {
  3316. try
  3317. {
  3318. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3319. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3320. if (dto.DiId == 0)
  3321. {
  3322. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3323. }
  3324. else
  3325. {
  3326. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3327. }
  3328. return Ok(JsonView(true, "查询成功!", new
  3329. {
  3330. deleClient = crm_Deles,
  3331. delegations = grp_Delegations
  3332. }));
  3333. }
  3334. catch (Exception ex)
  3335. {
  3336. return Ok(JsonView(false, "程序错误!"));
  3337. throw;
  3338. }
  3339. }
  3340. /// <summary>
  3341. /// 导出邀请函
  3342. /// </summary>
  3343. /// <param name="dto"></param>
  3344. /// <returns></returns>
  3345. [HttpPost]
  3346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3347. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3348. {
  3349. #region 参数验证
  3350. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3351. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3352. #endregion
  3353. try
  3354. {
  3355. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3356. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3357. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3358. From Grp_TourClientList tcl
  3359. Left Join
  3360. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3361. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3362. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3363. From Crm_DeleClient dc
  3364. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3365. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3366. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3367. Where dc.IsDel = 0) temp
  3368. On temp.DcId =tcl.ClientId
  3369. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3370. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3371. List<string> texts = new List<string>();
  3372. if (datas.Count != 0)
  3373. {
  3374. foreach (TourClientListDetailsView item in datas)
  3375. {
  3376. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3377. {
  3378. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3379. }
  3380. else
  3381. {
  3382. string name = item.LastName + item.FirstName;
  3383. texts.Add(name);
  3384. }
  3385. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3386. {
  3387. if (!transDic.ContainsKey(item.Job))
  3388. {
  3389. texts.Add(item.Job);
  3390. }
  3391. }
  3392. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3393. {
  3394. texts.Add(item.CompanyFullName);
  3395. }
  3396. }
  3397. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3398. if (transData.Count > 0)
  3399. {
  3400. foreach (TranslateResult item in transData)
  3401. {
  3402. if (!transDic.ContainsKey(item.Query))
  3403. {
  3404. transDic.Add(item.Query, item.Translation);
  3405. }
  3406. }
  3407. }
  3408. List<GuestList> list = new List<GuestList>();
  3409. foreach (TourClientListDetailsView dele in datas)
  3410. {
  3411. GuestList guestList = new GuestList();
  3412. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3413. {
  3414. guestList.Name = dele.Pinyin;
  3415. }
  3416. else
  3417. {
  3418. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3419. guestList.Name = Name;
  3420. }
  3421. if (dele.Sex == 0)
  3422. {
  3423. guestList.Sex = "Male";
  3424. }
  3425. else if (dele.Sex == 1)
  3426. {
  3427. guestList.Sex = "Female";
  3428. }
  3429. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3430. if (!string.IsNullOrEmpty(dele.Job))
  3431. {
  3432. guestList.Job = dele.Job;
  3433. }
  3434. list.Add(guestList);
  3435. }
  3436. //载入模板
  3437. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3438. DocumentBuilder builder = new DocumentBuilder(doc);
  3439. //获取word里所有表格
  3440. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3441. //获取所填表格的序数
  3442. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3443. var rowStart = tableOne.Rows[0]; //获取第1行
  3444. //循环赋值
  3445. for (int i = 0; i < list.Count; i++)
  3446. {
  3447. builder.MoveToCell(0, i + 1, 0, 0);
  3448. builder.Write(list[i].Name.ToString());
  3449. builder.MoveToCell(0, i + 1, 1, 0);
  3450. builder.Write(list[i].Sex.ToString());
  3451. builder.MoveToCell(0, i + 1, 2, 0);
  3452. builder.Write(list[i].DOB.ToString());
  3453. builder.MoveToCell(0, i + 1, 3, 0);
  3454. builder.Write(list[i].Job.ToString());
  3455. }
  3456. //删除多余行
  3457. while (tableOne.Rows.Count > list.Count + 1)
  3458. {
  3459. tableOne.Rows.RemoveAt(list.Count + 1);
  3460. }
  3461. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3462. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3463. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3464. doc.Save(filePath);
  3465. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3466. return Ok(JsonView(true, "操作成功!", Url));
  3467. }
  3468. else
  3469. {
  3470. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3471. }
  3472. }
  3473. catch (Exception ex)
  3474. {
  3475. return Ok(JsonView(false, ex.Message));
  3476. throw;
  3477. }
  3478. }
  3479. #endregion
  3480. #region 团组经理模块 出入境费用
  3481. ///// <summary>
  3482. ///// 团组模块 - 出入境费用
  3483. ///// </summary>
  3484. ///// <returns></returns>
  3485. //[HttpPost]
  3486. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3487. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3488. //{
  3489. // try
  3490. // {
  3491. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3492. // if (data.Code != 0)
  3493. // {
  3494. // return Ok(JsonView(false, data.Msg));
  3495. // }
  3496. // return Ok(JsonView(true, "查询成功!"));
  3497. // }
  3498. // catch (Exception ex)
  3499. // {
  3500. // return Ok(JsonView(false, ex.Message));
  3501. // throw;
  3502. // }
  3503. //}
  3504. /// <summary>
  3505. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3506. /// </summary>
  3507. /// <returns></returns>
  3508. [HttpPost]
  3509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3510. public async Task<IActionResult> SetDayAndCostAreaChange()
  3511. {
  3512. try
  3513. {
  3514. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3515. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3516. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3517. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3518. foreach (var item in unite) //处理交集数据
  3519. {
  3520. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3521. }
  3522. foreach (var item in merge) //处理差集数据
  3523. {
  3524. int nationalTravelFeeId = 0;
  3525. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3526. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3527. else
  3528. {
  3529. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3530. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3531. }
  3532. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3533. }
  3534. //只更新dayAndCost 的 nationalTravelFeeId;
  3535. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3536. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3537. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3538. }
  3539. catch (Exception ex)
  3540. {
  3541. return Ok(JsonView(false, ex.Message));
  3542. throw;
  3543. }
  3544. }
  3545. /// <summary>
  3546. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3547. /// </summary>
  3548. /// <returns></returns>
  3549. [HttpPost]
  3550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3551. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3552. {
  3553. try
  3554. {
  3555. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3556. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3557. //SetDataInfoView
  3558. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3559. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3560. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3561. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3562. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3563. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3564. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3565. //默认币种显示
  3566. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3567. {
  3568. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3569. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3570. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3571. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3572. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3573. };
  3574. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3575. if (_currencyRate.Count > 0)
  3576. {
  3577. foreach (var item in _currencyInfos)
  3578. {
  3579. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3580. if (rateInfo != null)
  3581. {
  3582. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3583. rate1 *= 1.035M;
  3584. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3585. }
  3586. }
  3587. }
  3588. return Ok(JsonView(true, "查询成功!", new
  3589. {
  3590. GroupNameData = groupNameData.Data,
  3591. CurrencyData = _CurrencyData,
  3592. WordTypeData = _WordTypeData,
  3593. ExcelTypeData = _ExcelTypeData,
  3594. CurrencyInit = _currencyInfos
  3595. }));
  3596. }
  3597. catch (Exception ex)
  3598. {
  3599. return Ok(JsonView(false, ex.Message));
  3600. throw;
  3601. }
  3602. }
  3603. /// <summary>
  3604. /// 团组模块 - 出入境费用
  3605. /// 实时汇率 tips
  3606. /// 签证费用 tips
  3607. /// </summary>
  3608. /// <returns></returns>
  3609. [HttpPost]
  3610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3611. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3612. {
  3613. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3614. //默认币种显示
  3615. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3616. {
  3617. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3618. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3619. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3620. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3621. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3622. };
  3623. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3624. List<dynamic> reteInfos = new List<dynamic>();
  3625. if (_currencyRate.Count > 0)
  3626. {
  3627. foreach (var item in _currencyInfos)
  3628. {
  3629. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3630. if (rateInfo != null)
  3631. {
  3632. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3633. decimal rate1 = item.Rate;
  3634. rate1 *= 1.03M;
  3635. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3636. reteInfos.Add(new
  3637. {
  3638. currCode = item.CurrencyCode,
  3639. currName = item.CurrencyName,
  3640. rate = rate2,
  3641. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3642. });
  3643. }
  3644. }
  3645. }
  3646. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3647. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3648. return Ok(JsonView(true, "查询成功!", new
  3649. {
  3650. //GroupNameData = groupNameData.Data,
  3651. visaData = visaData.Data,
  3652. airData = airData.Data,
  3653. reteInfos = reteInfos
  3654. }));
  3655. }
  3656. /// <summary>
  3657. /// 团组模块 - 出入境费用 - Info
  3658. /// </summary>
  3659. /// <returns></returns>
  3660. [HttpPost]
  3661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3662. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3663. {
  3664. try
  3665. {
  3666. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3667. if (data.Code != 0)
  3668. {
  3669. return Ok(JsonView(false, data.Msg));
  3670. }
  3671. return Ok(JsonView(true, "查询成功!", data.Data));
  3672. }
  3673. catch (Exception ex)
  3674. {
  3675. return Ok(JsonView(false, ex.Message));
  3676. }
  3677. }
  3678. /// <summary>
  3679. /// 团组模块 - 出入境费用 - Add And Update
  3680. /// </summary>
  3681. /// <returns></returns>
  3682. [HttpPost]
  3683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3684. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3685. {
  3686. try
  3687. {
  3688. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3689. if (data.Code != 0)
  3690. {
  3691. return Ok(JsonView(false, data.Msg));
  3692. }
  3693. //生成默认文件pdf并且通知人员
  3694. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3695. {
  3696. DiId = dto.DiId,
  3697. ExportType = 1,
  3698. SubTypeId = 1005
  3699. }, "pdf");
  3700. //发送通知
  3701. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3702. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3703. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3704. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3705. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3706. return Ok(JsonView(true, data.Msg, data.Data));
  3707. }
  3708. catch (Exception ex)
  3709. {
  3710. return Ok(JsonView(false, ex.Message));
  3711. }
  3712. }
  3713. /// <summary>
  3714. /// 团组模块 - 出入境费用 - Confirm 费用
  3715. /// </summary>
  3716. /// <returns></returns>
  3717. [HttpPost]
  3718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3719. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3720. {
  3721. //TODO:测试完毕需把对应的用户ID更改
  3722. //1、数据表添加字段
  3723. //2、更改字段接口()
  3724. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3725. //3、确认成功 给财务发送消息
  3726. if (_view.Code == 200)
  3727. {
  3728. if (dto.Type == 1)
  3729. {
  3730. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3731. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  3732. }
  3733. }
  3734. return Ok(_view);
  3735. }
  3736. /// <summary>
  3737. /// 团组模块 - 出入境费用 - File downlaod
  3738. /// </summary>
  3739. /// <param name="dto"></param>
  3740. /// <returns></returns>
  3741. [HttpPost]
  3742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3743. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3744. {
  3745. try
  3746. {
  3747. if (dto.DiId < 1)
  3748. {
  3749. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3750. }
  3751. if (dto.ExportType < 1)
  3752. {
  3753. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3754. }
  3755. if (dto.SubTypeId < 1)
  3756. {
  3757. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3758. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3759. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3760. 3 团组成员名单 1 团组成员名单"));
  3761. }
  3762. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3763. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3764. if (_EnterExitCosts == null)
  3765. {
  3766. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3767. }
  3768. //数据源
  3769. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3770. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3771. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3772. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3773. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3774. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3775. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3776. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3777. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3778. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3779. .Select((tcl, dc, cc) => new
  3780. {
  3781. Name = dc.LastName + dc.FirstName,
  3782. Sex = dc.Sex,
  3783. Birthday = dc.BirthDay,
  3784. Company = cc.CompanyFullName,
  3785. Job = dc.Job
  3786. })
  3787. .ToList();
  3788. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3789. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3790. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3791. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3792. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3793. if (dto.ExportType == 1) //明细表
  3794. {
  3795. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3796. {
  3797. //获取模板
  3798. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3799. //载入模板
  3800. Document doc = new Document(tempPath);
  3801. DocumentBuilder builder = new DocumentBuilder(doc);
  3802. //利用键值对存放数据
  3803. Dictionary<string, string> dic = new Dictionary<string, string>();
  3804. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3805. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3806. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3807. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3808. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3809. string row1_1 = "";
  3810. if (_EnterExitCosts.Visa > 0)
  3811. {
  3812. //insidePayTotal += _EnterExitCosts.Visa;
  3813. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3814. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3815. {
  3816. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3817. }
  3818. }
  3819. string row1_2 = "";
  3820. if (_EnterExitCosts.YiMiao > 0)
  3821. {
  3822. //insidePayTotal += _EnterExitCosts.YiMiao;
  3823. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3824. }
  3825. if (_EnterExitCosts.HeSuan > 0)
  3826. {
  3827. //insidePayTotal += _EnterExitCosts.HeSuan;
  3828. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3829. }
  3830. if (_EnterExitCosts.Service > 0)
  3831. {
  3832. //insidePayTotal += _EnterExitCosts.Service;
  3833. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3834. }
  3835. string row1_3 = "";
  3836. if (_EnterExitCosts.Safe > 0)
  3837. {
  3838. //insidePayTotal += _EnterExitCosts.Safe;
  3839. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3840. }
  3841. if (_EnterExitCosts.Ticket > 0)
  3842. {
  3843. //insidePayTotal += _EnterExitCosts.Ticket;
  3844. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3845. }
  3846. string row1 = "";
  3847. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3848. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3849. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3850. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3851. dic.Add("Row1Str", row1);
  3852. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3853. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3854. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3855. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3856. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3857. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3858. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3859. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3860. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3861. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3862. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3863. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3864. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3865. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3866. #region 填充word模板书签内容
  3867. foreach (var key in dic.Keys)
  3868. {
  3869. builder.MoveToBookmark(key);
  3870. builder.Write(dic[key]);
  3871. }
  3872. #endregion
  3873. #region 填充word表格内容
  3874. ////获读取指定表格方法二
  3875. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3876. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3877. for (int i = 0; i < dac1.Count; i++)
  3878. {
  3879. Grp_DayAndCost dac = dac1[i];
  3880. if (dac == null) continue;
  3881. builder.MoveToCell(0, i, 0, 0);
  3882. builder.Write("第" + dac.Days.ToString() + "晚:");
  3883. builder.MoveToCell(0, i, 1, 0);
  3884. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3885. //builder.Write(dac.Place == null ? "" : dac.Place);
  3886. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3887. builder.MoveToCell(0, i, 2, 0);
  3888. builder.Write("费用标准:");
  3889. string curr = "";
  3890. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3891. if (currData != null)
  3892. {
  3893. curr = currData.Name;
  3894. }
  3895. builder.MoveToCell(0, i, 3, 0);
  3896. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3897. builder.MoveToCell(0, i, 4, 0);
  3898. builder.Write("费用小计:");
  3899. builder.MoveToCell(0, i, 5, 0);
  3900. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3901. }
  3902. //删除多余行
  3903. while (table1.Rows.Count > dac1.Count)
  3904. {
  3905. table1.Rows.RemoveAt(dac1.Count);
  3906. }
  3907. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3908. for (int i = 0; i < dac2.Count; i++)
  3909. {
  3910. Grp_DayAndCost dac = dac2[i];
  3911. if (dac == null) continue;
  3912. builder.MoveToCell(1, i, 0, 0);
  3913. builder.Write("第" + dac.Days.ToString() + "天:");
  3914. builder.MoveToCell(1, i, 1, 0);
  3915. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3916. builder.MoveToCell(1, i, 2, 0);
  3917. builder.Write("费用标准:");
  3918. string curr = "";
  3919. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3920. if (currData != null)
  3921. {
  3922. curr = currData.Name;
  3923. }
  3924. builder.MoveToCell(1, i, 3, 0);
  3925. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3926. builder.MoveToCell(1, i, 4, 0);
  3927. builder.Write("费用小计:");
  3928. builder.MoveToCell(1, i, 5, 0);
  3929. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3930. }
  3931. //删除多余行
  3932. while (table2.Rows.Count > dac2.Count)
  3933. {
  3934. table2.Rows.RemoveAt(dac2.Count);
  3935. }
  3936. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3937. for (int i = 0; i < dac3.Count; i++)
  3938. {
  3939. Grp_DayAndCost dac = dac3[i];
  3940. if (dac == null) continue;
  3941. builder.MoveToCell(2, i, 0, 0);
  3942. builder.Write("第" + dac.Days.ToString() + "天:");
  3943. builder.MoveToCell(2, i, 1, 0);
  3944. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3945. builder.MoveToCell(2, i, 2, 0);
  3946. builder.Write("费用标准:");
  3947. string curr = "";
  3948. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3949. if (currData != null)
  3950. {
  3951. curr = currData.Name;
  3952. }
  3953. builder.MoveToCell(2, i, 3, 0);
  3954. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3955. builder.MoveToCell(2, i, 4, 0);
  3956. builder.Write("费用小计:");
  3957. builder.MoveToCell(2, i, 5, 0);
  3958. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3959. }
  3960. //删除多余行
  3961. while (table3.Rows.Count > dac3.Count)
  3962. {
  3963. table3.Rows.RemoveAt(dac3.Count);
  3964. }
  3965. #endregion
  3966. //文件名
  3967. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3968. AsposeHelper.removewatermark_v2180();
  3969. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3970. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3971. return Ok(JsonView(true, "成功", new { Url = url }));
  3972. }
  3973. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3974. {
  3975. //获取模板
  3976. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3977. //载入模板
  3978. Document doc = new Document(tempPath);
  3979. DocumentBuilder builder = new DocumentBuilder(doc);
  3980. Dictionary<string, string> dic = new Dictionary<string, string>();
  3981. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3982. {
  3983. List<string> list = new List<string>();
  3984. try
  3985. {
  3986. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3987. foreach (var item in spilitArr)
  3988. {
  3989. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3990. var depCode = spDotandEmpty[2].Substring(0, 3);
  3991. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3992. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3993. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3994. list.Add(depName);
  3995. list.Add(arrName);
  3996. }
  3997. list = list.Distinct().ToList();
  3998. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3999. }
  4000. catch (Exception)
  4001. {
  4002. dic.Add("ReturnCode", "行程录入不正确!");
  4003. }
  4004. }
  4005. else
  4006. {
  4007. dic.Add("ReturnCode", "未录入行程!");
  4008. }
  4009. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4010. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4011. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4012. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4013. {
  4014. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4015. dic.Add("Day", sp.Days.ToString());
  4016. }
  4017. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4018. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4019. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4020. //dic.Add("Names", Names);
  4021. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4022. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4023. decimal dac1totalPrice = 0.00M;
  4024. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  4025. foreach (var dac in dac1)
  4026. {
  4027. if (dac.SubTotal == 0.00M)
  4028. {
  4029. continue;
  4030. }
  4031. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4032. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4033. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4034. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4035. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4036. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4037. builder.Write(currency);//币种
  4038. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4039. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4040. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4041. builder.Write("");//人数
  4042. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4043. builder.Write("");//天数
  4044. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4045. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4046. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4047. decimal rate = 0.00M;
  4048. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4049. builder.Write(rate.ToString("#0.0000"));//汇率
  4050. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4051. decimal rbmPrice = dac.SubTotal;
  4052. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4053. accommodationStartIndex++;
  4054. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4055. }
  4056. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4057. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  4058. {
  4059. table1.Rows.RemoveAt(i - 1);
  4060. foodandotherStartIndex--;
  4061. }
  4062. if (dac2.Count == dac3.Count)//国家 币种 金额
  4063. {
  4064. for (int i = 0; i < dac2.Count; i++)
  4065. {
  4066. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4067. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4068. }
  4069. }
  4070. decimal dac2totalPrice = 0.00M;
  4071. foreach (var dac in dac2)
  4072. {
  4073. if (dac.SubTotal == 0)
  4074. {
  4075. continue;
  4076. }
  4077. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4078. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  4079. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4080. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4081. builder.Write(currency);//币种
  4082. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4083. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4084. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4085. builder.Write("");//人数
  4086. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4087. builder.Write("");//天数
  4088. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4089. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4090. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4091. decimal rate = 0.00M;
  4092. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4093. builder.Write(rate.ToString("#0.0000"));//汇率
  4094. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4095. decimal rbmPrice = dac.SubTotal;
  4096. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4097. foodandotherStartIndex++;
  4098. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4099. }
  4100. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4101. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4102. {
  4103. table1.Rows.RemoveAt(i - 1);
  4104. }
  4105. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4106. string otherFeeStr = "";
  4107. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4108. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4109. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4110. if (otherFeeStr.Length > 0)
  4111. {
  4112. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4113. otherFeeStr = $"({otherFeeStr})";
  4114. dic.Add("OtherFeeStr", otherFeeStr);
  4115. }
  4116. //总计
  4117. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4118. //国际旅费
  4119. string outsideJJ = "";
  4120. string allPriceJJ = "";
  4121. if (_EnterExitCosts.SumJJC == 1)
  4122. {
  4123. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4124. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4125. }
  4126. string outsideGW = "";
  4127. string allPriceGW = "";
  4128. if (_EnterExitCosts.SumGWC == 1)
  4129. {
  4130. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  4131. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4132. }
  4133. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  4134. {
  4135. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4136. dic.Add("InTravelPrice", InTravelPriceStr);
  4137. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4138. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4139. }
  4140. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4141. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4142. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4143. foreach (var key in dic.Keys)
  4144. {
  4145. builder.MoveToBookmark(key);
  4146. builder.Write(dic[key]);
  4147. }
  4148. //模板文件名
  4149. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4150. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4151. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4152. return Ok(JsonView(true, "成功", new { Url = url }));
  4153. }
  4154. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4155. {
  4156. //获取模板
  4157. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4158. //载入模板
  4159. WorkbookDesigner designer = new WorkbookDesigner();
  4160. designer.Workbook = new Workbook(tempPath);
  4161. Dictionary<string, string> dic = new Dictionary<string, string>();
  4162. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4163. {
  4164. List<string> list = new List<string>();
  4165. try
  4166. {
  4167. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4168. foreach (var item in spilitArr)
  4169. {
  4170. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4171. var depCode = spDotandEmpty[2].Substring(0, 3);
  4172. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4173. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4174. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4175. list.Add(depName);
  4176. list.Add(arrName);
  4177. }
  4178. list = list.Distinct().ToList();
  4179. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4180. }
  4181. catch (Exception)
  4182. {
  4183. dic.Add("ReturnCode", "行程录入不正确!");
  4184. }
  4185. }
  4186. else
  4187. {
  4188. dic.Add("ReturnCode", "未录入行程!");
  4189. }
  4190. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4191. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4192. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4193. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4194. {
  4195. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4196. dic.Add("Day", sp.Days.ToString());
  4197. }
  4198. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4199. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4200. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4201. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4202. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4203. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4204. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4205. designer.SetDataSource("Name", Names);
  4206. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4207. designer.SetDataSource("Day", dic["Day"] + "天");
  4208. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4209. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4210. int startIndex = 10;
  4211. const int startIndexcopy = 10;
  4212. if (dac2.Count == dac3.Count)//国家 币种 金额
  4213. {
  4214. for (int i = 0; i < dac2.Count; i++)
  4215. {
  4216. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4217. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4218. }
  4219. }
  4220. DataTable dtdac1 = new DataTable();
  4221. List<string> place = new List<string>();
  4222. dtdac1.Columns.AddRange(new DataColumn[] {
  4223. new DataColumn(){ ColumnName = "city"},
  4224. new DataColumn(){ ColumnName = "curr"},
  4225. new DataColumn(){ ColumnName = "criterion"},
  4226. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4227. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4228. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4229. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4230. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4231. });
  4232. DataTable dtdac2 = new DataTable();
  4233. dtdac2.Columns.AddRange(new DataColumn[] {
  4234. new DataColumn(){ ColumnName = "city"},
  4235. new DataColumn(){ ColumnName = "curr"},
  4236. new DataColumn(){ ColumnName = "criterion"},
  4237. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4238. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4239. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4240. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4241. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4242. });
  4243. dtdac1.TableName = "tb1";
  4244. dtdac2.TableName = "tb2";
  4245. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4246. foreach (var item in dac1)
  4247. {
  4248. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4249. if (place.Contains(item.Place))
  4250. {
  4251. continue;
  4252. }
  4253. DataRow row = dtdac1.NewRow();
  4254. row["city"] = item.Place;
  4255. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4256. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4257. row["curr"] = currency;
  4258. row["rate"] = rate.ToString("#0.0000");
  4259. row["criterion"] = item.Cost.ToString("#0.00");
  4260. row["number"] = 1;
  4261. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4262. //row["costRMB"] = rbmPrice;
  4263. dtdac1.Rows.Add(row);
  4264. place.Add(item.Place);
  4265. }
  4266. place = new List<string>();
  4267. foreach (var item in dac2)
  4268. {
  4269. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4270. if (place.Contains(item.Place))
  4271. {
  4272. continue;
  4273. }
  4274. DataRow row = dtdac2.NewRow();
  4275. row["city"] = item.Place;
  4276. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4277. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4278. row["curr"] = currency;
  4279. row["rate"] = rate.ToString("#0.0000");
  4280. row["criterion"] = item.Cost.ToString("#0.00");
  4281. row["number"] = 1;
  4282. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4283. //row["cost"] = item.SubTotal;
  4284. //row["costRMB"] = rbmPrice;
  4285. dtdac2.Rows.Add(row);
  4286. place.Add(item.Place);
  4287. //dac2totalPrice += rbmPrice;
  4288. }
  4289. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4290. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4291. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4292. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4293. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4294. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4295. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4296. string cellStr = $" 5.其他费用(";
  4297. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4298. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4299. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4300. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4301. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4302. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4303. if (cellStr.Length > 8)
  4304. {
  4305. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4306. }
  4307. cellStr += ")";
  4308. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4309. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4310. decimal pxFee = dac4.Sum(it => it.Cost);
  4311. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4312. string celllastStr1 = "";
  4313. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4314. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4315. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4316. celllastStr1 += $",国际旅费 元";
  4317. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4318. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4319. designer.SetDataSource("cell4Str", cell4Str);
  4320. designer.SetDataSource("cellStr", cellStr);
  4321. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4322. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4323. designer.SetDataSource("celllastStr", celllastStr);
  4324. Workbook wb = designer.Workbook;
  4325. var sheet = wb.Worksheets[0];
  4326. //绑定datatable数据集
  4327. designer.SetDataSource(dtdac1);
  4328. designer.SetDataSource(dtdac2);
  4329. designer.Process();
  4330. var rowStart = dtdac1.Rows.Count;
  4331. while (rowStart > 0)
  4332. {
  4333. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4334. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4335. startIndex++;
  4336. rowStart--;
  4337. }
  4338. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4339. startIndex += 1; //总计行
  4340. rowStart = dtdac2.Rows.Count;
  4341. while (rowStart > 0)
  4342. {
  4343. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4344. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4345. startIndex++;
  4346. rowStart--;
  4347. }
  4348. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4349. wb.CalculateFormula(true);
  4350. //模板文件名
  4351. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4352. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4353. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4354. return Ok(JsonView(true, "成功", new { Url = url }));
  4355. }
  4356. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4357. {
  4358. //获取模板
  4359. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4360. //载入模板
  4361. Document doc = new Document(tempPath);
  4362. DocumentBuilder builder = new DocumentBuilder(doc);
  4363. Dictionary<string, string> dic = new Dictionary<string, string>();
  4364. dic.Add("GroupName", _DelegationInfo.TeamName);
  4365. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4366. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4367. string missionLeaderJob = "";//负责人job
  4368. int groupNumber = 0; //团人数
  4369. if (DeleClientList.Count > 0)
  4370. {
  4371. missionLeader = DeleClientList[0]?.Name ?? "";
  4372. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4373. }
  4374. dic.Add("MissionLeader", missionLeader); //团负责人
  4375. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4376. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4377. #region MyRegion
  4378. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4379. //{
  4380. // List<string> list = new List<string>();
  4381. // try
  4382. // {
  4383. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4384. // foreach (var item in spilitArr)
  4385. // {
  4386. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4387. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4388. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4389. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4390. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4391. // list.Add(depName);
  4392. // list.Add(arrName);
  4393. // }
  4394. // list = list.Distinct().ToList();
  4395. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4396. // }
  4397. // catch (Exception)
  4398. // {
  4399. // dic.Add("ReturnCode", "行程录入不正确!");
  4400. // }
  4401. //}
  4402. //else
  4403. //{
  4404. // dic.Add("ReturnCode", "未录入行程!");
  4405. //}
  4406. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4407. dic.Add("ReturnCode", string.Join("、", countrys));
  4408. #endregion
  4409. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4410. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4411. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4412. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4413. //{
  4414. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4415. // dic.Add("Day", sp.Days.ToString());
  4416. //}
  4417. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4418. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4419. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4420. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4421. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4422. //培训人员名单
  4423. int cultivateRowIndex = 7;
  4424. foreach (var item in DeleClientList)
  4425. {
  4426. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4427. builder.Write(item.Name);
  4428. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4429. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4430. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4431. string birthDay = "";
  4432. if (item.Birthday != null)
  4433. {
  4434. DateTime dt = Convert.ToDateTime(item.Birthday);
  4435. birthDay = $"{dt.Year}.{dt.Month}";
  4436. }
  4437. builder.Write(birthDay);
  4438. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4439. builder.Write(item.Company);
  4440. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4441. builder.Write(item.Job);
  4442. cultivateRowIndex++;
  4443. }
  4444. //删除多余行
  4445. //cultivateRowIndex -= 2;
  4446. int delRows = 10 + 7 - cultivateRowIndex;
  4447. if (delRows > 0)
  4448. {
  4449. for (int i = 0; i < delRows; i++)
  4450. {
  4451. table1.Rows.RemoveAt(cultivateRowIndex);
  4452. //cultivateRowIndex++;
  4453. }
  4454. }
  4455. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4456. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4457. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4458. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4459. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4460. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4461. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4462. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4463. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4464. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4465. //其他费用
  4466. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4467. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4468. //其他费用合计
  4469. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4470. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4471. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4472. //公务舱合计
  4473. //国际旅费
  4474. string outsideJJ = "";
  4475. string allPriceJJ = "";
  4476. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4477. {
  4478. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4479. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4480. }
  4481. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4482. {
  4483. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4484. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4485. }
  4486. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4487. {
  4488. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4489. dic.Add("AirFeeTotal", airFeeTotalStr);
  4490. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4491. dic.Add("FeeTotal", feeTotalStr);
  4492. }
  4493. foreach (var key in dic.Keys)
  4494. {
  4495. builder.MoveToBookmark(key);
  4496. builder.Write(dic[key]);
  4497. }
  4498. //模板文件名
  4499. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4500. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4501. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4502. return Ok(JsonView(true, "成功", new { Url = url }));
  4503. }
  4504. }
  4505. else if (dto.ExportType == 2) //表格
  4506. {
  4507. //利用键值对存放数据
  4508. Dictionary<string, string> dic = new Dictionary<string, string>();
  4509. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4510. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4511. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4512. dic.Add("Day", sp.Days.ToString());
  4513. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4514. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4515. {
  4516. //获取模板
  4517. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4518. //载入模板
  4519. Document doc = new Document(tempPath);
  4520. DocumentBuilder builder = new DocumentBuilder(doc);
  4521. dic.Add("TeamName", _DelegationInfo.TeamName);
  4522. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4523. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4524. string missionLeaderName = "",
  4525. missionLeaderJob = "";
  4526. if (DeleClientList.Count > 0)
  4527. {
  4528. missionLeaderName = DeleClientList[0].Name;
  4529. missionLeaderJob = DeleClientList[0].Job;
  4530. }
  4531. dic.Add("MissionLeaderName", missionLeaderName);
  4532. dic.Add("MissionLeaderJob", missionLeaderJob);
  4533. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4534. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4535. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4536. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4537. int rowCount = 10;//总人数行
  4538. int startRowIndex = 7; //起始行
  4539. for (int i = 0; i < DeleClientList.Count; i++)
  4540. {
  4541. builder.MoveToCell(0, startRowIndex, 0, 0);
  4542. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4543. builder.MoveToCell(0, startRowIndex, 1, 0);
  4544. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4545. builder.Write(sex);//性别
  4546. builder.MoveToCell(0, startRowIndex, 2, 0);
  4547. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4548. builder.MoveToCell(0, startRowIndex, 3, 0);
  4549. builder.Write(DeleClientList[i].Company);//工作单位
  4550. builder.MoveToCell(0, startRowIndex, 4, 0);
  4551. builder.Write(DeleClientList[i].Job);//职务及级别
  4552. builder.MoveToCell(0, startRowIndex, 5, 0);
  4553. builder.Write("");//人员属性
  4554. builder.MoveToCell(0, startRowIndex, 6, 0);
  4555. builder.Write("");//上次出国时间
  4556. startRowIndex++;
  4557. }
  4558. int nullRow = rowCount - DeleClientList.Count;//空行
  4559. for (int i = 0; i < nullRow; i++)
  4560. {
  4561. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4562. }
  4563. foreach (var key in dic.Keys)
  4564. {
  4565. builder.MoveToBookmark(key);
  4566. builder.Write(dic[key]);
  4567. }
  4568. //模板文件名
  4569. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4570. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4571. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4572. return Ok(JsonView(true, "成功", new { Url = url }));
  4573. }
  4574. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4575. {
  4576. //获取模板
  4577. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4578. //载入模板
  4579. Document doc = new Document(tempPath);
  4580. DocumentBuilder builder = new DocumentBuilder(doc);
  4581. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4582. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4583. dic.Add("Names", Names);
  4584. int accommodationRows = 12, foodandotherRows = 12;
  4585. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4586. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4587. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4588. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4589. int accommodationStartIndex = 6;
  4590. decimal dac1totalPrice = 0.00M;
  4591. foreach (var dac in dac1)
  4592. {
  4593. if (dac.SubTotal == 0)
  4594. {
  4595. continue;
  4596. }
  4597. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4598. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4599. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4600. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4601. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4602. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4603. builder.Write(currency);//币种
  4604. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4605. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4606. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4607. builder.Write("");//人数
  4608. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4609. builder.Write("");//天数
  4610. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4611. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4612. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4613. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4614. builder.Write(rate.ToString("#0.0000"));//汇率
  4615. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4616. decimal rbmPrice = rate * dac.SubTotal;
  4617. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4618. accommodationStartIndex++;
  4619. dac1totalPrice += rbmPrice;
  4620. }
  4621. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4622. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4623. builder.Write("小计");
  4624. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4625. builder.Write(dac1totalPrice.ToString("#0.00"));
  4626. accommodationStartIndex++;
  4627. int nullRow = accommodationRows - dac1.Count;
  4628. //删除空行
  4629. //if (nullRow > 0)
  4630. //{
  4631. // int rowIndex = accommodationStartIndex;
  4632. // for (int i = 0; i < nullRow; i++)
  4633. // {
  4634. // Row row = table1.Rows[rowIndex];
  4635. // row.Remove();
  4636. // rowIndex++;
  4637. // }
  4638. //}
  4639. if (dac2.Count == dac3.Count)//国家 币种 金额
  4640. {
  4641. for (int i = 0; i < dac2.Count; i++)
  4642. {
  4643. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4644. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4645. }
  4646. }
  4647. int foodandotherStartIndex = 19;//
  4648. decimal dac2totalPrice = 0.00M;
  4649. foreach (var dac in dac2)
  4650. {
  4651. if (dac.SubTotal == 0)
  4652. {
  4653. continue;
  4654. }
  4655. //foodandotherStartIndex = 12;
  4656. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4657. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4658. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4659. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4660. builder.Write(currency);//币种
  4661. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4662. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4663. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4664. builder.Write("");//人数
  4665. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4666. builder.Write("");//天数
  4667. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4668. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4669. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4670. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4671. builder.Write(rate.ToString("#0.0000"));//汇率
  4672. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4673. decimal rbmPrice = rate * dac.SubTotal;
  4674. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4675. foodandotherStartIndex++;
  4676. dac2totalPrice += rbmPrice;
  4677. }
  4678. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4679. //删除空行
  4680. if (dac2.Count < foodandotherRows)
  4681. {
  4682. //int nullRow = accommodationRows - dac2.Count;
  4683. //while (table2.Rows.Count > dac2.Count)
  4684. //{
  4685. // table2.Rows.RemoveAt(dac2.Count);
  4686. //}
  4687. }
  4688. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4689. string otherFeeStr = "";
  4690. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4691. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4692. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4693. if (otherFeeStr.Length > 0)
  4694. {
  4695. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4696. otherFeeStr = $"({otherFeeStr})";
  4697. dic.Add("OtherFeeStr", otherFeeStr);
  4698. }
  4699. foreach (var key in dic.Keys)
  4700. {
  4701. builder.MoveToBookmark(key);
  4702. builder.Write(dic[key]);
  4703. }
  4704. //模板文件名
  4705. string strFileName = $"省级单位出(境)经费报销单.docx";
  4706. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4707. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4708. return Ok(JsonView(true, "成功", new { Url = url }));
  4709. }
  4710. }
  4711. else if (dto.ExportType == 3)
  4712. {
  4713. if (dto.SubTypeId == 1) //团组成员名单
  4714. {
  4715. if (DeleClientList.Count < 1)
  4716. {
  4717. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4718. }
  4719. //获取模板
  4720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4721. //载入模板
  4722. Document doc = new Document(tempPath);
  4723. DocumentBuilder builder = new DocumentBuilder(doc);
  4724. //获取word里所有表格
  4725. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4726. //获取所填表格的序数
  4727. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4728. var rowStart = tableOne.Rows[0]; //获取第1行
  4729. //循环赋值
  4730. for (int i = 0; i < DeleClientList.Count; i++)
  4731. {
  4732. builder.MoveToCell(0, i + 1, 0, 0);
  4733. builder.Write(DeleClientList[i].Name);
  4734. builder.MoveToCell(0, i + 1, 1, 0);
  4735. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4736. builder.Write(sex);
  4737. builder.MoveToCell(0, i + 1, 2, 0);
  4738. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4739. builder.MoveToCell(0, i + 1, 3, 0);
  4740. builder.Write(DeleClientList[i].Company);
  4741. builder.MoveToCell(0, i + 1, 4, 0);
  4742. builder.Write(DeleClientList[i].Job);
  4743. }
  4744. //删除多余行
  4745. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4746. {
  4747. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4748. }
  4749. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4750. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4751. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4752. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4753. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4754. return Ok(JsonView(true, "成功", new { Url = url }));
  4755. }
  4756. }
  4757. return Ok(JsonView(false, "操作失败!"));
  4758. }
  4759. catch (Exception ex)
  4760. {
  4761. return Ok(JsonView(false, ex.Message));
  4762. }
  4763. }
  4764. /// <summary>
  4765. /// 获取三公费用标准city
  4766. /// </summary>
  4767. /// <param name="placeData"></param>
  4768. /// <param name="nationalTravelFeeId"></param>
  4769. /// <returns></returns>
  4770. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4771. {
  4772. string _city = string.Empty;
  4773. if (placeData.Count < 1) return _city;
  4774. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4775. if (data == null) return _city;
  4776. string country = data.Country;
  4777. string city = data.City;
  4778. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4779. else _city = city;
  4780. return _city;
  4781. }
  4782. /// <summary>
  4783. /// 团组模块 - 出入境费用 - 明细表导出
  4784. /// </summary>
  4785. /// <returns></returns>
  4786. [HttpPost]
  4787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4788. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4789. {
  4790. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4791. if (data.Code != 0)
  4792. {
  4793. return Ok(JsonView(false, data.Msg));
  4794. }
  4795. return Ok(JsonView(true, data.Msg, data.Data));
  4796. }
  4797. /// <summary>
  4798. /// 团组模块 - 出入境费用 - 一键清空
  4799. /// </summary>
  4800. /// <returns></returns>
  4801. [HttpPost]
  4802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4803. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4804. {
  4805. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4806. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4807. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4808. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4809. if (_view.Code == 0)
  4810. {
  4811. return Ok(JsonView(true, "操作成功"));
  4812. }
  4813. return Ok(JsonView(false, "操作失败"));
  4814. }
  4815. /// <summary>
  4816. /// 团组模块 - 出入境费用 - 子项删除
  4817. /// </summary>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4821. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4822. {
  4823. try
  4824. {
  4825. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4826. if (data.Code != 0)
  4827. {
  4828. return Ok(JsonView(false, data.Msg));
  4829. }
  4830. return Ok(JsonView(true, "操作成功!", data.Data));
  4831. }
  4832. catch (Exception ex)
  4833. {
  4834. return Ok(JsonView(false, ex.Message));
  4835. }
  4836. }
  4837. /// <summary>
  4838. /// 团组模块 - 出入境国家费用标准 List
  4839. /// </summary>
  4840. /// <returns></returns>
  4841. [HttpPost]
  4842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4843. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4844. {
  4845. try
  4846. {
  4847. Stopwatch sw = new Stopwatch();
  4848. sw.Start();
  4849. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4850. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4851. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4852. Where gntf.Isdel = 0");
  4853. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4854. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4855. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4856. //foreach (var item in nationalTravel)
  4857. //{
  4858. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4859. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4860. // if (otherData != null)
  4861. // {
  4862. // cityData.Remove(otherData);
  4863. // cityData.Add(otherData);
  4864. // }
  4865. // nationalTravelFeeData1.Add(new
  4866. // {
  4867. // Country = item.Country,
  4868. // CityData = cityData
  4869. // });
  4870. //}
  4871. sw.Stop();
  4872. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4873. }
  4874. catch (Exception ex)
  4875. {
  4876. return Ok(JsonView(false, ex.Message));
  4877. throw;
  4878. }
  4879. }
  4880. /// <summary>
  4881. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4882. /// </summary>
  4883. /// <returns></returns>
  4884. [HttpPost]
  4885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4886. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4887. {
  4888. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4889. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4890. List<string> countryData = new List<string>();
  4891. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4892. countryData = countryData.Distinct().ToList();
  4893. List<dynamic> dataSource = new List<dynamic>();
  4894. foreach (var item in countryData)
  4895. {
  4896. List<string> cityData1 = new List<string>();
  4897. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4898. var countryData2 = new
  4899. {
  4900. CountryName = item,
  4901. CityData = cityData1
  4902. };
  4903. dataSource.Add(countryData2);
  4904. }
  4905. return Ok(JsonView(true, "查询成功!", dataSource));
  4906. }
  4907. /// <summary>
  4908. /// 团组模块 - 出入境国家费用标准 Page List
  4909. /// </summary>
  4910. /// <returns></returns>
  4911. [HttpPost]
  4912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4913. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4914. {
  4915. int portId = dto.PortType;
  4916. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4917. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4918. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4919. string whereSql = string.Empty;
  4920. if (!string.IsNullOrEmpty(dto.Country))
  4921. {
  4922. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4923. }
  4924. if (!string.IsNullOrEmpty(dto.City))
  4925. {
  4926. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4927. }
  4928. string pageSql = string.Format(@"Select * From (
  4929. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4930. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4931. From Grp_NationalTravelFee gntf
  4932. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4933. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4934. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4935. RefAsync<int> total = 0;
  4936. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4937. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4938. }
  4939. /// <summary>
  4940. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4941. /// </summary>
  4942. /// <returns></returns>
  4943. [HttpPost]
  4944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4945. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4946. {
  4947. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4948. int portId = dto.PortType;
  4949. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4950. string whereSql = string.Empty;
  4951. if (!string.IsNullOrEmpty(dto.Country))
  4952. {
  4953. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4954. }
  4955. if (!string.IsNullOrEmpty(dto.City))
  4956. {
  4957. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4958. }
  4959. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4960. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4961. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4962. From Grp_NationalTravelFee gntf
  4963. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4964. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4965. Where gntf.Isdel = 0 {0} ", whereSql);
  4966. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4967. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4968. }
  4969. /// <summary>
  4970. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4971. /// </summary>
  4972. /// <returns></returns>
  4973. [HttpPost]
  4974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4975. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4976. {
  4977. try
  4978. {
  4979. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4980. if (data.Code != 0)
  4981. {
  4982. return Ok(JsonView(false, data.Msg));
  4983. }
  4984. return Ok(JsonView(true, "操作成功!", data.Data));
  4985. }
  4986. catch (Exception ex)
  4987. {
  4988. return Ok(JsonView(false, ex.Message));
  4989. }
  4990. }
  4991. /// <summary>
  4992. /// 团组模块 - 出入境国家费用标准 - Del
  4993. /// </summary>
  4994. /// <returns></returns>
  4995. [HttpPost]
  4996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4997. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4998. {
  4999. try
  5000. {
  5001. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  5002. {
  5003. Id = dto.Id,
  5004. DeleteUserId = dto.DeleteUserId,
  5005. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5006. IsDel = 1
  5007. };
  5008. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  5009. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  5010. .WhereColumns(it => new { it.Id })
  5011. .ExecuteCommandAsync();
  5012. if (delStatus <= 0)
  5013. {
  5014. return Ok(JsonView(false, "删除失败!"));
  5015. }
  5016. return Ok(JsonView(true, "操作成功!"));
  5017. }
  5018. catch (Exception ex)
  5019. {
  5020. return Ok(JsonView(false, ex.Message));
  5021. }
  5022. }
  5023. #endregion
  5024. #region 签证费用录入
  5025. /// <summary>
  5026. /// 根据diid查询签证费用列表
  5027. /// </summary>
  5028. /// <param name="dto"></param>
  5029. /// <returns></returns>
  5030. [HttpPost]
  5031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5032. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  5033. {
  5034. try
  5035. {
  5036. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  5037. if (groupData.Code != 0)
  5038. {
  5039. return Ok(JsonView(false, groupData.Msg));
  5040. }
  5041. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5042. }
  5043. catch (Exception ex)
  5044. {
  5045. return Ok(JsonView(false, ex.Message));
  5046. }
  5047. }
  5048. /// <summary>
  5049. /// 根据签证费用Id查询单条数据及c表数据
  5050. /// </summary>
  5051. /// <param name="dto"></param>
  5052. /// <returns></returns>
  5053. [HttpPost]
  5054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5055. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  5056. {
  5057. try
  5058. {
  5059. Result groupData = await _visaPriceRep.PostVisaById(dto);
  5060. if (groupData.Code != 0)
  5061. {
  5062. return Ok(JsonView(false, groupData.Msg));
  5063. }
  5064. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5065. }
  5066. catch (Exception ex)
  5067. {
  5068. return Ok(JsonView(false, ex.Message));
  5069. }
  5070. }
  5071. /// <summary>
  5072. /// 签证费用删除
  5073. /// </summary>
  5074. /// <param name="dto"></param>
  5075. /// <returns></returns>
  5076. [HttpPost]
  5077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5078. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  5079. {
  5080. _sqlSugar.BeginTran();
  5081. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5082. if (!res)
  5083. {
  5084. _sqlSugar.RollbackTran();
  5085. return Ok(JsonView(false, "删除失败"));
  5086. }
  5087. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5088. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5089. .SetColumns(a => new Grp_CreditCardPayment()
  5090. {
  5091. IsDel = 1,
  5092. DeleteUserId = dto.DeleteUserId,
  5093. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5094. }).ExecuteCommand();
  5095. if (resSub < 1)
  5096. {
  5097. _sqlSugar.RollbackTran();
  5098. return Ok(JsonView(false, "删除失败"));
  5099. }
  5100. _sqlSugar.CommitTran();
  5101. return Ok(JsonView(true, "删除成功!"));
  5102. }
  5103. /// <summary>
  5104. /// 签证费用录入下拉框初始化
  5105. /// </summary>
  5106. /// <returns></returns>
  5107. [HttpPost]
  5108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5109. public async Task<IActionResult> VisaPriceAddSelect()
  5110. {
  5111. try
  5112. {
  5113. //支付方式
  5114. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5115. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5116. //币种
  5117. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5118. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5119. //乘客类型
  5120. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5121. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5122. //卡类型
  5123. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5124. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5125. var data = new
  5126. {
  5127. Payment = _Payment,
  5128. CurrencyList = _CurrencyList,
  5129. PassengerType = _PassengerType,
  5130. BankCard = _BankCard
  5131. };
  5132. return Ok(JsonView(true, "查询成功!", data));
  5133. }
  5134. catch (Exception ex)
  5135. {
  5136. return Ok(JsonView(false, "程序错误!"));
  5137. throw;
  5138. }
  5139. }
  5140. /// <summary>
  5141. /// 签证费用录入操作(Status:1.新增,2.修改)
  5142. /// </summary>
  5143. /// <param name="dto"></param>
  5144. /// <returns></returns>
  5145. [HttpPost]
  5146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5147. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5148. {
  5149. try
  5150. {
  5151. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5152. if (groupData.Code != 0)
  5153. {
  5154. return Ok(JsonView(false, groupData.Msg));
  5155. }
  5156. #region 应用推送
  5157. try
  5158. {
  5159. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5160. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5161. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5162. }
  5163. catch (Exception ex)
  5164. {
  5165. }
  5166. #endregion
  5167. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5168. }
  5169. catch (Exception ex)
  5170. {
  5171. return Ok(JsonView(false, ex.Message));
  5172. }
  5173. }
  5174. #endregion
  5175. #region op费用录入
  5176. /// <summary>
  5177. /// 根据diid查询op费用列表
  5178. /// </summary>
  5179. /// <param name="dto"></param>
  5180. /// <returns></returns>
  5181. [HttpPost]
  5182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5183. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5184. {
  5185. try
  5186. {
  5187. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5188. if (groupData.Code != 0)
  5189. {
  5190. return Ok(JsonView(false, groupData.Msg));
  5191. }
  5192. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5193. }
  5194. catch (Exception ex)
  5195. {
  5196. return Ok(JsonView(false, ex.Message));
  5197. }
  5198. }
  5199. /// <summary>
  5200. /// 根据op费用Id查询单条数据及c表数据
  5201. /// </summary>
  5202. /// <param name="dto"></param>
  5203. /// <returns></returns>
  5204. [HttpPost]
  5205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5206. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5207. {
  5208. try
  5209. {
  5210. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5211. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5212. var data = new
  5213. {
  5214. CarTouristGuideGround = _groupData,
  5215. CreditCardPayment = _creditCardPayment
  5216. };
  5217. return Ok(JsonView(true, "查询成功!", data));
  5218. }
  5219. catch (Exception ex)
  5220. {
  5221. return Ok(JsonView(false, "程序错误!"));
  5222. }
  5223. }
  5224. /// <summary>
  5225. /// op费用删除
  5226. /// </summary>
  5227. /// <param name="dto"></param>
  5228. /// <returns></returns>
  5229. [HttpPost]
  5230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5231. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5232. {
  5233. try
  5234. {
  5235. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5236. if (!res)
  5237. {
  5238. return Ok(JsonView(false, "删除失败"));
  5239. }
  5240. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5241. {
  5242. IsDel = 1,
  5243. DeleteUserId = dto.DeleteUserId,
  5244. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5245. }).ExecuteCommandAsync();
  5246. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5247. {
  5248. IsDel = 1,
  5249. DeleteUserId = dto.DeleteUserId,
  5250. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5251. }).ExecuteCommandAsync();
  5252. return Ok(JsonView(true, "删除成功!"));
  5253. }
  5254. catch (Exception ex)
  5255. {
  5256. return Ok(JsonView(false, "程序错误!"));
  5257. throw;
  5258. }
  5259. }
  5260. /// <summary>
  5261. /// op费用录入操作(Status:1.新增,2.修改)
  5262. /// </summary>
  5263. /// <param name="dto"></param>
  5264. /// <returns></returns>
  5265. [HttpPost]
  5266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5267. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5268. {
  5269. try
  5270. {
  5271. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5272. if (groupData.Code != 0)
  5273. {
  5274. return Ok(JsonView(false, groupData.Msg));
  5275. }
  5276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5277. }
  5278. catch (Exception ex)
  5279. {
  5280. return Ok(JsonView(false, ex.Message));
  5281. }
  5282. }
  5283. /// <summary>
  5284. /// 填写费用详细页面初始化绑定
  5285. /// </summary>
  5286. /// <param name="dto"></param>
  5287. /// <returns></returns>
  5288. [HttpPost]
  5289. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5290. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5291. {
  5292. try
  5293. {
  5294. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5295. if (groupData.Code != 0)
  5296. {
  5297. return Ok(JsonView(false, groupData.Msg));
  5298. }
  5299. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5300. }
  5301. catch (Exception ex)
  5302. {
  5303. return Ok(JsonView(false, ex.Message));
  5304. }
  5305. }
  5306. /// <summary>
  5307. /// 根据op费用Id查询详细数据
  5308. /// </summary>
  5309. /// <param name="dto"></param>
  5310. /// <returns></returns>
  5311. [HttpPost]
  5312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5313. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5314. {
  5315. try
  5316. {
  5317. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5318. if (groupData.Code != 0)
  5319. {
  5320. return Ok(JsonView(false, groupData.Msg));
  5321. }
  5322. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5323. }
  5324. catch (Exception ex)
  5325. {
  5326. return Ok(JsonView(false, ex.Message));
  5327. }
  5328. }
  5329. /// <summary>
  5330. /// OP费用录入填写详情
  5331. /// </summary>
  5332. /// <param name="dto"></param>
  5333. /// <returns></returns>
  5334. [HttpPost]
  5335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5336. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5337. {
  5338. try
  5339. {
  5340. #region 参数校验
  5341. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5342. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5343. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5344. #endregion
  5345. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5346. if (groupData.Code != 0)
  5347. {
  5348. return Ok(JsonView(false, groupData.Msg));
  5349. }
  5350. //自动审核
  5351. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5352. #region 应用推送
  5353. try
  5354. {
  5355. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5356. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5357. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5358. }
  5359. catch (Exception ex)
  5360. {
  5361. }
  5362. #endregion
  5363. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5364. }
  5365. catch (Exception ex)
  5366. {
  5367. return Ok(JsonView(false, ex.Message));
  5368. }
  5369. }
  5370. /// <summary>
  5371. /// 获取三公详细所有城市
  5372. /// </summary>
  5373. /// <returns></returns>
  5374. [HttpGet]
  5375. public IActionResult OpCarCityResult()
  5376. {
  5377. var jw = JsonView(false);
  5378. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5379. {
  5380. x.Id,
  5381. x.Country,
  5382. x.City,
  5383. }).ToList();
  5384. if (data.Count > 0)
  5385. {
  5386. jw = JsonView(true, "获取成功!", data);
  5387. }
  5388. else
  5389. {
  5390. jw.Msg = "城市数据为空!";
  5391. jw.Data = new string[0];
  5392. }
  5393. return Ok(jw);
  5394. }
  5395. /// <summary>
  5396. /// 导出地接费用明细
  5397. /// </summary>
  5398. /// <param name="dto"></param>
  5399. /// <returns></returns>
  5400. [HttpPost]
  5401. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5402. {
  5403. var jw = JsonView(false);
  5404. if (dto.Diid < 1)
  5405. {
  5406. jw.Msg = "请输入正确的diid!";
  5407. return Ok(jw);
  5408. }
  5409. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5410. if (group == null)
  5411. {
  5412. jw.Msg = "未找到团组信息!";
  5413. return Ok(jw);
  5414. }
  5415. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5416. if (localGuideArr.Count == 0)
  5417. {
  5418. jw.Msg = "该团组暂无地接信息!";
  5419. return Ok(jw);
  5420. }
  5421. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5422. var overspendSoure = new Dictionary<int, int>
  5423. {
  5424. { 91, 982 }, //车
  5425. { 92 , 1059} ,//导游
  5426. { 994 , 1073}, //翻译
  5427. { 988 , 1074 }, //早餐
  5428. { 93 , 1075 }, //午餐
  5429. { 989 , 1076 }, //晚餐
  5430. };
  5431. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5432. foreach (var groupArr in localGroup)
  5433. {
  5434. var keyValue = groupArr.Key;
  5435. if (int.TryParse(keyValue, out int cityid))
  5436. {
  5437. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5438. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5439. }
  5440. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5441. foreach (var item in groupArr)
  5442. {
  5443. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5444. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5445. new Grp_CarTouristGuideGroundReservationsContentExtend
  5446. {
  5447. Count = a.Count,
  5448. CreateTime = a.CreateTime,
  5449. CreateUserId = a.CreateUserId,
  5450. CTGGRId = a.CTGGRId,
  5451. Currency = a.Currency,
  5452. DatePrice = a.DatePrice,
  5453. DeleteTime = a.DeleteTime,
  5454. DeleteUserId = a.DeleteUserId,
  5455. DiId = a.DiId,
  5456. Id = a.Id,
  5457. IsDel = a.IsDel,
  5458. Price = a.Price,
  5459. PriceContent = a.PriceContent,
  5460. Remark = a.Remark,
  5461. SId = a.SId,
  5462. SidName = b.Name,
  5463. Units = a.Units,
  5464. }
  5465. ).ToList();
  5466. if (content.Count > 0)
  5467. {
  5468. contentArr.Add(content);
  5469. }
  5470. }
  5471. //open excel
  5472. //set excel
  5473. //save excel
  5474. try
  5475. {
  5476. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5477. IWorkbook workbook;
  5478. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5479. {
  5480. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5481. }
  5482. else
  5483. {
  5484. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5485. }
  5486. ISheet sheet = workbook.GetSheetAt(0);
  5487. var rowStartIndex = 2;
  5488. var clounmCount = 10;
  5489. var initStyleRow = sheet.GetRow(2);
  5490. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5491. //var overspendArrDetail =
  5492. var existsId = new List<CarCompare>();
  5493. var lastElem = arr.Last();
  5494. var thisSid = -1;
  5495. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5496. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5497. {
  5498. Name = "未知币种!",
  5499. Remark = "未知币种!",
  5500. };
  5501. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5502. Action cloneRowFn = () =>
  5503. {
  5504. rowStartIndex++;
  5505. var cloneRow = sheet.CreateRow(rowStartIndex);
  5506. // 复制样式
  5507. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5508. {
  5509. ICell sourceCell = initStyleRow.GetCell(i);
  5510. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5511. // 确保单元格存在样式
  5512. if (sourceCell.CellStyle != null)
  5513. {
  5514. targetCell.CellStyle = sourceCell.CellStyle;
  5515. }
  5516. }
  5517. };
  5518. var mergeRow = () =>
  5519. {
  5520. for (int i = 2; i < sheet.LastRowNum; i++)
  5521. {
  5522. var row = sheet.GetRow(i);
  5523. var cellFirst = row.GetCell(0);
  5524. var thisIndex = i + 1;
  5525. while (thisIndex < sheet.LastRowNum)
  5526. {
  5527. var nextRow = sheet.GetRow(thisIndex);
  5528. var nextCellFirst = nextRow.GetCell(0);
  5529. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5530. {
  5531. thisIndex++;
  5532. }
  5533. else
  5534. {
  5535. break;
  5536. }
  5537. }
  5538. thisIndex--;
  5539. if (thisIndex != i)
  5540. {
  5541. //合并row
  5542. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5543. i, // 起始行索引(0-based)
  5544. thisIndex, // 结束行索引(0-based)
  5545. 0, // 起始列索引(0-based)
  5546. 0 // 结束列索引(0-based)
  5547. );
  5548. sheet.AddMergedRegion(cellRangeAddress);
  5549. i = thisIndex;
  5550. }
  5551. }
  5552. };
  5553. var chaoshiNumber = 0;
  5554. var totalNumber = 0.00M;
  5555. string lastStr = "";
  5556. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5557. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5558. {
  5559. b.IsAuditGM,
  5560. x.Id,
  5561. x.Area,
  5562. b.PayPercentage,
  5563. b.PayMoney,
  5564. }).ToList();
  5565. string yesPayment = "", noPayment = "";
  5566. foreach (var item in queryCarArrByCityAndDiid)
  5567. {
  5568. if (item.IsAuditGM == 1)
  5569. {
  5570. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5571. }
  5572. else
  5573. {
  5574. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5575. }
  5576. }
  5577. lastStr = yesPayment + noPayment;
  5578. foreach (var item in arr)
  5579. {
  5580. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5581. {
  5582. if (thisSid != item.SId)
  5583. {
  5584. if (thisSid == -1)
  5585. {
  5586. thisSid = item.SId;
  5587. }
  5588. else
  5589. {
  5590. //合并小计行
  5591. //创建合并区域的实例
  5592. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5593. rowStartIndex, // 起始行索引(0-based)
  5594. rowStartIndex, // 结束行索引(0-based)
  5595. 0, // 起始列索引(0-based)
  5596. 3 // 结束列索引(0-based)
  5597. );
  5598. sheet.AddMergedRegion(cellRangeAddress);
  5599. var CellStyle = workbook.CreateCellStyle();
  5600. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5601. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5602. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5603. for (int i = 0; i <= clounmCount; i++)
  5604. {
  5605. if (i > 6)
  5606. {
  5607. var CellStyle1 = workbook.CreateCellStyle();
  5608. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5609. IFont Font = workbook.CreateFont(); // 创建字体
  5610. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5611. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5612. CellStyle1.SetFont(Font);
  5613. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5614. }
  5615. else
  5616. {
  5617. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5618. }
  5619. }
  5620. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5621. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5622. //超时合计
  5623. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5624. //超时数
  5625. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5626. //超时合计费用
  5627. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5628. thisSid = item.SId;
  5629. cloneRowFn();
  5630. chaoshiNumber = 0;
  5631. totalNumber = 0;
  5632. }
  5633. }
  5634. IRow row = sheet.GetRow(rowStartIndex);
  5635. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5636. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5637. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5638. if (isOpenOverspendSoure)
  5639. {
  5640. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5641. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5642. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5643. }
  5644. for (int i = 0; i <= clounmCount; i++)
  5645. {
  5646. var cell = row.GetCell(i);
  5647. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5648. if (cell == null)
  5649. {
  5650. cell = row.CreateCell(i);
  5651. }
  5652. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5653. fontRed.CloneStyleFrom(cell.CellStyle);
  5654. IFont Font = workbook.CreateFont(); // 创建字体
  5655. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5656. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5657. fontRed.SetFont(Font);
  5658. byte[] rgb = new byte[3] { 255, 242, 204 };
  5659. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5660. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5661. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5662. if (workbook is XSSFWorkbook)
  5663. {
  5664. BackgroundColor255_242_204.FillForegroundColor = 0;
  5665. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5666. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5667. }
  5668. else
  5669. {
  5670. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5671. }
  5672. if (i == 1 || i > 6)
  5673. {
  5674. if (i > 6)
  5675. {
  5676. fontRed.FillForegroundColor = 0;
  5677. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5678. fontRed.FillPattern = FillPattern.SolidForeground;
  5679. }
  5680. cell.CellStyle = fontRed;
  5681. }
  5682. if (i > 2 && i < 7)
  5683. {
  5684. cell.CellStyle = BackgroundColor255_242_204;
  5685. }
  5686. cell.SetCellValue(setCellValue); //写入单元格
  5687. }
  5688. if (overspendSoure.ContainsKey(thisSid))
  5689. {
  5690. var overspendId = overspendSoure[thisSid];
  5691. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5692. }
  5693. cloneRowFn();
  5694. existsId.Add(new CarCompare
  5695. {
  5696. DataPrice = item.DatePrice.ObjToDate(),
  5697. Sid = item.SId
  5698. });
  5699. }
  5700. if (item.Equals(lastElem))
  5701. {
  5702. //合并小计行
  5703. //创建合并区域的实例
  5704. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5705. rowStartIndex, // 起始行索引(0-based)
  5706. rowStartIndex, // 结束行索引(0-based)
  5707. 0, // 起始列索引(0-based)
  5708. 3 // 结束列索引(0-based)
  5709. );
  5710. sheet.AddMergedRegion(cellRangeAddress);
  5711. var CellStyle = workbook.CreateCellStyle();
  5712. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5713. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5714. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5715. for (int i = 0; i <= clounmCount; i++)
  5716. {
  5717. if (i > 6)
  5718. {
  5719. var CellStyle1 = workbook.CreateCellStyle();
  5720. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5721. IFont Font = workbook.CreateFont(); // 创建字体
  5722. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5723. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5724. CellStyle1.SetFont(Font);
  5725. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5726. }
  5727. else
  5728. {
  5729. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5730. }
  5731. }
  5732. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5733. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5734. //超时合计
  5735. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5736. //超时数
  5737. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5738. //超时合计费用
  5739. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5740. cloneRowFn();
  5741. // 创建合并区域的实例
  5742. cellRangeAddress = new CellRangeAddress(
  5743. rowStartIndex, // 起始行索引(0-based)
  5744. rowStartIndex, // 结束行索引(0-based)
  5745. 0, // 起始列索引(0-based)
  5746. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5747. );
  5748. // 添加合并区域
  5749. sheet.AddMergedRegion(cellRangeAddress);
  5750. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5751. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5752. }
  5753. }
  5754. mergeRow();
  5755. // 保存修改后的Excel文件到新文件
  5756. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5757. // new FileStream(newFilePath, FileMode.CreateNew)
  5758. using (var stream = new MemoryStream())
  5759. {
  5760. workbook.Write(stream, true);
  5761. stream.Flush();
  5762. stream.Seek(0, SeekOrigin.Begin);
  5763. MemoryStream memoryStream = new MemoryStream();
  5764. stream.CopyTo(memoryStream);
  5765. memoryStream.Seek(0, SeekOrigin.Begin);
  5766. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5767. }
  5768. workbook.Close();
  5769. workbook.Dispose();
  5770. }
  5771. catch (Exception ex)
  5772. {
  5773. jw.Msg = "出现异常!" + ex.Message;
  5774. return Ok(jw);
  5775. }
  5776. }
  5777. if (Zips.Count > 0)
  5778. {
  5779. IOOperatorHelper io = new IOOperatorHelper();
  5780. var byts = io.ConvertZipStream(Zips);
  5781. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5782. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5783. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5784. }
  5785. else
  5786. {
  5787. jw.Msg = "暂无生成文件!";
  5788. }
  5789. return Ok(jw);
  5790. }
  5791. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5792. {
  5793. string outStr = string.Empty;
  5794. switch (i)
  5795. {
  5796. case 0:
  5797. outStr = arr[0].SidName;
  5798. break;
  5799. case 1:
  5800. outStr = arr[0].DataPriceStr;
  5801. break;
  5802. case 2:
  5803. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5804. break;
  5805. case 4:
  5806. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5807. break;
  5808. case 7:
  5809. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5810. {
  5811. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5812. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5813. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5814. }
  5815. break;
  5816. case 8:
  5817. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5818. {
  5819. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5820. }
  5821. break;
  5822. case 9:
  5823. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5824. {
  5825. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5826. }
  5827. break;
  5828. case 10:
  5829. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5830. {
  5831. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5832. }
  5833. break;
  5834. }
  5835. return outStr;
  5836. }
  5837. #region OP行程单
  5838. /// <summary>
  5839. /// OP行程单初始化
  5840. /// </summary>
  5841. /// <param name="dto"></param>
  5842. /// <returns></returns>
  5843. [HttpPost]
  5844. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5845. {
  5846. var jw = JsonView(false);
  5847. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5848. var group = groupList.First();
  5849. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5850. if (group == null)
  5851. {
  5852. jw.Msg = "暂无团组!";
  5853. return Ok(jw);
  5854. }
  5855. group = groupList.Find(x => x.Id == diid);
  5856. if (group == null)
  5857. {
  5858. jw.Msg = "请输入正确的团组ID!";
  5859. return Ok(jw);
  5860. }
  5861. string city = string.Empty;
  5862. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5863. if (blackCode.Count > 0)
  5864. {
  5865. var black = blackCode.First();
  5866. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5867. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5868. if (blackSp.Length > 0)
  5869. {
  5870. try
  5871. {
  5872. var cityArrCode = new List<string>(20);
  5873. foreach (var item in blackSp)
  5874. {
  5875. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5876. var IndexSelect = itemSp[2];
  5877. var cityArrCodeLength = cityArrCode.Count - 1;
  5878. var startCity = IndexSelect.Substring(0, 3);
  5879. if (cityArrCodeLength > 0)
  5880. {
  5881. var arrEndCity = cityArrCode[cityArrCodeLength];
  5882. if (arrEndCity != startCity)
  5883. {
  5884. cityArrCode.Add(startCity.ToUpper());
  5885. }
  5886. }
  5887. else
  5888. {
  5889. cityArrCode.Add(startCity.ToUpper());
  5890. }
  5891. var endCity = IndexSelect.Substring(3, 3);
  5892. cityArrCode.Add(endCity.ToUpper());
  5893. }
  5894. var cityThree = string.Empty;
  5895. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5896. cityThree = cityThree.TrimEnd(',');
  5897. if (string.IsNullOrWhiteSpace(cityThree))
  5898. {
  5899. throw new
  5900. Exception("error");
  5901. }
  5902. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5903. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5904. foreach (var item in cityArrCode)
  5905. {
  5906. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5907. if (find != null)
  5908. {
  5909. city += find.City + "/";
  5910. }
  5911. else
  5912. {
  5913. city += item + "三字码未收入/";
  5914. }
  5915. }
  5916. city = city.TrimEnd('/');
  5917. }
  5918. catch (Exception e)
  5919. {
  5920. city = "黑屏代码格式不正确!";
  5921. }
  5922. }
  5923. }
  5924. else
  5925. {
  5926. city = "未录入黑屏代码";
  5927. }
  5928. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5929. {
  5930. Date = x.Date,
  5931. Days = x.Days,
  5932. Diffgroup = x.Diffgroup,
  5933. Diid = x.Diid,
  5934. Traffic_First = x.Traffic_First,
  5935. Traffic_Second = x.Traffic_Second,
  5936. Trip = x.Trip,
  5937. WeekDay = x.WeekDay,
  5938. Id = x.Id
  5939. }).ToList();
  5940. jw.Data = new
  5941. {
  5942. groupList = groupList.Select(x => new
  5943. {
  5944. x.Id,
  5945. x.TeamName,
  5946. x.TourCode
  5947. }).ToList(),
  5948. groupInfo = new
  5949. {
  5950. group.VisitDays,
  5951. group.TourCode,
  5952. group.VisitPNumber,
  5953. group.TeamName,
  5954. city
  5955. },
  5956. OpTravelList
  5957. };
  5958. jw.Code = 200;
  5959. jw.Msg = "操作成功!";
  5960. return Ok(jw);
  5961. }
  5962. /// <summary>
  5963. /// 删除团组行程单
  5964. /// </summary>
  5965. /// <returns></returns>
  5966. [HttpPost]
  5967. public IActionResult DelTravel(DelOpTravelDto dto)
  5968. {
  5969. var jw = JsonView(false);
  5970. if (dto.UserId <= 0 || dto.Diid <= 0)
  5971. {
  5972. jw.Msg = "请输入正确的参数!";
  5973. return Ok(jw);
  5974. }
  5975. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5976. .SetColumns(x => new Grp_TravelList
  5977. {
  5978. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5979. DeleteUserId = dto.UserId,
  5980. IsDel = 1,
  5981. }).ExecuteCommand();
  5982. jw = JsonView(true);
  5983. return Ok(jw);
  5984. }
  5985. /// <summary>
  5986. /// 行程单保存
  5987. /// </summary>
  5988. /// <returns></returns>
  5989. [HttpPost]
  5990. public IActionResult TravelSave(TravelSaveDto dto)
  5991. {
  5992. var jw = JsonView(false);
  5993. if (dto.Arr.Count > 0)
  5994. {
  5995. try
  5996. {
  5997. _sqlSugar.BeginTran();
  5998. foreach (var item in dto.Arr)
  5999. {
  6000. if (item.Id == 0)
  6001. {
  6002. throw new Exception("请传入正确的Id");
  6003. }
  6004. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  6005. .SetColumns(x => new Grp_TravelList
  6006. {
  6007. Trip = item.Trip
  6008. }).ExecuteCommand();
  6009. }
  6010. _sqlSugar.CommitTran();
  6011. jw = JsonView(true);
  6012. }
  6013. catch (Exception ex)
  6014. {
  6015. _sqlSugar.RollbackTran();
  6016. jw.Msg = "程序异常!" + ex.Message;
  6017. }
  6018. }
  6019. else
  6020. {
  6021. jw.Msg = "请传入正确的参数!";
  6022. }
  6023. return Ok(jw);
  6024. }
  6025. /// <summary>
  6026. /// 导出行程单
  6027. /// </summary>
  6028. /// <param name="dto"></param>
  6029. /// <returns></returns>
  6030. [HttpPost]
  6031. public IActionResult ExportTravel(ExportTravelDto dto)
  6032. {
  6033. var jw = JsonView(false);
  6034. jw.Data = "";
  6035. int diid = 0;
  6036. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  6037. if (Find == null)
  6038. {
  6039. jw.Msg = "请选择正确的团组!";
  6040. return Ok(jw);
  6041. }
  6042. else
  6043. {
  6044. diid = Find.Id;
  6045. }
  6046. //数据源
  6047. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  6048. DataTable dtBlack = null;
  6049. try
  6050. {
  6051. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  6052. }
  6053. catch (Exception)
  6054. {
  6055. jw.Msg = "机票黑屏代码有误!";
  6056. return Ok(jw);
  6057. }
  6058. string CityStr = string.Empty;
  6059. if (dtBlack.Rows.Count == 0)
  6060. {
  6061. jw.Msg = "机票黑屏代码有误!";
  6062. return Ok(jw);
  6063. }
  6064. else
  6065. {
  6066. foreach (DataRow row in dtBlack.Rows)
  6067. {
  6068. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  6069. {
  6070. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  6071. return Ok(jw);
  6072. }
  6073. }
  6074. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  6075. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  6076. }
  6077. //创建数据源Table
  6078. DataTable dtSource = new DataTable();
  6079. dtSource.Columns.Add("Days", typeof(string));
  6080. dtSource.Columns.Add("Date", typeof(string));
  6081. dtSource.Columns.Add("Week", typeof(string));
  6082. dtSource.Columns.Add("Traffic", typeof(string));
  6083. dtSource.Columns.Add("Trip", typeof(string));
  6084. //获取数据,放到datatable
  6085. foreach (var item in _travelList)
  6086. {
  6087. DataRow dr = dtSource.NewRow();
  6088. dr["Days"] = item.Days;
  6089. dr["Date"] = item.Date;
  6090. dr["Week"] = item.WeekDay;
  6091. dr["Traffic"] = item.Traffic_First
  6092. + "\r\n"
  6093. + item.Traffic_Second;
  6094. dr["Trip"] = item.Trip;
  6095. dtSource.Rows.Add(dr);
  6096. }
  6097. Dictionary<string, string> dic = new Dictionary<string, string>();
  6098. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6099. dic.Add("City", CityStr);
  6100. dic.Add("Days", Find.VisitDays.ToString());
  6101. dic.Add("DeleCode", Find.TourCode);
  6102. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6103. //模板路径
  6104. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6105. //载入模板
  6106. Document doc = null;
  6107. DocumentBuilder builder = null;
  6108. try
  6109. {
  6110. //载入模板
  6111. doc = new Document(tempPath);
  6112. builder = new DocumentBuilder(doc);
  6113. }
  6114. catch (Exception)
  6115. {
  6116. jw.Msg = "模板位置不存在!";
  6117. return Ok(jw);
  6118. }
  6119. foreach (var key in dic.Keys)
  6120. {
  6121. Bookmark bookmark = doc.Range.Bookmarks[key];
  6122. if (bookmark != null)
  6123. {
  6124. builder.MoveToBookmark(key);
  6125. builder.Write(dic[key]);
  6126. }
  6127. }
  6128. //获取word里所有表格
  6129. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6130. //获取所填表格的序数
  6131. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6132. try
  6133. {
  6134. //循环赋值
  6135. for (int i = 0; i < dtSource.Rows.Count; i++)
  6136. {
  6137. builder.MoveToCell(0, i + 1, 0, 0);
  6138. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6139. builder.MoveToCell(0, i + 1, 1, 0);
  6140. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6141. builder.MoveToCell(0, i + 1, 2, 0);
  6142. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6143. var trip = dtSource.Rows[i]["Trip"].ToString();
  6144. builder.MoveToCell(0, i + 1, 3, 0);
  6145. builder.Write(trip);
  6146. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6147. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6148. // 获取特定索引的段落
  6149. Paragraph paragraph = (Paragraph)paragraphs[0];
  6150. Run run = paragraph.Runs[0];
  6151. Aspose.Words.Font font = run.Font;
  6152. font.Name = "黑体";
  6153. //设置双休红色
  6154. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6155. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6156. paragraph = (Paragraph)paragraphs[1];
  6157. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6158. {
  6159. run = paragraph.Runs[0];
  6160. font = run.Font;
  6161. font.Color = Color.Red;
  6162. }
  6163. }
  6164. }
  6165. catch (Exception ex)
  6166. {
  6167. }
  6168. //删除多余行
  6169. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6170. {
  6171. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6172. }
  6173. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6174. if (!Directory.Exists(savePath))
  6175. {
  6176. try
  6177. {
  6178. Directory.CreateDirectory(savePath);
  6179. }
  6180. catch
  6181. {
  6182. }
  6183. }
  6184. string path = savePath + Find.TeamName + "出访日程";
  6185. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6186. try
  6187. {
  6188. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6189. string postfix = ".docx";
  6190. if (dto.IsPDF == 1)
  6191. {
  6192. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6193. postfix = ".pdf";
  6194. }
  6195. doc.Save(path + postfix, saveFormat);
  6196. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6197. }
  6198. catch (Exception)
  6199. {
  6200. jw = JsonView(false);
  6201. }
  6202. return Ok(jw);
  6203. }
  6204. /// <summary>
  6205. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6206. /// </summary>
  6207. /// <param name="num"></param>
  6208. /// <returns></returns>
  6209. string GetNum(string num)
  6210. {
  6211. string str = "";
  6212. switch (num)
  6213. {
  6214. case "1":
  6215. str = "一";
  6216. break;
  6217. case "2":
  6218. str = "二";
  6219. break;
  6220. case "3":
  6221. str = "三";
  6222. break;
  6223. case "4":
  6224. str = "四";
  6225. break;
  6226. case "5":
  6227. str = "五";
  6228. break;
  6229. case "6":
  6230. str = "六";
  6231. break;
  6232. case "7":
  6233. str = "七";
  6234. break;
  6235. case "8":
  6236. str = "八";
  6237. break;
  6238. case "9":
  6239. str = "九";
  6240. break;
  6241. case "10":
  6242. str = "十";
  6243. break;
  6244. case "11":
  6245. str = "十一";
  6246. break;
  6247. case "12":
  6248. str = "十二";
  6249. break;
  6250. case "一":
  6251. str = "1";
  6252. break;
  6253. case "二":
  6254. str = "2";
  6255. break;
  6256. case "三":
  6257. str = "3";
  6258. break;
  6259. case "四":
  6260. str = "4";
  6261. break;
  6262. case "五":
  6263. str = "5";
  6264. break;
  6265. case "六":
  6266. str = "6";
  6267. break;
  6268. case "七":
  6269. str = "7";
  6270. break;
  6271. case "八":
  6272. str = "8";
  6273. break;
  6274. case "九":
  6275. str = "9";
  6276. break;
  6277. case "十":
  6278. str = "10";
  6279. break;
  6280. case "十一":
  6281. str = "11";
  6282. break;
  6283. case "十二":
  6284. str = "12";
  6285. break;
  6286. }
  6287. return str;
  6288. }
  6289. #endregion
  6290. #endregion
  6291. #region 团组成本
  6292. /// <summary>
  6293. /// 团组成本数据初始化
  6294. /// </summary>
  6295. /// <param name="dto"></param>
  6296. /// <returns></returns>
  6297. [HttpPost]
  6298. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6299. {
  6300. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6301. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6302. WHEN COUNT(*) >= 0 THEN 'True'
  6303. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6304. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6305. ").ToList(); //团组列表
  6306. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6307. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6308. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6309. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6310. if (groupinfoValue != null)
  6311. {
  6312. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6313. var spArr = new string[1] { countryArr };
  6314. if (countryArr.Contains("|"))
  6315. {
  6316. spArr = countryArr.Split("|");
  6317. }
  6318. else if (countryArr.Contains("、"))
  6319. {
  6320. spArr = countryArr.Split("、");
  6321. }
  6322. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6323. {
  6324. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6325. if (dbQueryCountry != null)
  6326. {
  6327. visaCountryInfoArr.Add(dbQueryCountry);
  6328. }
  6329. }
  6330. }
  6331. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6332. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6333. var create = _GroupCostRepository.
  6334. CreateGroupCostByBlackCode(dto.Diid);
  6335. if (groupCost.Count == 0 && create.Code == 0)
  6336. {
  6337. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6338. }
  6339. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6340. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6341. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6342. groupCostMap = groupCostMap.Select(x =>
  6343. {
  6344. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6345. {
  6346. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6347. }
  6348. return x;
  6349. }).ToList();
  6350. //GroupCostParameter.Add(new
  6351. // Grp_GroupCostParameter());
  6352. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6353. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6354. return Ok(JsonView(new
  6355. {
  6356. groupList,
  6357. groupInfo,
  6358. groupChecks,
  6359. groupCost = groupCostMap,
  6360. hotelNumber,
  6361. GroupCostParameter = GroupCostParameterMap,
  6362. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6363. {
  6364. x.VisaCountry,
  6365. x.VisaPrice,
  6366. x.Id,
  6367. }).ToList(),
  6368. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6369. blackCodeIsTrue = create.Code == 0 ? true : false,
  6370. hotelIsTrue = hotelIsTrue,
  6371. }));
  6372. }
  6373. /// <summary>
  6374. /// 团组成本信息保存
  6375. /// </summary>
  6376. /// <param name="dto"></param>
  6377. /// <returns></returns>
  6378. [HttpPost]
  6379. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6380. {
  6381. if (dto.Diid <= 0 || dto.Userid <= 0)
  6382. {
  6383. return Ok(JsonView(false));
  6384. }
  6385. JsonView jw = null;
  6386. bool isTrue = false;
  6387. #region 复制团组成本
  6388. //if (dto.Diid == 2581)
  6389. //{
  6390. // dto.Diid = 2599;
  6391. // dto.CheckBoxs.ForEach(x =>
  6392. // {
  6393. // x.Diid = 2599;
  6394. // });
  6395. // dto.GroupCosts.ForEach(x =>
  6396. // {
  6397. // x.Diid = 2599;
  6398. // });
  6399. // dto.CostTypeHotelNumbers.ForEach(x =>
  6400. // {
  6401. // x.Diid = 2599;
  6402. // });
  6403. // dto.GroupCostParameters.ForEach(x =>
  6404. // {
  6405. // x.DiId = 2599;
  6406. // });
  6407. //}
  6408. #endregion
  6409. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6410. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6411. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6412. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6413. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6414. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6415. try
  6416. {
  6417. _sqlSugar.BeginTran();
  6418. isTrue = await _GroupCostRepository.
  6419. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6420. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6421. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6422. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6423. _sqlSugar.CommitTran();
  6424. jw = JsonView(true, "保存成功!", isTrue);
  6425. }
  6426. catch (Exception)
  6427. {
  6428. _sqlSugar.RollbackTran();
  6429. jw = JsonView(false);
  6430. }
  6431. return Ok(jw);
  6432. }
  6433. /// <summary>
  6434. /// 司兼导数据
  6435. /// </summary>
  6436. /// <param name="dto"></param>
  6437. /// <returns></returns>
  6438. [HttpPost]
  6439. public IActionResult GetCarGuides(CarGuidesDto dto)
  6440. {
  6441. JsonView jw = null;
  6442. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6443. jw = JsonView(true, "获取成功!", Data);
  6444. return Ok(jw);
  6445. }
  6446. /// <summary>
  6447. /// 导游数据
  6448. /// </summary>
  6449. /// <param name="dto"></param>
  6450. /// <returns></returns>
  6451. [HttpPost]
  6452. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6453. {
  6454. JsonView jw = null;
  6455. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6456. // 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
  6457. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6458. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6459. jw = JsonView(true, "获取成功!", Data);
  6460. return Ok(jw);
  6461. }
  6462. /// <summary>
  6463. /// 成本车数据
  6464. /// </summary>
  6465. /// <param name="dto"></param>
  6466. /// <returns></returns>
  6467. [HttpPost]
  6468. public IActionResult GetCarInfo(CarGuidesDto dto)
  6469. {
  6470. JsonView jw = null;
  6471. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6472. jw = JsonView(true, "获取成功!", Data);
  6473. return Ok(jw);
  6474. }
  6475. /// <summary>
  6476. /// 景点数据
  6477. /// </summary>
  6478. /// <param name="dto"></param>
  6479. /// <returns></returns>
  6480. [HttpPost]
  6481. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6482. {
  6483. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6484. return Ok(JsonView(true, "获取成功!", Data));
  6485. }
  6486. /// <summary>
  6487. /// 成本通知
  6488. /// </summary>
  6489. /// <param name="dto"></param>
  6490. /// <returns></returns>
  6491. [HttpPost]
  6492. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6493. {
  6494. if (dto.Diid < 0)
  6495. {
  6496. return Ok(JsonView(false));
  6497. }
  6498. JsonView jw = null;
  6499. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6500. if (GroupCostParameter != null)
  6501. {
  6502. int IsShare = 0;
  6503. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6504. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6505. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6506. string msg = string.Empty;
  6507. if (isTrue)
  6508. {
  6509. if (IsShare == 0)
  6510. {
  6511. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6512. }
  6513. else
  6514. {
  6515. #region 企微通知对应岗位用户
  6516. try
  6517. {
  6518. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6519. }
  6520. catch (Exception ex)
  6521. {
  6522. }
  6523. #endregion
  6524. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6525. }
  6526. jw = JsonView(isTrue, msg, new { IsShare });
  6527. }
  6528. else
  6529. {
  6530. msg = "修改失败!";
  6531. jw = JsonView(isTrue, msg);
  6532. }
  6533. }
  6534. else
  6535. {
  6536. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6537. }
  6538. return Ok(jw);
  6539. }
  6540. /// <summary>
  6541. /// 导出报价单
  6542. /// </summary>
  6543. /// <param name="dto"></param>
  6544. /// <returns></returns>
  6545. [HttpPost]
  6546. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6547. {
  6548. if (dto.Diid == 0)
  6549. {
  6550. return Ok(JsonView(false, "请传递团组id"));
  6551. }
  6552. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6553. if (deleInfo.Code != 0)
  6554. {
  6555. return Ok(JsonView(false, "团组信息查询失败!"));
  6556. }
  6557. var di = deleInfo.Data as DelegationInfoWebView;
  6558. if (di != null)
  6559. {
  6560. //文件名
  6561. string strFileName = di.TeamName + "-收款账单.doc";
  6562. //获取模板
  6563. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6564. //载入模板
  6565. Document doc = new Document(tmppath);
  6566. decimal TotalPrice = 0.00M;
  6567. string itemStr = string.Empty;
  6568. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6569. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6570. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6571. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6572. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6573. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6574. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6575. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6576. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6577. foreach (var cost in groupCostType)
  6578. {
  6579. var List = cost.ToList();
  6580. if (cost.Key == "A")
  6581. {
  6582. foreach (var ListItem in List)
  6583. {
  6584. if (ListItem.number > 0)
  6585. {
  6586. if (ListItem.code.Contains("TBR"))
  6587. {
  6588. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6589. }
  6590. else
  6591. {
  6592. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6593. }
  6594. TotalPrice += (ListItem.number * ListItem.price);
  6595. }
  6596. }
  6597. }
  6598. else
  6599. {
  6600. itemStr = itemStr.Insert(0, "A段\r\n");
  6601. itemStr += "B段\r\n";
  6602. foreach (var ListItem in List)
  6603. {
  6604. if (ListItem.number > 0)
  6605. {
  6606. if (ListItem.code.Contains("TBR"))
  6607. {
  6608. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6609. }
  6610. else
  6611. {
  6612. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6613. }
  6614. TotalPrice += (ListItem.number * ListItem.price);
  6615. }
  6616. }
  6617. }
  6618. }
  6619. #region 替换Word模板书签内容
  6620. Dictionary<string, string> marks = new Dictionary<string, string>();
  6621. marks.Add("To", di.ClientUnit);//付款方
  6622. marks.Add("ToTel", di.TellPhone);//付款方电话
  6623. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6624. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6625. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6626. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6627. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6628. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6629. marks.Add("PayItemContent", itemStr);//详细信息
  6630. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6631. #endregion
  6632. ////注
  6633. //if (doc.Range.Bookmarks["Attention"] != null)
  6634. //{
  6635. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6636. // mark.Text = frList[0].Attention;
  6637. //}
  6638. foreach (var item in marks.Keys)
  6639. {
  6640. if (doc.Range.Bookmarks[item] != null)
  6641. {
  6642. Bookmark mark = doc.Range.Bookmarks[item];
  6643. mark.Text = marks[item];
  6644. }
  6645. }
  6646. byte[] bytes = null;
  6647. using (MemoryStream stream = new MemoryStream())
  6648. {
  6649. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6650. bytes = stream.ToArray();
  6651. }
  6652. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6653. return Ok(JsonView(true, "", new
  6654. {
  6655. Data = bytes,
  6656. strFileName,
  6657. }));
  6658. }
  6659. else
  6660. {
  6661. return Ok(JsonView(false, "团组信息不存在!"));
  6662. }
  6663. }
  6664. /// <summary>
  6665. /// 导出团组成本
  6666. /// </summary>
  6667. /// <param name="dto"></param>
  6668. /// <returns></returns>
  6669. [HttpPost]
  6670. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6671. {
  6672. var jw = JsonView(false);
  6673. if (dto.Diid == 0)
  6674. {
  6675. return Ok(JsonView(false, "请传递团组id"));
  6676. }
  6677. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6678. if (deleInfo.Code != 0)
  6679. {
  6680. return Ok(JsonView(false, "团组信息查询失败!"));
  6681. }
  6682. var di = deleInfo.Data as DelegationInfoWebView;
  6683. if (di == null)
  6684. {
  6685. return Ok(JsonView(false, "团组信息查询失败!"));
  6686. }
  6687. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6688. WorkbookDesigner designer = new WorkbookDesigner();
  6689. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6690. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6691. for (int i = 0; i < List_GC.Count; i++)
  6692. {
  6693. GroupCost_Excel gc = new GroupCost_Excel();
  6694. gc.Id = List_GC[i].Id;
  6695. gc.Diid = List_GC[i].Diid.ToString();
  6696. gc.DAY = List_GC[i].DAY;
  6697. string week = "";
  6698. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6699. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6700. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6701. gc.ITIN = List_GC[i].ITIN;
  6702. gc.CarType = List_GC[i].CarType;
  6703. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6704. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6705. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6706. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6707. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6708. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6709. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6710. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6711. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6712. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6713. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6714. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6715. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6716. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6717. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6718. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6719. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6720. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6721. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6722. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6723. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6724. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6725. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6726. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6727. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6728. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6729. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6730. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6731. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6732. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6733. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6734. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6735. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6736. List_GC1.Add(gc);
  6737. }
  6738. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6739. dt.TableName = "TB";
  6740. //报表标题等不用dt的值
  6741. designer.SetDataSource("TeamName", dto.title.TeamName);
  6742. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6743. designer.SetDataSource("Tax", dto.title.Tax);
  6744. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6745. designer.SetDataSource("Currency", dto.title.Currency);
  6746. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6747. designer.SetDataSource("Rate", dto.title.Rate);
  6748. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6749. var Aparams = hotels.Find(x => x.Type == "Default");
  6750. if (Aparams == null)
  6751. {
  6752. return Ok(jw);
  6753. }
  6754. //酒店数量
  6755. var txtSGRNumber = Aparams.SGR.ToString();
  6756. var txtTBRNumber = Aparams.TBR.ToString();
  6757. var txtJSESNumber = Aparams.JSES.ToString();
  6758. var txtSUITENumbe = Aparams.SUITE.ToString();
  6759. if (dto.costType == "B")
  6760. {
  6761. Aparams = hotels.Find(x => x.Type == "A");
  6762. var Bparams = hotels.Find(x => x.Type == "B");
  6763. if (Aparams == null || Bparams == null)
  6764. {
  6765. return Ok(jw);
  6766. }
  6767. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6768. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6769. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6770. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6771. }
  6772. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6773. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6774. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6775. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6776. var ws = designer.Workbook.Worksheets[0];
  6777. int Row = List_GC.Count;
  6778. int startIndex = 11;
  6779. int HideRows = 0;
  6780. List<int> hideRowsList = new List<int>();
  6781. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6782. #region A段left数据
  6783. var left = dto.leftInfo.Find(x => x.Type == "A");
  6784. if (left == null)
  6785. {
  6786. return Ok(jw);
  6787. }
  6788. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6789. if (leftBindData != null)
  6790. {
  6791. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6792. designer.SetDataSource("VisaRS", leftBindData.rs);
  6793. designer.SetDataSource("VisaXS", leftBindData.xs);
  6794. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6795. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6796. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6797. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6798. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6799. }
  6800. else
  6801. {
  6802. hideRowsList.Add(Row + startIndex + HideRows);
  6803. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6804. }
  6805. HideRows += 2;
  6806. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6807. if (leftBindData != null)
  6808. {
  6809. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6810. designer.SetDataSource("BXRS", leftBindData.rs);
  6811. designer.SetDataSource("BXXS", leftBindData.xs);
  6812. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6813. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6814. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6815. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6816. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6817. }
  6818. else
  6819. {
  6820. hideRowsList.Add(Row + startIndex + HideRows);
  6821. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6822. }
  6823. HideRows += 2;
  6824. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6825. if (leftBindData != null)
  6826. {
  6827. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6828. designer.SetDataSource("HSRS", leftBindData.rs);
  6829. designer.SetDataSource("HSXS", leftBindData.xs);
  6830. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6831. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6832. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6833. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6834. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6835. }
  6836. else
  6837. {
  6838. hideRowsList.Add(Row + startIndex + HideRows);
  6839. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6840. }
  6841. HideRows += 2;
  6842. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6843. if (leftBindData != null)
  6844. {
  6845. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6846. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6847. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6848. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6849. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6850. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6851. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6852. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6853. }
  6854. else
  6855. {
  6856. hideRowsList.Add(Row + startIndex + HideRows);
  6857. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6858. }
  6859. HideRows += 2;
  6860. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6861. if (leftBindData != null)
  6862. {
  6863. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6864. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6865. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6866. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6867. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6868. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6869. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6870. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6871. }
  6872. else
  6873. {
  6874. hideRowsList.Add(Row + startIndex + HideRows);
  6875. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6876. }
  6877. HideRows += 2;
  6878. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6879. if (leftBindData != null)
  6880. {
  6881. ////TBR
  6882. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6883. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6884. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6885. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6886. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6887. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6888. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6889. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6890. }
  6891. else
  6892. {
  6893. hideRowsList.Add(Row + startIndex + HideRows);
  6894. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6895. }
  6896. HideRows += 2;
  6897. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6898. if (leftBindData != null)
  6899. {
  6900. ////SGR
  6901. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6902. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6903. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6904. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6905. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6906. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6907. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6908. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6909. }
  6910. else
  6911. {
  6912. hideRowsList.Add(Row + startIndex + HideRows);
  6913. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6914. }
  6915. HideRows += 2;
  6916. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6917. if (leftBindData != null)
  6918. {
  6919. ////JS/ES
  6920. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6921. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6922. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6923. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6924. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6925. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6926. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6927. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6928. }
  6929. else
  6930. {
  6931. hideRowsList.Add(Row + startIndex + HideRows);
  6932. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6933. }
  6934. HideRows += 2;
  6935. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6936. if (leftBindData != null)
  6937. {
  6938. ////SUITE
  6939. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6940. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6941. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6942. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6943. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6944. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6945. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6946. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6947. }
  6948. else
  6949. {
  6950. hideRowsList.Add(Row + startIndex + HideRows);
  6951. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6952. }
  6953. HideRows += 2;
  6954. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6955. if (leftBindData != null)
  6956. {
  6957. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6958. designer.SetDataSource("DJRS", leftBindData.rs);
  6959. designer.SetDataSource("DJXS", leftBindData.xs);
  6960. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6961. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6962. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6963. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6964. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6965. }
  6966. else
  6967. {
  6968. hideRowsList.Add(Row + startIndex + HideRows);
  6969. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6970. }
  6971. HideRows += 2;
  6972. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6973. if (leftBindData != null)
  6974. {
  6975. designer.SetDataSource("HCPCB", leftBindData.cb);
  6976. designer.SetDataSource("HCPRS", leftBindData.rs);
  6977. designer.SetDataSource("HCPXS", leftBindData.xs);
  6978. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6979. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6980. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6981. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6982. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6983. }
  6984. else
  6985. {
  6986. hideRowsList.Add(Row + startIndex + HideRows);
  6987. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6988. }
  6989. HideRows += 2;
  6990. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  6991. if (leftBindData != null)
  6992. {
  6993. designer.SetDataSource("CPCB", leftBindData.cb);
  6994. designer.SetDataSource("CPRS", leftBindData.rs);
  6995. designer.SetDataSource("CPXS", leftBindData.xs);
  6996. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6997. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6998. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6999. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7000. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7001. }
  7002. else
  7003. {
  7004. hideRowsList.Add(Row + startIndex + HideRows);
  7005. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7006. }
  7007. HideRows += 2;
  7008. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7009. if (leftBindData != null)
  7010. {
  7011. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7012. designer.SetDataSource("GWRS", leftBindData.rs);
  7013. designer.SetDataSource("GWXS", leftBindData.xs);
  7014. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7015. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7016. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7017. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7018. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7019. }
  7020. else
  7021. {
  7022. hideRowsList.Add(Row + startIndex + HideRows);
  7023. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7024. }
  7025. HideRows += 2;
  7026. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7027. if (leftBindData != null)
  7028. {
  7029. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7030. designer.SetDataSource("LYJRS", leftBindData.rs);
  7031. designer.SetDataSource("LYJXS", leftBindData.xs);
  7032. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7033. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7034. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7035. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7036. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7037. }
  7038. else
  7039. {
  7040. hideRowsList.Add(Row + startIndex + HideRows);
  7041. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7042. }
  7043. #endregion
  7044. #region A段Right信息
  7045. var right = dto.rightInfo.Find(x => x.Type == "A");
  7046. if (right == null)
  7047. {
  7048. return Ok(jw);
  7049. }
  7050. HideRows += 4;
  7051. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7052. if (rightBindData != null)
  7053. {
  7054. //经济舱 + 双人间 TBR
  7055. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7056. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7057. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7058. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7059. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7060. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7061. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7062. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7063. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7064. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7065. }
  7066. else
  7067. {
  7068. hideRowsList.Add(Row + startIndex + HideRows);
  7069. }
  7070. HideRows += 2;
  7071. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7072. if (rightBindData != null)
  7073. {
  7074. //经济舱 + 单人间 SGR
  7075. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7076. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7077. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7078. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7079. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7080. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7081. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7082. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7083. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7084. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7085. }
  7086. else
  7087. {
  7088. hideRowsList.Add(Row + startIndex + HideRows);
  7089. }
  7090. HideRows += 2;
  7091. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7092. if (rightBindData != null)
  7093. {
  7094. //公务舱 + 单人间 SGR
  7095. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7096. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7097. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7098. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7099. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7100. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7101. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7102. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7103. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7104. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7105. }
  7106. else
  7107. {
  7108. hideRowsList.Add(Row + startIndex + HideRows);
  7109. }
  7110. HideRows += 2;
  7111. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7112. if (rightBindData != null)
  7113. {
  7114. //公务舱 + 小套房 JSES
  7115. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7116. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7117. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7118. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7119. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7120. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7121. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7122. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7123. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7124. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7125. }
  7126. else
  7127. {
  7128. hideRowsList.Add(Row + startIndex + HideRows);
  7129. }
  7130. HideRows += 2;
  7131. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7132. if (rightBindData != null)
  7133. {
  7134. //公务舱 + 小套房 JSES
  7135. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7136. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7137. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7138. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7139. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7140. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7141. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7142. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7143. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7144. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7145. }
  7146. else
  7147. {
  7148. hideRowsList.Add(Row + startIndex + HideRows);
  7149. }
  7150. HideRows += 2;
  7151. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7152. if (rightBindData != null)
  7153. {
  7154. //经济舱 + 大套房
  7155. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7156. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7157. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7158. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7159. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7160. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7161. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7162. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7163. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7164. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7165. }
  7166. else
  7167. {
  7168. hideRowsList.Add(Row + startIndex + HideRows);
  7169. }
  7170. #endregion
  7171. #region B段标题清空
  7172. designer.SetDataSource("CostBDRCB", "");
  7173. designer.SetDataSource("CostBRS", "");
  7174. designer.SetDataSource("CostBXS", "");
  7175. designer.SetDataSource("CostBZCB", "");
  7176. designer.SetDataSource("CostBDRBJ", "");
  7177. designer.SetDataSource("CostBZBJ", "");
  7178. designer.SetDataSource("CostBDRLR", "");
  7179. designer.SetDataSource("CostBZLR", "");
  7180. designer.SetDataSource("CostBDRCBOM", "");
  7181. designer.SetDataSource("CostBRSOM", "");
  7182. designer.SetDataSource("CostBZCBOM", "");
  7183. designer.SetDataSource("CostBDRBJOM", "");
  7184. designer.SetDataSource("CostBZBJOM", "");
  7185. designer.SetDataSource("CostBDRLROM", "");
  7186. designer.SetDataSource("CostBZLROM", "");
  7187. #endregion
  7188. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7189. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7190. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7191. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7192. designer.SetDataSource("DJName", "地接(CNY)");
  7193. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7194. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7195. designer.SetDataSource("GWName", "公务(CNY)");
  7196. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7197. designer.SetDataSource("LYJName", "零用金(CNY)");
  7198. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7199. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7200. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7201. designer.SetDataSource("BXName", "保险(CNY)");
  7202. designer.SetDataSource("VisaName", "签证(CNY)");
  7203. #region B段基本数据
  7204. if (dto.costType == "B")
  7205. {
  7206. left = dto.leftInfo.Find(x => x.Type == "B");
  7207. if (left == null)
  7208. {
  7209. return Ok(jw);
  7210. }
  7211. #region B段left数据
  7212. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7213. if (leftBindData != null)
  7214. {
  7215. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7216. designer.SetDataSource("BHSRS", leftBindData.rs);
  7217. designer.SetDataSource("BHSXS", leftBindData.xs);
  7218. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7219. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7220. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7221. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7222. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7223. }
  7224. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7225. if (leftBindData != null)
  7226. {
  7227. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7228. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7229. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7230. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7231. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7232. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7233. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7234. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7235. }
  7236. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7237. if (leftBindData != null)
  7238. {
  7239. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7240. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7241. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7242. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7243. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7244. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7245. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7246. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7247. }
  7248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7249. if (leftBindData != null)
  7250. {
  7251. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7252. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7253. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7254. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7255. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7256. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7257. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7258. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7259. }
  7260. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7261. if (leftBindData != null)
  7262. {
  7263. designer.SetDataSource("BCPCB", leftBindData.cb);
  7264. designer.SetDataSource("BCPRS", leftBindData.rs);
  7265. designer.SetDataSource("BCPXS", leftBindData.xs);
  7266. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7267. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7268. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7269. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7270. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7271. }
  7272. //TBR
  7273. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7274. if (leftBindData != null)
  7275. {
  7276. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7277. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7278. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7279. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7280. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7281. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7282. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7283. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7284. }
  7285. //SGR
  7286. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7287. if (leftBindData != null)
  7288. {
  7289. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7290. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7291. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7292. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7293. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7294. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7295. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7296. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7297. }
  7298. //JS/ES
  7299. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7300. if (leftBindData != null)
  7301. {
  7302. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7303. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7304. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7305. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7306. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7307. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7308. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7309. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7310. }
  7311. //SUITE
  7312. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7313. if (leftBindData != null)
  7314. {
  7315. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7316. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7317. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7318. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7319. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7320. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7321. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7322. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7323. }
  7324. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7325. if (leftBindData != null)
  7326. {
  7327. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7328. designer.SetDataSource("BDJRS", leftBindData.rs);
  7329. designer.SetDataSource("BDJXS", leftBindData.xs);
  7330. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7331. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7332. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7333. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7334. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7335. }
  7336. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7337. if (leftBindData != null)
  7338. {
  7339. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7340. designer.SetDataSource("BGWRS", leftBindData.rs);
  7341. designer.SetDataSource("BGWXS", leftBindData.xs);
  7342. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7343. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7344. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7345. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7346. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7347. }
  7348. #region 优化方案
  7349. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7350. //excelBind.Add("零用金", new {
  7351. //cb="",
  7352. //rs="",
  7353. //xs ="",
  7354. //zcb = "",
  7355. //});
  7356. #endregion
  7357. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7358. if (leftBindData != null)
  7359. {
  7360. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7361. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7362. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7363. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7364. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7365. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7366. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7367. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7368. }
  7369. #endregion
  7370. #region B段Right信息
  7371. right = dto.rightInfo.Find(x => x.Type == "B");
  7372. if (right == null)
  7373. {
  7374. return Ok(jw);
  7375. }
  7376. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7377. if (rightBindData != null)
  7378. {
  7379. //经济舱 + 双人间 TBR
  7380. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7381. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7382. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7383. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7384. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7385. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7386. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7387. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7388. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7389. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7390. }
  7391. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7392. if (rightBindData != null)
  7393. {
  7394. //经济舱 + 单人间 SGR
  7395. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7396. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7397. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7398. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7399. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7400. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7401. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7402. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7403. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7404. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7405. }
  7406. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7407. if (rightBindData != null)
  7408. {
  7409. //公务舱 + 单人间 SGR
  7410. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7411. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7412. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7413. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7414. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7415. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7416. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7417. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7418. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7419. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7420. }
  7421. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7422. if (rightBindData != null)
  7423. {
  7424. //公务舱 + 小套房 JSES
  7425. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7426. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7427. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7428. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7429. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7430. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7431. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7432. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7433. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7434. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7435. }
  7436. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7437. if (rightBindData != null)
  7438. {
  7439. //公务舱 + 小套房 JSES
  7440. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7441. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7442. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7443. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7444. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7445. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7446. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7447. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7448. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7449. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7450. }
  7451. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7452. if (rightBindData != null)
  7453. {
  7454. //经济舱 + 大套房
  7455. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7456. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7457. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7458. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7459. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7460. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7461. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7462. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7463. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7464. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7465. }
  7466. #endregion
  7467. #region 标题
  7468. designer.SetDataSource("CostBDRCB", "单人成本");
  7469. designer.SetDataSource("CostBRS", "人数");
  7470. designer.SetDataSource("CostBXS", "系数");
  7471. designer.SetDataSource("CostBZCB", "总成本");
  7472. designer.SetDataSource("CostBDRBJ", "单人报价");
  7473. designer.SetDataSource("CostBZBJ", "总报价");
  7474. designer.SetDataSource("CostBDRLR", "单人利润");
  7475. designer.SetDataSource("CostBZLR", "总利润");
  7476. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7477. designer.SetDataSource("CostBRSOM", "人数");
  7478. designer.SetDataSource("CostBZCBOM", "总成本");
  7479. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7480. designer.SetDataSource("CostBZBJOM", "总报价");
  7481. designer.SetDataSource("CostBDRLROM", "单人利润");
  7482. designer.SetDataSource("CostBZLROM", "总利润");
  7483. #endregion
  7484. }
  7485. #endregion
  7486. designer.SetDataSource("TzZCB2", TzZCB2);
  7487. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7488. designer.SetDataSource("TzZLR2", TzZLR2);
  7489. string[] dataSourceKeys = new string[]
  7490. {
  7491. "VF",
  7492. "TGS",
  7493. "TGOF",
  7494. "TGM",
  7495. "TGA",
  7496. "TGTF",
  7497. "TGEF",
  7498. "CFM",
  7499. "CFOF",
  7500. "B",
  7501. "L",
  7502. "D",
  7503. "TBR",
  7504. "SGR",
  7505. "JSES",
  7506. "Suite",
  7507. "TV",
  7508. "1L",
  7509. "IF",
  7510. "EF",
  7511. "BRF",
  7512. "TE",
  7513. "TGT",
  7514. "DRVT",
  7515. "PC",
  7516. "TLF",
  7517. "ECT"
  7518. };
  7519. foreach (var item in dataSourceKeys)
  7520. {
  7521. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7522. if (find != null)
  7523. {
  7524. designer.SetDataSource(item, find.text);
  7525. }
  7526. else
  7527. {
  7528. designer.SetDataSource(item, 0);
  7529. }
  7530. }
  7531. designer.SetDataSource(dt);
  7532. //根据数据源处理生成报表内容
  7533. designer.Process();
  7534. designer.Workbook.Worksheets[0].Name = "清单";
  7535. Worksheet sheet = designer.Workbook.Worksheets[0];
  7536. foreach (var Rowindex in hideRowsList)
  7537. {
  7538. ws.Cells.HideRows(Rowindex, 2);
  7539. }
  7540. byte[] bytes = null;
  7541. string strFileName = di.TeamName + "-团组-成本.xls";
  7542. using (MemoryStream stream = new MemoryStream())
  7543. {
  7544. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7545. bytes = stream.ToArray();
  7546. }
  7547. return Ok(JsonView(true, "", new
  7548. {
  7549. Data = bytes,
  7550. strFileName,
  7551. }));
  7552. }
  7553. /// <summary>
  7554. /// 导出客户报表
  7555. /// </summary>
  7556. /// <returns></returns>
  7557. [HttpPost]
  7558. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7559. {
  7560. var jw = JsonView(false);
  7561. if (dto.Diid == 0)
  7562. {
  7563. return Ok(JsonView(false, "请传递团组id"));
  7564. }
  7565. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7566. if (deleInfo.Code != 0)
  7567. {
  7568. return Ok(JsonView(false, "团组信息查询失败!"));
  7569. }
  7570. var di = deleInfo.Data as DelegationInfoWebView;
  7571. if (di == null)
  7572. {
  7573. return Ok(JsonView(false, "团组信息查询失败!"));
  7574. }
  7575. //文件名
  7576. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7577. //获取模板
  7578. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7579. //载入模板
  7580. Document doc = new Document(tmppath);
  7581. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7582. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7583. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7584. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7585. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7586. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7587. if (AParameter == null)
  7588. {
  7589. return Ok(JsonView(false, "系数不存在!"));
  7590. }
  7591. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7592. , TzAirDesc, TzZCost;
  7593. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7594. = TzAirDesc = TzZCost = string.Empty;
  7595. TzNumber = AParameter.CostTypenumber.ToString();
  7596. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7597. CarGuides1 = dto.CarGuides1;
  7598. Meal = dto.Meal;
  7599. SubsidizedMeals = dto.SubsidizedMeals;
  7600. NightRepair = dto.NightRepair;
  7601. AttractionsTickets = dto.AttractionsTickets;
  7602. MiscellaneousFees = dto.MiscellaneousFees;
  7603. ATip = dto.ATip;
  7604. TzHotelDesc = "";
  7605. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7606. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7607. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7608. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7609. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7610. TzAirDesc = "";
  7611. TzZCost = dto.TzZCost;
  7612. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7613. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7614. var index = 1;
  7615. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7616. foreach (var item in TzHotelDescArr)
  7617. {
  7618. if (AinfoArr != null)
  7619. {
  7620. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7621. if (Ainfo != null)
  7622. {
  7623. if (int.Parse(Ainfo.rs) <= 0)
  7624. {
  7625. continue;
  7626. }
  7627. var hotelText = string.Empty;
  7628. switch (item)
  7629. {
  7630. case "SGR":
  7631. hotelText = "单人间";
  7632. break;
  7633. case "JSES":
  7634. hotelText = "小套房";
  7635. break;
  7636. case "SUITE":
  7637. hotelText = "套房";
  7638. break;
  7639. case "TBR":
  7640. hotelText = "双人间";
  7641. break;
  7642. }
  7643. if (item != "TBR")
  7644. {
  7645. 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";
  7646. }
  7647. else
  7648. {
  7649. 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";
  7650. }
  7651. index++;
  7652. }
  7653. }
  7654. }
  7655. index = 1;
  7656. foreach (var item in TzAirDescArr)
  7657. {
  7658. if (AinfoArr != null)
  7659. {
  7660. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7661. if (Ainfo != null)
  7662. {
  7663. if (int.Parse(Ainfo.rs) <= 0)
  7664. {
  7665. continue;
  7666. }
  7667. 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";
  7668. index++;
  7669. }
  7670. }
  7671. }
  7672. if (dto.costType == "B")
  7673. {
  7674. if (BParameter == null)
  7675. {
  7676. return Ok(JsonView(false, "B段系数不存在!"));
  7677. }
  7678. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7679. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7680. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7681. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7682. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7683. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7684. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7685. foreach (var item in TzHotelDescArr)
  7686. {
  7687. if (AinfoArr != null)
  7688. {
  7689. TzHotelDesc += "B段信息 \r\n";
  7690. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7691. if (Ainfo != null)
  7692. {
  7693. if (int.Parse(Ainfo.rs) <= 0)
  7694. {
  7695. continue;
  7696. }
  7697. var hotelText = string.Empty;
  7698. switch (item)
  7699. {
  7700. case "SGR":
  7701. hotelText = "单人间";
  7702. break;
  7703. case "JSES":
  7704. hotelText = "小套房";
  7705. break;
  7706. case "SUITE":
  7707. hotelText = "套房";
  7708. break;
  7709. case "TBR":
  7710. hotelText = "双人间";
  7711. break;
  7712. }
  7713. if (item != "TBR")
  7714. {
  7715. 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";
  7716. }
  7717. else
  7718. {
  7719. 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";
  7720. }
  7721. index++;
  7722. }
  7723. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7724. }
  7725. }
  7726. index = 1;
  7727. foreach (var item in TzAirDescArr)
  7728. {
  7729. if (AinfoArr != null)
  7730. {
  7731. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7732. if (Ainfo != null)
  7733. {
  7734. if (int.Parse(Ainfo.rs) <= 0)
  7735. {
  7736. continue;
  7737. }
  7738. 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";
  7739. index++;
  7740. }
  7741. }
  7742. }
  7743. }
  7744. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7745. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7746. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7747. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7748. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7749. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7750. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7751. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7752. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7753. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7754. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7755. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7756. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7757. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7758. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7759. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7760. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7761. DickeyValue.Add("TzZCost", TzZCost);
  7762. foreach (var key in DickeyValue.Keys)
  7763. {
  7764. if (doc.Range.Bookmarks[key] != null)
  7765. {
  7766. Bookmark mark = doc.Range.Bookmarks[key];
  7767. mark.Text = DickeyValue[key];
  7768. }
  7769. }
  7770. byte[] bytes = null;
  7771. string strFileName = di.TeamName + "-客户报价.doc";
  7772. using (MemoryStream stream = new MemoryStream())
  7773. {
  7774. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7775. bytes = stream.ToArray();
  7776. }
  7777. return Ok(JsonView(true, "", new
  7778. {
  7779. Data = bytes,
  7780. strFileName,
  7781. }));
  7782. }
  7783. /// <summary>
  7784. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7785. /// </summary>
  7786. /// <param name="dto"></param>
  7787. /// <returns></returns>
  7788. [HttpPost]
  7789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7790. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7791. {
  7792. try
  7793. {
  7794. #region 参数验证
  7795. if (dto.DiId < 0)
  7796. {
  7797. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7798. }
  7799. List<int> cTableIds = new List<int>() {
  7800. 76 ,//酒店预订
  7801. 77 ,//行程
  7802. 79 ,//车/导游地接
  7803. 80 ,//签证
  7804. 81 ,//邀请/公务活
  7805. 82 ,//团组客户保险
  7806. 85 ,//机票预订
  7807. 98 ,//其他款项
  7808. 285 ,//收款退还
  7809. 751 ,//酒店早餐
  7810. 1015 // 超支费用
  7811. };
  7812. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7813. {
  7814. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7815. }
  7816. #endregion
  7817. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7818. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7819. if (_GroupCostParameters.Count <= 0)
  7820. {
  7821. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7822. }
  7823. if (_GroupCostParameters[0].IsShare == 0)
  7824. {
  7825. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7826. }
  7827. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7828. //处理date为空问题
  7829. if (_GroupCosts.Count > 0)
  7830. {
  7831. for (int i = 0; i < _GroupCosts.Count; i++)
  7832. {
  7833. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7834. {
  7835. if (i > 0)
  7836. {
  7837. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7838. }
  7839. }
  7840. }
  7841. }
  7842. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7843. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7844. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7845. string currCode = "";
  7846. #region currCode 验证
  7847. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7848. if (isInt)
  7849. {
  7850. var currData = currDatas.Find(it => it.Id == intCurrency);
  7851. if (currData != null)
  7852. {
  7853. currCode = currData.Name;
  7854. }
  7855. }
  7856. else
  7857. {
  7858. currCode = _GroupCostParameters[0].Currency.Trim();
  7859. }
  7860. #endregion
  7861. //op,酒店单段模式存储
  7862. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7863. {
  7864. CurrencyCode = currCode,
  7865. Rate = _GroupCostParameters[0].Rate,
  7866. CostType = _GroupCostParameters[0].CostType,
  7867. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7868. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7869. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7870. };
  7871. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7872. if (_GroupCostParameters.Count == 2)
  7873. {
  7874. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7875. }
  7876. foreach (var item in _GroupCostParameters)
  7877. {
  7878. decimal _rate = 1;
  7879. decimal _rate1 = item.Rate;
  7880. decimal _scale = 1;
  7881. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7882. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7883. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7884. //if (userInfo != null)
  7885. //{
  7886. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7887. // {
  7888. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7889. // {
  7890. // _scale = 1.00M;
  7891. // }
  7892. // }
  7893. //}
  7894. #endregion
  7895. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7896. {
  7897. CurrencyCode = currCode,
  7898. Rate = _rate1,
  7899. CostType = item.CostType,
  7900. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7901. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7902. CostTypeNumber = item.CostTypenumber
  7903. };
  7904. if (_GroupCostParameters.Count > 1)
  7905. {
  7906. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7907. }
  7908. else
  7909. {
  7910. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7911. }
  7912. if (dto.CTable == 79)//
  7913. {
  7914. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7915. modulePromptInfo.TotalCost = item.DJCB;
  7916. }
  7917. List<string> costTypes = new List<string>() { "A", "B" };
  7918. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7919. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7920. if (_GroupCostsDuplicates.Count() == 1)
  7921. {
  7922. _GroupCostsTypeData = _GroupCosts;
  7923. }
  7924. else
  7925. {
  7926. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7927. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7928. }
  7929. /*
  7930. * 76 酒店预订
  7931. * 77 行程
  7932. * 79 车/导游地接
  7933. * 80 签证
  7934. * 81 邀请/公务活动
  7935. * 82 团组客户保险
  7936. * 85 机票预订
  7937. * 98 其他款项
  7938. * 285 收款退还
  7939. * 751 酒店早餐
  7940. * 1015 超支费用
  7941. */
  7942. switch (dto.CTable)
  7943. {
  7944. case 76: // 酒店预订
  7945. _ModuleSubPromptInfo.AddRange(
  7946. _GroupCostsTypeData.Select(it => new
  7947. {
  7948. it.DAY,
  7949. it.Date,
  7950. it.ACCON,
  7951. it.ITIN,
  7952. it.SGR,
  7953. it.TBR,
  7954. it.JS_ES,
  7955. it.Suite
  7956. })
  7957. );
  7958. break;
  7959. case 79: // 车/导游地接
  7960. _ModuleSubPromptInfo.AddRange(
  7961. _GroupCostsTypeData.Select(it => new
  7962. {
  7963. Date = it.Date, //日期
  7964. CarFee = it.CarCost * _rate * _scale, //车费用
  7965. CarType = it.CarType, //车型
  7966. DriverFee = it.CFS * _rate * _scale, //司机工资
  7967. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  7968. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  7969. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  7970. GuideFee = it.TGS * _rate * _scale, //导游费用
  7971. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  7972. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  7973. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  7974. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  7975. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  7976. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  7977. Breakfast = it.B * _rate * _scale, //早餐费
  7978. Lunch = it.L * _rate * _scale, //午餐费
  7979. Dinner = it.D * _rate * _scale, //晚餐费
  7980. TicketFee = it.EF * _rate * _scale, //门票费
  7981. SpentCash = it.PC * _rate * _scale, //零用金
  7982. LeadersFee = it.TLF * _rate * _scale, //领队费
  7983. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  7984. TravelSupplies = it.TE * _rate * _scale, //出行物资
  7985. })
  7986. );
  7987. break;
  7988. case 85: // 机票
  7989. List<dynamic> datas = new List<dynamic>();
  7990. datas.Add(
  7991. new
  7992. {
  7993. AirType = "经济舱",
  7994. AirNum = item.JJCRS,
  7995. AirDRCB = item.JJCCB,
  7996. AirZCB = (item.JJCRS * item.JJCCB)
  7997. }
  7998. );
  7999. datas.Add(
  8000. new
  8001. {
  8002. AirType = "公务舱",
  8003. AirNum = item.GWCRS,
  8004. AirDRCB = item.GWCCB,
  8005. AirZCB = (item.GWCRS * item.GWCCB)
  8006. }
  8007. );
  8008. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8009. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8010. modulePromptInfo.Data = new
  8011. {
  8012. airFeeData = datas,
  8013. airInitData = initDatas
  8014. };
  8015. _ModulePromptInfos.Add(modulePromptInfo);
  8016. break;
  8017. default:
  8018. break;
  8019. }
  8020. }
  8021. if (dto.CTable != 85)
  8022. {
  8023. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8024. _ModulePromptInfos.Add(_ModulePromptInfo);
  8025. }
  8026. _view.ModulePromptInfos = _ModulePromptInfos;
  8027. return Ok(JsonView(true, "操作成功!", _view));
  8028. }
  8029. catch (Exception ex)
  8030. {
  8031. return Ok(JsonView(false, ex.Message));
  8032. }
  8033. }
  8034. /// <summary>
  8035. /// 根据黑屏代码重新生成行程
  8036. /// </summary>
  8037. /// <param name="dto"></param>
  8038. /// <returns></returns>
  8039. [HttpPost]
  8040. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8041. {
  8042. var jw = JsonView(false);
  8043. var Create = _GroupCostRepository.
  8044. CreateGroupCostByBlackCode(dto.Diid);
  8045. jw.Msg = Create.Msg;
  8046. if (Create.Code == 0)
  8047. {
  8048. jw.Code = 200;
  8049. jw.Data = new
  8050. {
  8051. groupCost = Create.Data,
  8052. blackCodeIsTrue = true
  8053. };
  8054. }
  8055. else
  8056. {
  8057. jw.Code = 400;
  8058. jw.Data = new
  8059. {
  8060. groupCost = Create.Data,
  8061. blackCodeIsTrue = false,
  8062. };
  8063. }
  8064. return Ok(jw);
  8065. }
  8066. /// <summary>
  8067. /// 成本获取OP历史车费用
  8068. /// </summary>
  8069. /// <param name="dto"></param>
  8070. /// <returns></returns>
  8071. [HttpPost]
  8072. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8073. {
  8074. var jw = JsonView(false);
  8075. try
  8076. {
  8077. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8078. //获取现有所有车的数据
  8079. if (!dto.Param.IsNullOrWhiteSpace())
  8080. {
  8081. string sql = $@"
  8082. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8083. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8084. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8085. 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
  8086. AND gctggr.ServiceEndTime is not NULL
  8087. ORDER by gctggrc.id DESC
  8088. ";
  8089. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8090. var numeberResult = await Task.Run(() =>
  8091. {
  8092. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8093. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8094. return numberArr;
  8095. });
  8096. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8097. foreach (var item in numeberResult)
  8098. {
  8099. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8100. {
  8101. Country = "数据异常!",
  8102. City = string.Empty,
  8103. };
  8104. item.Area = find.Country + " " + find.City;
  8105. }
  8106. dbResult.AddRange(numeberResult);
  8107. if (dto.Param.Contains("、"))
  8108. {
  8109. var sp = dto.Param.Split("、");
  8110. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8111. .Where(x =>
  8112. {
  8113. return System.Array.Exists(sp, e =>
  8114. {
  8115. bool where = false;
  8116. if (x.Area != null)
  8117. {
  8118. where = x.Area.Contains(e);
  8119. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8120. {
  8121. return false;
  8122. }
  8123. }
  8124. if (x.PriceName != null && !where)
  8125. {
  8126. where = x.PriceName.Contains(e);
  8127. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8128. {
  8129. return false;
  8130. }
  8131. }
  8132. return where;
  8133. });
  8134. }).ToList();
  8135. }
  8136. else
  8137. {
  8138. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8139. .Where(x =>
  8140. {
  8141. bool where = false;
  8142. if (x.Area != null)
  8143. {
  8144. where = x.Area.Contains(dto.Param);
  8145. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8146. {
  8147. return false;
  8148. }
  8149. }
  8150. if (x.PriceName != null && !where)
  8151. {
  8152. where = x.PriceName.Contains(dto.Param);
  8153. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8154. {
  8155. return false;
  8156. }
  8157. }
  8158. return where;
  8159. }
  8160. )
  8161. .ToList();
  8162. }
  8163. }
  8164. var view = dbResult.Select(x =>
  8165. {
  8166. decimal dp = 0.00M;
  8167. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8168. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8169. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8170. {
  8171. if (startB && endB)
  8172. {
  8173. var timesp = endD.Subtract(startD);
  8174. if ((timesp.Days + 1) != 0)
  8175. {
  8176. dp = x.Price / (timesp.Days + 1);
  8177. }
  8178. }
  8179. }
  8180. else
  8181. {
  8182. dp = x.Price;
  8183. }
  8184. return new
  8185. {
  8186. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8187. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8188. x.Area,
  8189. x.id,
  8190. price = x.Price.ToString("F2"),
  8191. x.PriceName,
  8192. x.PriceContent,
  8193. x.TeamName,
  8194. x.DatePrice,
  8195. dayPrice = dp.ToString("F2"),
  8196. };
  8197. }).OrderByDescending(x => x.id).ToList();
  8198. jw = JsonView(true, "获取成功!", view);
  8199. }
  8200. catch (Exception e)
  8201. {
  8202. jw = JsonView(false, e.Message);
  8203. }
  8204. return Ok(jw);
  8205. }
  8206. #endregion
  8207. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8208. /// <summary>
  8209. /// 酒店预订
  8210. /// 酒店费用列表 根据团组Id查询
  8211. /// </summary>
  8212. /// <param name="_dto"></param>
  8213. /// <returns></returns>
  8214. [HttpPost]
  8215. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8216. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8217. {
  8218. #region 参数验证
  8219. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8220. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8221. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8222. #region 团组操作权限验证 76 酒店预定模块
  8223. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8224. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8225. #endregion
  8226. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8227. #region 页面操作权限验证
  8228. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8229. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8230. #endregion
  8231. #endregion
  8232. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8233. }
  8234. /// <summary>
  8235. /// 酒店预订
  8236. /// 基础数据
  8237. /// </summary>
  8238. /// <param name="_dto"></param>
  8239. /// <returns></returns>
  8240. [HttpPost]
  8241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8242. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8243. {
  8244. #region 参数验证
  8245. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8246. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8247. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8248. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8249. #region 页面操作权限验证
  8250. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8251. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8252. #endregion
  8253. #region 团组操作权限验证 76 酒店预定模块
  8254. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8255. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8256. #endregion
  8257. #endregion
  8258. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8259. }
  8260. /// <summary>
  8261. /// 酒店预订
  8262. /// 创建 入住卷号码
  8263. /// </summary>
  8264. /// <param name="_dto"></param>
  8265. /// <returns></returns>
  8266. [HttpPost]
  8267. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8268. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8269. {
  8270. try
  8271. {
  8272. #region 参数验证
  8273. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8274. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8275. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8276. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8277. #region 页面操作权限验证
  8278. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8279. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8280. #endregion
  8281. #region 团组操作权限验证 76 酒店预定模块
  8282. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8283. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8284. #endregion
  8285. #endregion
  8286. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8287. if (data.Code != 0)
  8288. {
  8289. return Ok(JsonView(false, data.Msg));
  8290. }
  8291. return Ok(JsonView(true, data.Msg, data.Data));
  8292. }
  8293. catch (Exception ex)
  8294. {
  8295. return Ok(JsonView(false, ex.Message));
  8296. }
  8297. }
  8298. /// <summary>
  8299. /// 酒店预订
  8300. /// 详情
  8301. /// </summary>
  8302. /// <param name="_dto"></param>
  8303. /// <returns></returns>
  8304. [HttpPost]
  8305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8306. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8307. {
  8308. #region 参数验证
  8309. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8310. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8311. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8312. #region 团组操作权限验证 76 酒店预定模块
  8313. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8314. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8315. #endregion
  8316. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8317. #region 页面操作权限验证
  8318. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8319. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8320. #endregion
  8321. #endregion
  8322. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8323. }
  8324. /// <summary>
  8325. /// 酒店预订
  8326. /// Add Or Edit
  8327. /// </summary>
  8328. /// <param name="_dto"></param>
  8329. /// <returns></returns>
  8330. [HttpPost]
  8331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8332. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8333. {
  8334. #region 参数验证
  8335. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8336. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8337. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8338. #region 团组操作权限验证 76 酒店预定模块
  8339. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8340. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8341. #endregion
  8342. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8343. #region 页面操作权限验证
  8344. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8345. if (_dto.Id == 0) // Add
  8346. {
  8347. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8348. }
  8349. else if (_dto.Id > 1) // Edit
  8350. {
  8351. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8352. }
  8353. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8354. #endregion
  8355. #endregion
  8356. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8357. if (_view.Code != 200)
  8358. {
  8359. return Ok(_view);
  8360. }
  8361. #region 应用推送
  8362. try
  8363. {
  8364. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8365. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8366. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8367. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8368. //自动审核
  8369. await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8370. }
  8371. catch (Exception ex)
  8372. {
  8373. }
  8374. #endregion
  8375. return Ok(_view);
  8376. }
  8377. /// <summary>
  8378. /// 酒店预订
  8379. /// Del
  8380. /// </summary>
  8381. /// <param name="_dto"></param>
  8382. /// <returns></returns>
  8383. [HttpPost]
  8384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8385. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8386. {
  8387. #region 参数验证
  8388. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8389. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8390. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8391. #region 团组操作权限验证 76 酒店预定模块
  8392. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8393. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8394. #endregion
  8395. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8396. #region 页面操作权限验证
  8397. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8398. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8399. #endregion
  8400. #endregion
  8401. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8402. }
  8403. /// <summary>
  8404. /// 酒店预订
  8405. /// 生成VOUCHER
  8406. /// 2024.05.06 之前版本
  8407. /// </summary>
  8408. /// <param name="_dto"></param>
  8409. /// <returns></returns>
  8410. [HttpPost]
  8411. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8412. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8413. {
  8414. try
  8415. {
  8416. #region 参数验证
  8417. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8418. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8419. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8420. #region 团组操作权限验证 76 酒店预定模块
  8421. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8422. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8423. #endregion
  8424. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8425. #region 页面操作权限验证
  8426. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8427. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8428. #endregion
  8429. #endregion
  8430. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8431. //判断数据是否完整
  8432. if (hr != null)
  8433. {
  8434. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8435. {
  8436. string strFileName = "HotelStatement/";
  8437. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8438. if (dele != null)
  8439. strFileName += dele.TourCode;
  8440. //载入模板
  8441. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8442. Document doc = new Document(sss);
  8443. DocumentBuilder builder = new DocumentBuilder(doc);
  8444. #region 替换Word模板书签内容
  8445. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8446. //入住卷预定号码
  8447. if (doc.Range.Bookmarks["VNO"] != null)
  8448. {
  8449. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8450. mark.Text = hr.CheckNumber;
  8451. }
  8452. //酒店时间
  8453. if (doc.Range.Bookmarks["Date"] != null)
  8454. {
  8455. Bookmark mark = doc.Range.Bookmarks["Date"];
  8456. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8457. }
  8458. //团号
  8459. if (doc.Range.Bookmarks["TNo"] != null)
  8460. {
  8461. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8462. mark.Text = dele.TourCode;
  8463. }
  8464. //预定号码
  8465. if (doc.Range.Bookmarks["BookingId"] != null)
  8466. {
  8467. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8468. mark.Text = hr.ReservationsNo;
  8469. }
  8470. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8471. {
  8472. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8473. mark.Text = hr.DetermineNo;
  8474. }
  8475. //酒店城市
  8476. if (doc.Range.Bookmarks["City"] != null)
  8477. {
  8478. Bookmark mark = doc.Range.Bookmarks["City"];
  8479. mark.Text = hr.City;
  8480. }
  8481. //酒店名称
  8482. if (doc.Range.Bookmarks["HName"] != null)
  8483. {
  8484. Bookmark mark = doc.Range.Bookmarks["HName"];
  8485. mark.Text = hr.HotelName;
  8486. }
  8487. //酒店地址
  8488. if (doc.Range.Bookmarks["Address"] != null)
  8489. {
  8490. Bookmark mark = doc.Range.Bookmarks["Address"];
  8491. mark.Text = hr.HotelAddress;
  8492. }
  8493. //酒店电话
  8494. if (doc.Range.Bookmarks["Tel"] != null)
  8495. {
  8496. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8497. mark.Text = hr.HotelTel;
  8498. }
  8499. //酒店传真
  8500. if (doc.Range.Bookmarks["Fax"] != null)
  8501. {
  8502. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8503. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8504. {
  8505. mark.Text = hr.HotelFax;
  8506. }
  8507. }
  8508. //入住时间
  8509. if (doc.Range.Bookmarks["CIn"] != null)
  8510. {
  8511. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8512. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8513. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8514. }
  8515. //退房时间
  8516. if (doc.Range.Bookmarks["COut"] != null)
  8517. {
  8518. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8519. Bookmark mark = doc.Range.Bookmarks["COut"];
  8520. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8521. }
  8522. //客户名称
  8523. if (doc.Range.Bookmarks["GName"] != null)
  8524. {
  8525. string guestName = "";
  8526. string[] clients = new string[] { };
  8527. if (hr.GuestName.Contains(","))
  8528. {
  8529. clients = hr.GuestName.Split(",");
  8530. }
  8531. else
  8532. {
  8533. clients = new string[] { hr.GuestName };
  8534. }
  8535. List<int> clientIds_int = new List<int>();
  8536. if (clients.Length > 0)
  8537. {
  8538. foreach (var item in clients)
  8539. {
  8540. if (item.IsNumeric())
  8541. {
  8542. clientIds_int.Add(int.Parse(item));
  8543. }
  8544. }
  8545. }
  8546. if (clientIds_int.Count > 0)
  8547. {
  8548. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8549. foreach (var client in _clientDatas)
  8550. {
  8551. //男
  8552. if (client.Sex == 0) guestName += $"Mr.";
  8553. //女
  8554. else if (client.Sex == 1) guestName += $"Ms.";
  8555. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8556. {
  8557. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8558. }
  8559. //guestName += $"{client.Pinyin},";
  8560. }
  8561. if (guestName.Length > 0)
  8562. {
  8563. guestName = guestName.Substring(0, guestName.Length - 1);
  8564. }
  8565. }
  8566. else
  8567. {
  8568. guestName = hr.GuestName;
  8569. }
  8570. Bookmark mark = doc.Range.Bookmarks["GName"];
  8571. mark.Text = guestName;
  8572. }
  8573. //房间介绍
  8574. if (doc.Range.Bookmarks["ROOM"] != null)
  8575. {
  8576. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8577. mark.Text = hr.RoomExplanation;
  8578. }
  8579. //报价描述
  8580. if (doc.Range.Bookmarks["NOTE"] != null)
  8581. {
  8582. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8583. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8584. if (ss != null)
  8585. mark.Text = ss.Name;
  8586. }
  8587. //入住时间
  8588. if (doc.Range.Bookmarks["CheckIn"] != null)
  8589. {
  8590. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8591. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8592. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8593. }
  8594. //退房时间
  8595. if (doc.Range.Bookmarks["CheckOut"] != null)
  8596. {
  8597. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8598. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8599. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8600. }
  8601. //日期
  8602. if (doc.Range.Bookmarks["DT"] != null)
  8603. {
  8604. Bookmark mark = doc.Range.Bookmarks["DT"];
  8605. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8606. }
  8607. //名称
  8608. if (doc.Range.Bookmarks["VName"] != null)
  8609. {
  8610. Bookmark mark = doc.Range.Bookmarks["VName"];
  8611. mark.Text = hr.HotelName;
  8612. }
  8613. //号码
  8614. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8615. {
  8616. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8617. mark.Text = hr.CheckNumber;
  8618. }
  8619. #endregion
  8620. strFileName += "VOUCHER.doc";
  8621. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8622. doc.Save(fileDir);
  8623. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8624. return Ok(JsonView(true, "操作成功!", Url));
  8625. }
  8626. else
  8627. {
  8628. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8629. }
  8630. }
  8631. else
  8632. {
  8633. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8634. }
  8635. }
  8636. catch (Exception ex)
  8637. {
  8638. return Ok(JsonView(false, ex.Message));
  8639. }
  8640. }
  8641. /// <summary>
  8642. /// 酒店预订
  8643. /// 生成VOUCHER
  8644. /// 2024.05.06 之后版本
  8645. /// </summary>
  8646. /// <param name="_dto"></param>
  8647. /// <returns></returns>
  8648. [HttpPost]
  8649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8650. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8651. {
  8652. #region 参数验证
  8653. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8654. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8655. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8656. #region 团组操作权限验证 76 酒店预定模块
  8657. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8658. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8659. #endregion
  8660. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8661. #region 页面操作权限验证
  8662. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8663. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8664. #endregion
  8665. #endregion
  8666. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8667. //判断数据是否完整
  8668. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8669. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8670. string strFileName = "HotelStatement/";
  8671. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8672. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8673. #region 数据处理
  8674. List<int> guestIds = new List<int>();
  8675. int index = 0;
  8676. foreach (var item in hrDtas)
  8677. {
  8678. if (item.GuestName.Contains(","))
  8679. {
  8680. string[] guestIdArr = item.GuestName.Split(',');
  8681. foreach (var guestIdStr in guestIdArr)
  8682. {
  8683. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8684. if (guestBool)
  8685. {
  8686. guestIds.Add(guestId);
  8687. }
  8688. }
  8689. }
  8690. else guestNames += item.GuestName;
  8691. var voucherInfo = new HotelVoucherInfoView()
  8692. {
  8693. HotelName = item.HotelName,
  8694. CheckInDate = item.CheckInDate,
  8695. CheckOutDate = item.CheckOutDate,
  8696. ConfirmationNumber = item.DetermineNo.Trim(),
  8697. RoomType = item.RoomExplanation
  8698. };
  8699. vouchers.Add(voucherInfo);
  8700. }
  8701. if (guestIds.Count > 0)
  8702. {
  8703. guestIds = guestIds.Distinct().ToList();
  8704. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8705. if (guestDatas.Count > 0)
  8706. {
  8707. guestNames = "";
  8708. foreach (var guest in guestDatas)
  8709. {
  8710. string guestName = "";
  8711. if (guest.Sex == 0) guestName += @"MR.";
  8712. else if (guest.Sex == 1) guestName += @"MS.";
  8713. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8714. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8715. guestNames += @$"{guestName.Trim()}、";
  8716. }
  8717. if (guestNames.Length > 0)
  8718. {
  8719. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8720. }
  8721. }
  8722. }
  8723. #endregion
  8724. //载入模板
  8725. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8726. Document doc = new Document(sss);
  8727. DocumentBuilder builder = new DocumentBuilder(doc);
  8728. if (doc.Range.Bookmarks["GuestName"] != null)
  8729. {
  8730. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8731. mark.Text = guestNames;
  8732. }
  8733. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8734. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8735. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8736. for (int i = 1; i <= vouchers.Count; i++)
  8737. {
  8738. HotelVoucherInfoView hviv = vouchers[i - 1];
  8739. builder.MoveToCell(0, i, 0, 0);
  8740. builder.Write(hviv.HotelName);
  8741. builder.MoveToCell(0, i, 1, 0);
  8742. builder.Write(hviv.CheckInDate);
  8743. builder.MoveToCell(0, i, 2, 0);
  8744. builder.Write(hviv.CheckOutDate);
  8745. builder.MoveToCell(0, i, 3, 0);
  8746. builder.Write(hviv.RoomType);
  8747. builder.MoveToCell(0, i, 4, 0);
  8748. builder.Write(hviv.ConfirmationNumber);
  8749. }
  8750. //删除多余行
  8751. int currRowIndex = vouchers.Count + 1;
  8752. int delRows = 21 - currRowIndex;
  8753. if (delRows > 0)
  8754. {
  8755. for (int i = 0; i < delRows; i++)
  8756. {
  8757. table.Rows.RemoveAt(currRowIndex);
  8758. //cultivateRowIndex++;
  8759. }
  8760. }
  8761. strFileName += "VOUCHER.docx";
  8762. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8763. doc.Save(fileDir);
  8764. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8765. return Ok(JsonView(true, "操作成功!", Url));
  8766. }
  8767. /// <summary>
  8768. /// 酒店预订
  8769. /// 生成 预定成本 Excel
  8770. /// </summary>
  8771. /// <param name="_dto"></param>
  8772. /// <returns></returns>
  8773. [HttpPost]
  8774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8775. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8776. {
  8777. #region 参数验证
  8778. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8779. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8780. if (!vadalitorRes.IsValid)
  8781. {
  8782. var errors = new StringBuilder();
  8783. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8784. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8785. }
  8786. #region 团组操作权限验证 76 酒店预定模块
  8787. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8788. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8789. #endregion
  8790. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8791. #region 页面操作权限验证
  8792. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8793. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8794. #endregion
  8795. #endregion
  8796. decimal _rate = 1.00M;
  8797. string _currency = "";
  8798. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8799. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8800. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8801. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8802. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8803. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8804. {
  8805. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8806. }
  8807. _currency = _GroupCostParameter.Currency;
  8808. bool isIntType = int.TryParse(_currency, out int currId);
  8809. if (isIntType)
  8810. {
  8811. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8812. }
  8813. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8814. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8815. if (currInfo == null)
  8816. {
  8817. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8818. }
  8819. if (!_currency.ToUpper().Equals("CNY"))
  8820. {
  8821. _rate = _GroupCostParameter.Rate;
  8822. }
  8823. _rate = currInfo.Rate;
  8824. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8825. string strFileName = "HotelStatement/";
  8826. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8827. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8828. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8829. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8830. #region 数据处理
  8831. foreach (var item in hrDtas)
  8832. {
  8833. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8834. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8835. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8836. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8837. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8838. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8839. string singleRoomFeeStr = string.Empty,
  8840. doubleRoomFeeStr = string.Empty,
  8841. suiteRoomFeeStr = string.Empty,
  8842. otherRoomFeeStr = string.Empty,
  8843. payMoneyStr = string.Empty,
  8844. cardPriceStr = string.Empty;
  8845. if (roomCurr.Equals(_currency))
  8846. {
  8847. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8848. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8849. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8850. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8851. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8852. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8853. }
  8854. else
  8855. {
  8856. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8857. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8858. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8859. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8860. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8861. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8862. }
  8863. string breakfastPriceStr = string.Empty,
  8864. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8865. governmentRentStr = string.Empty,
  8866. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8867. cityTaxStrStr = string.Empty,
  8868. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8869. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8870. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8871. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8872. pcfds.Add(new HotelReservations_PCFD_View()
  8873. {
  8874. City = item.City,
  8875. HotelName = item.HotelName,
  8876. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8877. // SingleRoomCount = item.SingleRoomCount,
  8878. SingleRoomPrice = singleRoomFeeStr,
  8879. // DoubleRoomCount = item.DoubleRoomCount,
  8880. DoubleRoomPrice = doubleRoomFeeStr,
  8881. //SuiteRoomCount = item.SuiteRoomCount,
  8882. SuiteRoomPrice = suiteRoomFeeStr,
  8883. OtherRoomPrice = otherRoomFeeStr,
  8884. //OtherRoomCount = item.OtherRoomCount,
  8885. BreakfastPrice = breakfastPriceStr,
  8886. GovernmentRent = governmentRentStr,
  8887. CityTax = cityTaxStrStr,
  8888. RoomExplanation = item.RoomExplanation,
  8889. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8890. PayTime = roomInfo.ConsumptionDate,
  8891. BankNo = roomInfo.BankNo,
  8892. PayMoney = payMoneyStr,
  8893. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8894. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8895. CardPrice = cardPriceStr,
  8896. Remark = ccpInfo.Remark
  8897. });
  8898. }
  8899. #endregion
  8900. //载入模板
  8901. WorkbookDesigner designer = new WorkbookDesigner();
  8902. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8903. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8904. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8905. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8906. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8907. designer.SetDataSource("Opertor", userInfo.CnName);
  8908. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8909. dt.TableName = "ViewMyHotelReservations";
  8910. designer.SetDataSource(dt);
  8911. designer.Process();
  8912. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8913. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8914. designer.Workbook.Save(serverPath);
  8915. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8916. #region 删除指定行
  8917. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8918. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8919. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8920. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8921. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8922. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8923. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8924. cssIndex = dt.Columns["CityTax"].Ordinal,
  8925. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8926. remarkIndex = dt.Columns["Remark"].Ordinal;
  8927. //删除指定列
  8928. foreach (DataRow item in dt.Rows)
  8929. {
  8930. string singleStr = item["SingleRoomPrice"].ToString();
  8931. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8932. if (containsDigitButNotZero1) singleDel = false;
  8933. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8934. string doubleStr = item["DoubleRoomPrice"].ToString();
  8935. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8936. if (containsDigitButNotZero2) doubleDel = false;
  8937. string suiteStr = item["SuiteRoomPrice"].ToString();
  8938. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8939. if (containsDigitButNotZero3) suiteDel = false;
  8940. string otherStr = item["OtherRoomPrice"].ToString();
  8941. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8942. if (containsDigitButNotZero4) otherDel = false;
  8943. string zcStr = item["BreakfastPrice"].ToString();
  8944. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8945. if (containsDigitButNotZero5) zcDel = false;
  8946. string dsStr = item["GovernmentRent"].ToString();
  8947. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8948. if (containsDigitButNotZero6) dsDel = false;
  8949. string cssStr = item["CityTax"].ToString();
  8950. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8951. if (containsDigitButNotZero7) cssDel = false;
  8952. string cpStr = item["ConsumptionPatterns"].ToString();
  8953. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8954. string remarkStr = item["Remark"].ToString();
  8955. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8956. }
  8957. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8958. DeleteColumn(serverPath, cpIndex, cpDel);
  8959. DeleteColumn(serverPath, dsIndex, dsDel);
  8960. DeleteColumn(serverPath, cssIndex, cssDel);
  8961. DeleteColumn(serverPath, zcIndex, zcDel);
  8962. DeleteColumn(serverPath, otherIndex, otherDel);
  8963. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8964. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8965. DeleteColumn(serverPath, singleIndex, singleDel);
  8966. #endregion
  8967. //只保留第一个表格
  8968. DeleteSheet(serverPath);
  8969. return Ok(JsonView(true, "操作成功", url = rst));
  8970. }
  8971. /// <summary>
  8972. /// 删除指定列
  8973. /// </summary>
  8974. /// <param name="file"></param>
  8975. /// <param name="columnIndex"></param>
  8976. /// <param name="isDel"></param>
  8977. private void DeleteColumn(string file, int columnIndex, bool isDel)
  8978. {
  8979. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8980. //wb.Save(file);
  8981. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  8982. if (sheet1 != null)
  8983. {
  8984. if (isDel)
  8985. {
  8986. Cells cells = sheet1.Cells;
  8987. cells.DeleteColumn(columnIndex);
  8988. }
  8989. }
  8990. wb.Save(file);
  8991. }
  8992. /// <summary>
  8993. /// 删除sheet
  8994. /// </summary>
  8995. /// <param name="file"></param>
  8996. /// <param name="sheetName"></param>
  8997. private void DeleteSheet(string file, string sheetName = "")
  8998. {
  8999. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9000. //wb.Save(file);
  9001. List<string> sheets = new List<string>();
  9002. foreach (var item in wb.Worksheets)
  9003. {
  9004. sheets.Add(item.Name);
  9005. }
  9006. if (sheets.Count > 0)
  9007. {
  9008. sheets.RemoveAt(0);//不删除第一个sheet
  9009. foreach (var item in sheets)
  9010. {
  9011. wb.Worksheets.RemoveAt(item);
  9012. }
  9013. }
  9014. wb.Save(file);
  9015. }
  9016. /// <summary>
  9017. /// 酒店预订
  9018. /// 确认单
  9019. /// </summary>
  9020. /// <param name="_dto"></param>
  9021. /// <returns></returns>
  9022. [HttpPost]
  9023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9024. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9025. {
  9026. try
  9027. {
  9028. #region 参数验证
  9029. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9030. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9031. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9032. #region 团组操作权限验证 76 酒店预定模块
  9033. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9034. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9035. #endregion
  9036. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9037. #region 页面操作权限验证
  9038. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9039. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9040. #endregion
  9041. #endregion
  9042. //团组信息
  9043. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9044. //酒店数据
  9045. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9046. if (listhoteldata.Count < 0)
  9047. {
  9048. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9049. }
  9050. //利datatable存储
  9051. DataTable dt = new DataTable();
  9052. dt.Columns.Add("CheckInDate", typeof(string));
  9053. dt.Columns.Add("City", typeof(string));
  9054. dt.Columns.Add("Hotel", typeof(string));
  9055. dt.Columns.Add("Room", typeof(string));
  9056. for (int i = 0; i < listhoteldata.Count; i++)
  9057. {
  9058. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9059. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9060. while (dayStart < dayEnd)
  9061. {
  9062. string temp = "";
  9063. DataRow row = dt.NewRow();
  9064. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9065. row["City"] = listhoteldata[i].City;
  9066. row["Hotel"] = listhoteldata[i].HotelName;
  9067. if (listhoteldata[i].SingleRoomCount > 0)
  9068. {
  9069. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9070. }
  9071. if (listhoteldata[i].DoubleRoomCount > 0)
  9072. {
  9073. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9074. }
  9075. if (listhoteldata[i].SuiteRoomCount > 0)
  9076. {
  9077. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9078. }
  9079. if (listhoteldata[i].OtherRoomCount > 0)
  9080. {
  9081. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9082. }
  9083. row["Room"] = temp;
  9084. dt.Rows.Add(row);
  9085. dayStart = dayStart.AddDays(1);
  9086. }
  9087. }
  9088. Dictionary<string, string> dic = new Dictionary<string, string>();
  9089. dic.Add("Dele", di.TeamName);
  9090. dic.Add("City", di.VisitCountry);
  9091. //模板路径
  9092. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9093. //载入模板
  9094. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9095. DocumentBuilder builder = new DocumentBuilder(doc);
  9096. foreach (var key in dic.Keys)
  9097. {
  9098. builder.MoveToBookmark(key);
  9099. builder.Write(dic[key]);
  9100. }
  9101. //获取word里所有表格
  9102. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9103. //获取所填表格的序数
  9104. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9105. var rowStart = tableOne.Rows[0]; //获取第1行
  9106. //循环赋值
  9107. for (int i = 0; i < dt.Rows.Count; i++)
  9108. {
  9109. builder.MoveToCell(0, i + 1, 0, 0);
  9110. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9111. builder.MoveToCell(0, i + 1, 1, 0);
  9112. builder.Write(dt.Rows[i]["City"].ToString());
  9113. builder.MoveToCell(0, i + 1, 2, 0);
  9114. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9115. builder.MoveToCell(0, i + 1, 3, 0);
  9116. builder.Write(dt.Rows[i]["Room"].ToString());
  9117. }
  9118. //删除多余行
  9119. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9120. {
  9121. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9122. }
  9123. string strFileName = di.TeamName + "酒店确认单.doc";
  9124. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9125. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9126. return Ok(JsonView(true, "成功", url));
  9127. }
  9128. catch (Exception ex)
  9129. {
  9130. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9131. }
  9132. }
  9133. #endregion
  9134. #region 团组状态
  9135. /// <summary>
  9136. /// 团组状态列表 Page
  9137. /// </summary>
  9138. /// <param name="dto">团组列表请求dto</param>
  9139. /// <returns></returns>
  9140. [HttpPost]
  9141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9142. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9143. {
  9144. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9145. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9146. {
  9147. string sqlWhere = string.Empty;
  9148. if (dto.IsSure == 0) //未完成
  9149. {
  9150. sqlWhere += string.Format(@" And IsSure = 0");
  9151. }
  9152. else if (dto.IsSure == 1) //已完成
  9153. {
  9154. sqlWhere += string.Format(@" And IsSure = 1");
  9155. }
  9156. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9157. {
  9158. string tj = dto.SearchCriteria;
  9159. 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}%')",
  9160. tj, tj, tj, tj, tj);
  9161. }
  9162. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9163. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9164. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9165. From (
  9166. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9167. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9168. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9169. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9170. From Grp_DelegationInfo gdi
  9171. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9172. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9173. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9174. Where gdi.IsDel = 0 {0}
  9175. ) temp ", sqlWhere);
  9176. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9177. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9178. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9179. }
  9180. else
  9181. {
  9182. return Ok(JsonView(false, "查询失败"));
  9183. }
  9184. }
  9185. /// <summary>
  9186. /// 团组状态
  9187. /// 设置操作完成
  9188. /// </summary>
  9189. /// <param name="dto">团组列表请求dto</param>
  9190. /// <returns></returns>
  9191. [HttpPost]
  9192. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9193. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9194. {
  9195. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9196. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9197. {
  9198. Id = dto.Id,
  9199. IsSure = 1
  9200. };
  9201. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9202. .UpdateColumns(it => new { it.IsSure })
  9203. .WhereColumns(it => new { it.Id })
  9204. .ExecuteCommandAsync();
  9205. if (result > 0)
  9206. {
  9207. return Ok(JsonView(true, "操作完成!"));
  9208. }
  9209. return Ok(JsonView(false, "操作失败!"));
  9210. }
  9211. #endregion
  9212. #region 保险费用录入
  9213. /// <summary>
  9214. /// 根据团组Id查询保险费用列表
  9215. /// </summary>
  9216. /// <param name="dto"></param>
  9217. /// <returns></returns>
  9218. [HttpPost]
  9219. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9220. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9221. {
  9222. try
  9223. {
  9224. Result groupData = await _customersRep.CustomersByDiId(dto);
  9225. if (groupData.Code != 0)
  9226. {
  9227. return Ok(JsonView(false, groupData.Msg));
  9228. }
  9229. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9230. }
  9231. catch (Exception ex)
  9232. {
  9233. return Ok(JsonView(false, ex.Message));
  9234. }
  9235. }
  9236. /// <summary>
  9237. /// 根据保险费用Id查询保险费用详细
  9238. /// </summary>
  9239. /// <param name="dto"></param>
  9240. /// <returns></returns>
  9241. [HttpPost]
  9242. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9243. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9244. {
  9245. try
  9246. {
  9247. Result groupData = await _customersRep.CustomersById(dto);
  9248. if (groupData.Code != 0)
  9249. {
  9250. return Ok(JsonView(false, groupData.Msg));
  9251. }
  9252. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9253. }
  9254. catch (Exception ex)
  9255. {
  9256. return Ok(JsonView(false, ex.Message));
  9257. }
  9258. }
  9259. /// <summary>
  9260. /// 保险费用录入页面初始化绑定
  9261. /// </summary>
  9262. /// <param name="dto"></param>
  9263. /// <returns></returns>
  9264. [HttpPost]
  9265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9266. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9267. {
  9268. try
  9269. {
  9270. Result groupData = await _customersRep.CustomersInitialize(dto);
  9271. if (groupData.Code != 0)
  9272. {
  9273. return Ok(JsonView(false, groupData.Msg));
  9274. }
  9275. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9276. }
  9277. catch (Exception ex)
  9278. {
  9279. return Ok(JsonView(false, ex.Message));
  9280. }
  9281. }
  9282. /// <summary>
  9283. /// 保险费用操作(Status:1.新增,2.修改)
  9284. /// </summary>
  9285. /// <param name="dto"></param>
  9286. /// <returns></returns>
  9287. [HttpPost]
  9288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9289. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9290. {
  9291. try
  9292. {
  9293. Result groupData = await _customersRep.OpCustomers(dto);
  9294. if (groupData.Code != 0)
  9295. {
  9296. return Ok(JsonView(false, groupData.Msg));
  9297. }
  9298. #region 应用推送
  9299. try
  9300. {
  9301. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9302. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9303. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9304. }
  9305. catch (Exception ex)
  9306. {
  9307. }
  9308. #endregion
  9309. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9310. }
  9311. catch (Exception ex)
  9312. {
  9313. return Ok(JsonView(false, ex.Message));
  9314. }
  9315. }
  9316. /// <summary>
  9317. /// 保险文件上传
  9318. /// </summary>
  9319. /// <param name="file"></param>
  9320. /// <returns></returns>
  9321. [HttpPost]
  9322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9323. public async Task<IActionResult> UploadCus(IFormFile file)
  9324. {
  9325. try
  9326. {
  9327. if (file != null)
  9328. {
  9329. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9330. //文件名称
  9331. string projectFileName = file.FileName;
  9332. //上传的文件的路径
  9333. string filePath = "";
  9334. if (!Directory.Exists(fileDir))
  9335. {
  9336. Directory.CreateDirectory(fileDir);
  9337. }
  9338. //上传的文件的路径
  9339. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9340. using (FileStream fs = System.IO.File.Create(filePath))
  9341. {
  9342. file.CopyTo(fs);
  9343. fs.Flush();
  9344. }
  9345. return Ok(JsonView(true, "上传成功!", projectFileName));
  9346. }
  9347. else
  9348. {
  9349. return Ok(JsonView(false, "上传失败!"));
  9350. }
  9351. }
  9352. catch (Exception ex)
  9353. {
  9354. return Ok(JsonView(false, "程序错误!"));
  9355. throw;
  9356. }
  9357. }
  9358. /// <summary>
  9359. /// 保险删除指定文件
  9360. /// </summary>
  9361. /// <param name="dto"></param>
  9362. /// <returns></returns>
  9363. [HttpPost]
  9364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9365. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9366. {
  9367. try
  9368. {
  9369. string filePath = "";
  9370. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9371. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9372. //int id = 0;
  9373. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9374. // 删除该文件
  9375. try
  9376. {
  9377. System.IO.File.Delete(filePath);
  9378. 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()
  9379. {
  9380. Attachment = "",
  9381. }).ExecuteCommandAsync();
  9382. if (result != 0)
  9383. {
  9384. return Ok(JsonView(true, "成功!"));
  9385. }
  9386. else
  9387. {
  9388. return Ok(JsonView(false, "失败!"));
  9389. }
  9390. }
  9391. catch (Exception)
  9392. {
  9393. 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()
  9394. {
  9395. Attachment = "",
  9396. }).ExecuteCommandAsync();
  9397. if (result != 0)
  9398. {
  9399. return Ok(JsonView(true, "成功!"));
  9400. }
  9401. else
  9402. {
  9403. return Ok(JsonView(false, "失败!"));
  9404. }
  9405. }
  9406. }
  9407. catch (Exception ex)
  9408. {
  9409. return Ok(JsonView(false, "程序错误!"));
  9410. throw;
  9411. }
  9412. }
  9413. /// <summary>
  9414. /// 保险费用操作(删除)
  9415. /// </summary>
  9416. /// <param name="dto"></param>
  9417. /// <returns></returns>
  9418. [HttpPost]
  9419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9420. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9421. {
  9422. try
  9423. {
  9424. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9425. if (!res)
  9426. {
  9427. return Ok(JsonView(false, "删除失败"));
  9428. }
  9429. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9430. {
  9431. IsDel = 1,
  9432. DeleteUserId = dto.DeleteUserId,
  9433. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9434. }).ExecuteCommandAsync();
  9435. return Ok(JsonView(true, "删除成功!"));
  9436. }
  9437. catch (Exception ex)
  9438. {
  9439. return Ok(JsonView(false, "程序错误!"));
  9440. throw;
  9441. }
  9442. }
  9443. #endregion
  9444. #region 接团客户名单 PageId 104
  9445. /// <summary>
  9446. /// 接团客户名单
  9447. /// 迁移数据(慎用!)
  9448. /// </summary>
  9449. /// <param name="dto"></param>
  9450. /// <returns></returns>
  9451. [HttpPost]
  9452. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9453. public async Task<IActionResult> PostTourClientListChange()
  9454. {
  9455. try
  9456. {
  9457. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9458. //var groupClinetData1
  9459. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9460. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9461. int updateCount = 0;
  9462. if (oldOAClientList.Count > 0)
  9463. {
  9464. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9465. _sqlSugar.BeginTran();
  9466. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9467. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9468. foreach (var item in oldOAClientList)
  9469. {
  9470. int comId = 0;
  9471. string format = "yyyy-MM-dd HH:mm:ss";
  9472. string data11 = "1990-01-01 00:00";
  9473. var data1 = IsValidDate(item.OPdate, format);
  9474. if (data1) data11 = item.OPdate;
  9475. //客户公司验证
  9476. if (!string.IsNullOrEmpty(item.Company))
  9477. {
  9478. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9479. if (clientComInfo == null) // add
  9480. {
  9481. var addInfo = new Crm_CustomerCompany()
  9482. {
  9483. CompanyAbbreviation = "",
  9484. CompanyFullName = item.Company,
  9485. Address = "",
  9486. PostCodes = "",
  9487. LastedOpUserId = item.OPer,
  9488. LastedOpDt = Convert.ToDateTime(data11),
  9489. CreateUserId = item.OPer,
  9490. CreateTime = Convert.ToDateTime(data11),
  9491. IsDel = 0
  9492. };
  9493. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9494. if (comId1 > 0) comId = comId1;
  9495. }
  9496. else comId = clientComInfo.Id;
  9497. }
  9498. //客户人员验证
  9499. int clientId = 0;
  9500. string name = item.LastName + item.Name;
  9501. if (!string.IsNullOrEmpty(name))
  9502. {
  9503. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9504. if (clientInfo == null)
  9505. {
  9506. DateTime? dateTime = null;
  9507. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9508. if (isDt) dateTime = birthDayDt;
  9509. var addInfo1 = new Crm_DeleClient()
  9510. {
  9511. CrmCompanyId = comId,
  9512. DiId = -1,
  9513. LastName = item.LastName,
  9514. FirstName = item.Name,
  9515. OldName = "",
  9516. Pinyin = item.Pinyin,
  9517. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9518. Marriage = 0,
  9519. Phone = item.Phone,
  9520. Job = item.Job,
  9521. BirthDay = dateTime
  9522. };
  9523. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9524. if (clientId1 > 0) clientId = clientId1;
  9525. }
  9526. else clientId = clientInfo.Id;
  9527. }
  9528. if (clientId < 1)
  9529. {
  9530. continue;
  9531. }
  9532. int airType = 0;
  9533. if (item.AirType == "超经舱") airType = 459;
  9534. else if (item.AirType == "公务舱") airType = 458;
  9535. else if (item.AirType == "经济舱") airType = 460;
  9536. else if (item.AirType == "其他") airType = 565;
  9537. else if (item.AirType == "头等舱") airType = 457;
  9538. var _TourClientListEntity = new Grp_TourClientList()
  9539. {
  9540. DiId = item.Diid,
  9541. ClientId = clientId,
  9542. CreateUserId = item.OPer,
  9543. CreateTime = Convert.ToDateTime(data11),
  9544. Remark = item.Remark,
  9545. IsDel = item.Isdel,
  9546. ShippingSpaceTypeId = airType,
  9547. ShippingSpaceSpecialNeeds = item.AirRemark,
  9548. HotelSpecialNeeds = item.RoomType
  9549. };
  9550. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9551. if (_TourClientList > 0)
  9552. {
  9553. updateCount++;
  9554. }
  9555. }
  9556. _sqlSugar.CommitTran();
  9557. }
  9558. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9559. }
  9560. catch (Exception ex)
  9561. {
  9562. _sqlSugar.RollbackTran();
  9563. return Ok(JsonView(false, ex.Message));
  9564. }
  9565. return Ok(JsonView(true));
  9566. }
  9567. private bool IsValidDate(string dateString, string format)
  9568. {
  9569. DateTime dateValue;
  9570. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9571. return valid;
  9572. }
  9573. /// <summary>
  9574. /// 接团客户名单
  9575. /// 根据团组Id查询List
  9576. /// </summary>
  9577. /// <param name="dto"></param>
  9578. /// <returns></returns>
  9579. [HttpPost]
  9580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9581. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9582. {
  9583. #region 参数验证
  9584. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9585. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9586. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9587. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9588. #region 页面操作权限验证
  9589. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9590. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9591. #endregion
  9592. #endregion
  9593. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9594. if (viewData.Code != 0)
  9595. {
  9596. return Ok(JsonView(false, viewData.Msg));
  9597. }
  9598. return Ok(JsonView(viewData.Data));
  9599. }
  9600. /// <summary>
  9601. /// 接团客户名单
  9602. /// 基础数据 Init
  9603. /// </summary>
  9604. /// <param name="_dto"></param>
  9605. /// <returns></returns>
  9606. [HttpPost]
  9607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9608. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9609. {
  9610. #region 参数验证
  9611. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9612. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9613. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9614. #region 页面操作权限验证
  9615. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9616. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9617. #endregion
  9618. #endregion
  9619. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9620. if (viewData.Code != 0)
  9621. {
  9622. return Ok(JsonView(false, viewData.Msg));
  9623. }
  9624. return Ok(JsonView(viewData.Data));
  9625. }
  9626. /// <summary>
  9627. /// 接团客户名单
  9628. /// 根据 Id查询 Details
  9629. /// </summary>
  9630. /// <param name="_dto"></param>
  9631. /// <returns></returns>
  9632. [HttpPost]
  9633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9634. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9635. {
  9636. #region 参数验证
  9637. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9638. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9639. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9640. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9641. #region 页面操作权限验证
  9642. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9643. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9644. #endregion
  9645. #endregion
  9646. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9647. if (viewData.Code != 0)
  9648. {
  9649. return Ok(JsonView(false, viewData.Msg));
  9650. }
  9651. return Ok(JsonView(viewData.Data));
  9652. }
  9653. /// <summary>
  9654. /// 接团客户名单
  9655. /// Add Or Edit
  9656. /// </summary>
  9657. /// <param name="_dto"></param>
  9658. /// <returns></returns>
  9659. [HttpPost]
  9660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9661. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9662. {
  9663. #region 参数验证
  9664. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9665. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9666. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9667. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9668. #region 页面操作权限验证
  9669. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9670. if (_dto.Id == 0) //添加
  9671. {
  9672. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9673. }
  9674. else if (_dto.Id >= 0) //修改
  9675. {
  9676. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9677. }
  9678. #endregion
  9679. #endregion
  9680. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9681. if (viewData.Code != 0)
  9682. {
  9683. return Ok(JsonView(false, viewData.Msg));
  9684. }
  9685. return Ok(JsonView(true));
  9686. }
  9687. /// <summary>
  9688. /// 接团客户名单
  9689. /// AddMultiple(添加多个)
  9690. /// </summary>
  9691. /// <param name="_dto"></param>
  9692. /// <returns></returns>
  9693. [HttpPost]
  9694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9695. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9696. {
  9697. #region 参数验证
  9698. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9699. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9700. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9701. #region 页面操作权限验证
  9702. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9703. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9704. #endregion
  9705. #endregion
  9706. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9707. if (viewData.Code != 0)
  9708. {
  9709. return Ok(JsonView(false, viewData.Msg));
  9710. }
  9711. return Ok(JsonView(true));
  9712. }
  9713. /// <summary>
  9714. /// 接团客户名单
  9715. /// Del
  9716. /// </summary>
  9717. /// <param name="_dto"></param>
  9718. /// <returns></returns>
  9719. [HttpPost]
  9720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9721. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9722. {
  9723. #region 参数验证
  9724. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9725. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9726. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9727. #region 页面操作权限验证
  9728. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9729. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9730. #endregion
  9731. #endregion
  9732. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9733. if (viewData.Code != 0)
  9734. {
  9735. return Ok(JsonView(false, viewData.Msg));
  9736. }
  9737. return Ok(JsonView(true));
  9738. }
  9739. /// <summary>
  9740. /// 接团客户名单
  9741. /// 文件下载 客户名单
  9742. /// </summary>
  9743. /// <param name="_dto"></param>
  9744. /// <returns></returns>
  9745. [HttpPost]
  9746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9747. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9748. {
  9749. #region 参数验证
  9750. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9751. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9752. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9753. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9754. #region 页面操作权限验证
  9755. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9756. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9757. #endregion
  9758. #endregion
  9759. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9760. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9761. From Grp_TourClientList tcl
  9762. Left Join
  9763. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9764. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9765. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9766. From Crm_DeleClient dc
  9767. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9768. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9769. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9770. Where dc.IsDel = 0) temp
  9771. On temp.DcId =tcl.ClientId
  9772. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9773. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9774. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9775. //载入模板
  9776. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9777. if (_dto.Language == 1)
  9778. {
  9779. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9780. }
  9781. //载入模板
  9782. var doc = new Document(tempPath);
  9783. DocumentBuilder builder = new DocumentBuilder(doc);
  9784. //获取word里所有表格
  9785. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9786. //获取所填表格的序数
  9787. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9788. var rowStart = tableOne.Rows[0]; //获取第1行
  9789. if (_dto.Language == 0)
  9790. {
  9791. //循环赋值
  9792. for (int i = 0; i < DcList.Count; i++)
  9793. {
  9794. builder.MoveToCell(0, i + 1, 0, 0);
  9795. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9796. builder.MoveToCell(0, i + 1, 1, 0);
  9797. int sex = DcList[i].Sex;
  9798. string sexStr = string.Empty;
  9799. if (sex == 0) sexStr = "男";
  9800. else if (sex == 1) sexStr = "女";
  9801. else sexStr = "未设置";
  9802. builder.Write(sexStr);
  9803. builder.MoveToCell(0, i + 1, 2, 0);
  9804. string birthDay = DcList[i].BirthDay;
  9805. string birthDayStr = string.Empty;
  9806. if (!string.IsNullOrEmpty(birthDay))
  9807. {
  9808. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9809. }
  9810. builder.Write(birthDayStr);
  9811. builder.MoveToCell(0, i + 1, 3, 0);
  9812. string company = "";
  9813. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9814. {
  9815. company = DcList[i].CompanyFullName.ToString();
  9816. }
  9817. builder.Write(company);
  9818. builder.MoveToCell(0, i + 1, 4, 0);
  9819. builder.Write(DcList[i].Job);
  9820. }
  9821. }
  9822. else if (_dto.Language == 1)
  9823. {
  9824. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9825. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9826. //循环赋值
  9827. for (int i = 0; i < DcList.Count; i++)
  9828. {
  9829. string PYName = "";
  9830. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9831. {
  9832. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9833. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9834. PYName = PY_First + " " + PY_Last;
  9835. }
  9836. else
  9837. {
  9838. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9839. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9840. PYName = PY_First + " " + PY_Last;
  9841. }
  9842. builder.MoveToCell(0, i + 1, 0, 0);
  9843. builder.Write(PYName);
  9844. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9845. builder.MoveToCell(0, i + 1, 1, 0);
  9846. builder.Write(sex);
  9847. DateTime birthDt;
  9848. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9849. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  9850. builder.MoveToCell(0, i + 1, 2, 0);
  9851. builder.Write(birthday);
  9852. string company = "";
  9853. try
  9854. {
  9855. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9856. {
  9857. //查询对照表
  9858. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9859. if (tempCec != null)
  9860. {
  9861. company = tempCec.enName;
  9862. }
  9863. //翻译
  9864. else
  9865. {
  9866. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  9867. }
  9868. }
  9869. }
  9870. catch (Exception)
  9871. {
  9872. }
  9873. builder.MoveToCell(0, i + 1, 3, 0);
  9874. builder.Write(company);
  9875. string job = "";
  9876. try
  9877. {
  9878. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9879. {
  9880. //查询对照表
  9881. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9882. if (tempPec != null)
  9883. {
  9884. job = tempPec.enName;
  9885. }
  9886. //翻译
  9887. else
  9888. {
  9889. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  9890. }
  9891. }
  9892. }
  9893. catch (Exception ex)
  9894. {
  9895. }
  9896. builder.MoveToCell(0, i + 1, 4, 0);
  9897. builder.Write(job);
  9898. }
  9899. }
  9900. //删除多余行
  9901. while (tableOne.Rows.Count > DcList.Count + 1)
  9902. {
  9903. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9904. }
  9905. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9906. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9907. doc.Save(fileDir);
  9908. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9909. return Ok(JsonView(true, "操作成功!", Url));
  9910. }
  9911. #endregion
  9912. #region 团组倒推表
  9913. /// <summary>
  9914. /// 倒推表基础数据
  9915. /// Init
  9916. /// </summary>
  9917. /// <param name="dto"></param>
  9918. /// <returns></returns>
  9919. [HttpPost]
  9920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9921. public async Task<IActionResult> PostInvertedListInit()
  9922. {
  9923. var viewData = await _invertedListRep._Init();
  9924. if (viewData.Code != 0)
  9925. {
  9926. return Ok(JsonView(false, viewData.Msg));
  9927. }
  9928. return Ok(JsonView(viewData.Data));
  9929. }
  9930. /// <summary>
  9931. /// 倒推表
  9932. /// Info
  9933. /// </summary>
  9934. /// <param name="dto"></param>
  9935. /// <returns></returns>
  9936. [HttpPost]
  9937. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9938. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  9939. {
  9940. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  9941. if (viewData.Code != 0)
  9942. {
  9943. return Ok(JsonView(false, viewData.Msg));
  9944. }
  9945. return Ok(JsonView(viewData.Data));
  9946. }
  9947. /// <summary>
  9948. /// 倒推表
  9949. /// Create
  9950. /// </summary>
  9951. /// <param name="dto"></param>
  9952. /// <returns></returns>
  9953. [HttpPost]
  9954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9955. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  9956. {
  9957. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  9958. if (viewData.Code != 0)
  9959. {
  9960. return Ok(JsonView(false, viewData.Msg));
  9961. }
  9962. return Ok(JsonView(viewData.Data));
  9963. }
  9964. /// <summary>
  9965. /// 倒推表
  9966. /// Update
  9967. /// </summary>
  9968. /// <param name="dto"></param>
  9969. /// <returns></returns>
  9970. [HttpPost]
  9971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9972. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  9973. {
  9974. var viewData = await _invertedListRep._Update(dto);
  9975. if (viewData.Code != 0)
  9976. {
  9977. return Ok(JsonView(false, viewData.Msg));
  9978. }
  9979. return Ok(JsonView(viewData.Data));
  9980. }
  9981. /// <summary>
  9982. /// 倒推表
  9983. /// File Download
  9984. /// </summary>
  9985. /// <param name="dto"></param>
  9986. /// <returns></returns>
  9987. [HttpPost]
  9988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9989. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  9990. {
  9991. var info2 = await _invertedListRep._Info(1, dto.DiId);
  9992. if (info2.Code != 0)
  9993. {
  9994. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  9995. }
  9996. var info1 = info2.Data as InvertedListInfoView;
  9997. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  9998. string teamName = "";
  9999. if (info != null) teamName = info.TeamName;
  10000. //载入模板
  10001. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10002. DocumentBuilder builder = new DocumentBuilder(doc);
  10003. //利用键值对存放数据
  10004. Dictionary<string, string> dic = new Dictionary<string, string>();
  10005. dic.Add("TeamName", teamName);
  10006. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10007. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10008. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10009. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10010. dic.Add("SQRemark", info1.ApprovalRemark);
  10011. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10012. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10013. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10014. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10015. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10016. dic.Add("QZRemark", info1.VisaInformationRemark);
  10017. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10018. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10019. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10020. dic.Add("CQRemark", info1.IssueVisaRemark);
  10021. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10022. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10023. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10024. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10025. #region 填充word模板书签内容
  10026. foreach (var key in dic.Keys)
  10027. {
  10028. builder.MoveToBookmark(key);
  10029. builder.Write(dic[key]);
  10030. }
  10031. #endregion
  10032. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10033. string fileName = $"{teamName}团出行准备流程表.doc";
  10034. string filePath = fileDir + $@"InvertedList/{fileName}";
  10035. doc.Save(filePath);
  10036. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10037. return Ok(JsonView(true, "操作成功!", Url));
  10038. }
  10039. #endregion
  10040. #region 三公签证费用(签证费、代办费)
  10041. /// <summary>
  10042. /// 三公签证费用(签证费、代办费)
  10043. /// List
  10044. /// </summary>
  10045. /// <returns></returns>
  10046. [HttpPost]
  10047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10048. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10049. {
  10050. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10051. if (_view.Code != 0)
  10052. {
  10053. return Ok(JsonView(false, _view.Msg));
  10054. }
  10055. return Ok(JsonView(true, "操作成功!", _view.Data));
  10056. }
  10057. /// <summary>
  10058. /// 三公签证费用(签证费、代办费)
  10059. /// Add Or Update
  10060. /// </summary>
  10061. /// <returns></returns>
  10062. [HttpPost]
  10063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10064. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10065. {
  10066. var _view = await _visaFeeInfoRep._Update(_dto);
  10067. if (_view.Code != 0)
  10068. {
  10069. return Ok(JsonView(false, _view.Msg));
  10070. }
  10071. return Ok(JsonView(true, _view.Msg));
  10072. }
  10073. #endregion
  10074. #region 酒店询价
  10075. /// <summary>
  10076. /// 酒店询价
  10077. /// Init
  10078. /// </summary>
  10079. /// <param name="dto"></param>
  10080. /// <returns></returns>
  10081. [HttpPost]
  10082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10083. public async Task<IActionResult> PostHotelInquiryInit()
  10084. {
  10085. var res = await _hotelInquiryRep._Init();
  10086. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10087. return Ok(JsonView(true, res.Msg, res.Data));
  10088. }
  10089. /// <summary>
  10090. /// 酒店询价
  10091. /// page Item
  10092. /// </summary>
  10093. /// <param name="_dto"></param>
  10094. /// <returns></returns>
  10095. [HttpPost]
  10096. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10097. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10098. {
  10099. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10100. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10101. var view = res.Data as PageDataViewBase;
  10102. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10103. }
  10104. /// <summary>
  10105. /// 酒店询价
  10106. /// info
  10107. /// </summary>
  10108. /// <param name="_dto"></param>
  10109. /// <returns></returns>
  10110. [HttpPost]
  10111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10112. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10113. {
  10114. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10115. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10116. return Ok(JsonView(true, res.Msg, res.Data));
  10117. }
  10118. /// <summary>
  10119. /// 酒店询价
  10120. /// Add Or Edit
  10121. /// </summary>
  10122. /// <param name="_dto"></param>
  10123. /// <returns></returns>
  10124. [HttpPost]
  10125. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10126. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10127. {
  10128. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10129. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10130. return Ok(JsonView(true, res.Msg, res.Data));
  10131. }
  10132. /// <summary>
  10133. /// 酒店询价
  10134. /// Del
  10135. /// </summary>
  10136. /// <param name="_dto"></param>
  10137. /// <returns></returns>
  10138. [HttpPost]
  10139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10140. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10141. {
  10142. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10143. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10144. return Ok(JsonView(true, res.Msg, res.Data));
  10145. }
  10146. #endregion
  10147. #region 下载匹配op行程单
  10148. /// <summary>
  10149. /// 匹配op行程单
  10150. /// Init
  10151. /// </summary>
  10152. /// <param name="dto">团组列表请求dto</param>
  10153. /// <returns></returns>
  10154. [HttpPost]
  10155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10156. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10157. {
  10158. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10159. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10160. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10161. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10162. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10163. .Where(it => it.IsDel == 0)
  10164. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10165. .OrderByDescending(it => it.CreateUserId)
  10166. .ToList();
  10167. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10168. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10169. var diids = groupInfos.Select(it => it.Id).ToList();
  10170. List<string> countrys = new List<string>();
  10171. foreach (var item in country)
  10172. {
  10173. var data = _groupRepository.FormartTeamName(item);
  10174. var dataArray = _groupRepository.GroupSplitCountry(data);
  10175. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10176. }
  10177. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10178. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10179. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10180. foreach (var item in areaItem)
  10181. {
  10182. string areaStr = item.Value;
  10183. if (!string.IsNullOrEmpty(areaStr))
  10184. {
  10185. string[] str1 = areaStr.Split("-");
  10186. if (str1.Length > 0)
  10187. {
  10188. areaArray.AddRange(str1);
  10189. }
  10190. }
  10191. }
  10192. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10193. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10194. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10195. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10196. .ToList();
  10197. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10198. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10199. .Where(it => countriesIds.Contains(it.Id))
  10200. .Select(it => new { it.Id, Name = it.Name_CN })
  10201. .ToList();
  10202. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10203. .Select(it => it.TeamName).ToList();
  10204. stopwatch.Stop();
  10205. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10206. }
  10207. ///// <summary>
  10208. ///// 匹配op行程单
  10209. ///// Init 查询区域数据
  10210. ///// </summary>
  10211. ///// <param name="dto">团组列表请求dto</param>
  10212. ///// <returns></returns>
  10213. //[HttpPost]
  10214. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10215. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10216. //{
  10217. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10218. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10219. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10220. // if (string.IsNullOrEmpty(countriesDataStr))
  10221. // {
  10222. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10223. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10224. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10225. // }
  10226. // else
  10227. // {
  10228. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10229. // }
  10230. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10231. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10232. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10233. // List<dynamic> childList = new List<dynamic>();
  10234. // int parentId = dto.CountriesId;
  10235. // if (provinceData.Count > 1)
  10236. // {
  10237. // foreach (var item1 in provinceData)
  10238. // {
  10239. // List<dynamic> childList1 = new List<dynamic>();
  10240. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10241. // foreach (var item2 in citiesData1)
  10242. // {
  10243. // List<dynamic> childList2 = new List<dynamic>();
  10244. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10245. // foreach (var item3 in countiesData1)
  10246. // {
  10247. // childList2.Add(new
  10248. // {
  10249. // id = item3.Id,
  10250. // parentId = item2.Id,
  10251. // level = "district",
  10252. // name = item3.Name_CN,
  10253. // });
  10254. // }
  10255. // childList1.Add(new
  10256. // {
  10257. // id = item2.Id,
  10258. // parentId = item1.Id,
  10259. // level = "city",
  10260. // name = item2.Name_CN,
  10261. // childList = childList2
  10262. // });
  10263. // }
  10264. // childList.Add(new
  10265. // {
  10266. // id = item1.Id,
  10267. // parentId = parentId,
  10268. // level = "province",
  10269. // name = item1.Name_CN,
  10270. // childList = childList1
  10271. // });
  10272. // }
  10273. // //城市
  10274. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10275. // foreach (var item2 in citiesData2)
  10276. // {
  10277. // List<dynamic> childList22 = new List<dynamic>();
  10278. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10279. // foreach (var item3 in countiesData1)
  10280. // {
  10281. // childList22.Add(new
  10282. // {
  10283. // id = item3.Id,
  10284. // parentId = item2.Id,
  10285. // level = "district",
  10286. // name = item3.Name_CN,
  10287. // });
  10288. // }
  10289. // childList.Add(new
  10290. // {
  10291. // id = item2.Id,
  10292. // parentId = parentId,
  10293. // level = "city",
  10294. // name = item2.Name_CN,
  10295. // childList = childList22
  10296. // });
  10297. // }
  10298. // }
  10299. // else
  10300. // {
  10301. // foreach (var item2 in citiesData)
  10302. // {
  10303. // string cname = item2.Name_CN;
  10304. // List<dynamic> childList1 = new List<dynamic>();
  10305. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10306. // foreach (var item3 in countiesData1)
  10307. // {
  10308. // childList1.Add(new
  10309. // {
  10310. // Id = item3.Id,
  10311. // parentId = item2.Id,
  10312. // level = "district",
  10313. // name = item3.Name_CN
  10314. // });
  10315. // }
  10316. // childList.Add(new
  10317. // {
  10318. // id = item2.Id,
  10319. // parentId = parentId,
  10320. // level = "city",
  10321. // name = item2.Name_CN,
  10322. // childList = childList1
  10323. // });
  10324. // }
  10325. // }
  10326. // stopwatch.Stop();
  10327. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10328. //}
  10329. /// <summary>
  10330. /// 匹配op行程单
  10331. /// 接团信息列表 Page
  10332. /// </summary>
  10333. /// <param name="dto">团组列表请求dto</param>
  10334. /// <returns></returns>
  10335. [HttpPost]
  10336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10337. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10338. {
  10339. var swatch = new Stopwatch();
  10340. swatch.Start();
  10341. #region 参数验证
  10342. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10343. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10344. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10345. #region 页面操作权限验证
  10346. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10347. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10348. #endregion
  10349. #endregion
  10350. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10351. {
  10352. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10353. string sqlWhere = "";
  10354. if (!string.IsNullOrEmpty(dto.Country))
  10355. {
  10356. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10357. }
  10358. if (!string.IsNullOrEmpty(dto.Area))
  10359. {
  10360. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10361. }
  10362. if (!string.IsNullOrEmpty(dto.TeamName))
  10363. {
  10364. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10365. }
  10366. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10367. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10368. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10369. swatch.Stop();
  10370. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10371. }
  10372. else
  10373. {
  10374. return Ok(JsonView(false, "查询失败"));
  10375. }
  10376. }
  10377. /// <summary>
  10378. /// 匹配op行程单
  10379. /// 行程单下载
  10380. /// </summary>
  10381. /// <param name="dto">团组列表请求dto</param>
  10382. /// <returns></returns>
  10383. [HttpPost]
  10384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10385. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10386. {
  10387. #region 参数验证
  10388. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10389. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10390. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10391. #region 页面操作权限验证
  10392. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10393. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10394. #endregion
  10395. #endregion
  10396. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10397. {
  10398. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10399. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10400. }
  10401. else
  10402. {
  10403. return Ok(JsonView(false, "下载失败!"));
  10404. }
  10405. }
  10406. #endregion
  10407. #region 国家信息 数据 注释
  10408. //[HttpPost]
  10409. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10410. //{
  10411. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10412. // foreach (var item in dto)
  10413. // {
  10414. // infos.Add(new Grp_GroupsTaskAssignment()
  10415. // {
  10416. // DIId = item,
  10417. // CTId = 82,
  10418. // UId = 248,
  10419. // IsEnable = 1,
  10420. // CreateUserId = 233,
  10421. // CreateTime = DateTime.Now,
  10422. // IsDel = 0
  10423. // });
  10424. // infos.Add(new Grp_GroupsTaskAssignment()
  10425. // {
  10426. // DIId = item,
  10427. // CTId = 82,
  10428. // UId = 286,
  10429. // IsEnable = 1,
  10430. // CreateUserId = 233,
  10431. // CreateTime = DateTime.Now,
  10432. // IsDel = 0
  10433. // });
  10434. // }
  10435. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10436. // return Ok("操作成功");
  10437. //}
  10438. //public class paramJsonDto
  10439. //{
  10440. // public List<CountriesInfo> str { get; set; }
  10441. //}
  10442. //[HttpPost]
  10443. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10444. //{
  10445. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10446. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10447. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10448. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10449. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10450. // _sqlSugar.BeginTran();
  10451. // int countitiesIndex = 0;
  10452. // foreach (var item in dto.str)
  10453. // {
  10454. // dynamic data = item.c;
  10455. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10456. // if (data != null)
  10457. // {
  10458. // countitiesIndex++;
  10459. // foreach (var item1 in data)
  10460. // {
  10461. // string cnname = item1.cn;
  10462. // string enname = item1.en;
  10463. // Sys_Cities provinceInfo = new Sys_Cities()
  10464. // {
  10465. // CountriesId = countriesId,
  10466. // Name_CN = cnname,
  10467. // Name_EN = enname,
  10468. // ParentId = 0,
  10469. // IsCapital = 1,
  10470. // CreateUserId = 208,
  10471. // CreateTime = DateTime.Now,
  10472. // IsDel = 0
  10473. // };
  10474. // if (item1.lv == "province") //省份
  10475. // {
  10476. // provinceInfo.Level = 1;
  10477. // int provinceId = 0;
  10478. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10479. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10480. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10481. // var data1 = item1.c;
  10482. // foreach (var item2 in data1)
  10483. // {
  10484. // if (item2.lv == "city")
  10485. // {
  10486. // string citycnname = item2.cn;
  10487. // string cityenname = item2.en;
  10488. // Sys_Cities cityInfo = new Sys_Cities()
  10489. // {
  10490. // CountriesId = countriesId,
  10491. // ParentId = provinceId,
  10492. // Level = 2,
  10493. // Name_CN = citycnname,
  10494. // Name_EN = cityenname,
  10495. // IsCapital = 1,
  10496. // CreateUserId = 208,
  10497. // CreateTime = DateTime.Now,
  10498. // IsDel = 0
  10499. // };
  10500. // if (item2.c != null)
  10501. // {
  10502. // int cityId = 0;
  10503. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10504. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10505. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10506. // foreach (var item3 in item2.c)
  10507. // {
  10508. // if (item3.lv == "district")
  10509. // {
  10510. // var districtInfo = new Sys_Cities()
  10511. // {
  10512. // CountriesId = countriesId,
  10513. // Name_CN = item3.cn,
  10514. // Name_EN = item3.en,
  10515. // Level = 3,
  10516. // ParentId = cityId,
  10517. // IsCapital = 1,
  10518. // CreateUserId = 208,
  10519. // CreateTime = DateTime.Now,
  10520. // IsDel = 0
  10521. // };
  10522. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10523. // //{
  10524. // districts.Add(districtInfo);
  10525. // //}
  10526. // }
  10527. // }
  10528. // }
  10529. // else
  10530. // {
  10531. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10532. // //{
  10533. // cities.Add(cityInfo);
  10534. // //}
  10535. // }
  10536. // }
  10537. // }
  10538. // }
  10539. // else if (item1.lv == "city")//城市
  10540. // {
  10541. // provinceInfo.Level = 2;
  10542. // if (item1.c != null)
  10543. // {
  10544. // int cityId = 0;
  10545. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10546. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10547. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10548. // foreach (var item3 in item1.c)
  10549. // {
  10550. // if (item3.lv == "district")
  10551. // {
  10552. // var districtInfo = new Sys_Cities()
  10553. // {
  10554. // CountriesId = countriesId,
  10555. // Name_CN = item3.cn,
  10556. // Name_EN = item3.en,
  10557. // Level = 3,
  10558. // ParentId = cityId,
  10559. // IsCapital = 1,
  10560. // CreateUserId = 208,
  10561. // CreateTime = DateTime.Now,
  10562. // IsDel = 0
  10563. // };
  10564. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10565. // //{
  10566. // districts.Add(districtInfo);
  10567. // //}
  10568. // }
  10569. // }
  10570. // }
  10571. // else
  10572. // {
  10573. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10574. // //{
  10575. // cities.Add(provinceInfo);
  10576. // //}
  10577. // }
  10578. // }
  10579. // }
  10580. // }
  10581. // }
  10582. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10583. // cities = cities.Distinct().ToList();
  10584. // districts = districts.Distinct().ToList();
  10585. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10586. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10587. // cities.AddRange(districts);
  10588. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10589. // //_sqlSugar.RollbackTran();
  10590. // _sqlSugar.CommitTran();
  10591. // return Ok(JsonView(false, "操作成功!"));
  10592. //}
  10593. //[HttpPost]
  10594. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10595. //{
  10596. // List<CountitiesInfo> infos = dto.MyProperty;
  10597. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10598. // _sqlSugar.BeginTran();
  10599. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10600. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10601. // foreach (var item in infos)
  10602. // {
  10603. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10604. // if (countryInfo != null)
  10605. // {
  10606. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10607. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10608. // if (cityInfo1 != null)
  10609. // {
  10610. // cityInfo1.IsCapital = 0;
  10611. // cityInfos.Add(cityInfo1);
  10612. // }
  10613. // }
  10614. // }
  10615. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10616. // .UpdateColumns(it => it.IsCapital)
  10617. // .WhereColumns(it => it.Id)
  10618. // .ExecuteCommand();
  10619. // //_sqlSugar.RollbackTran();
  10620. // _sqlSugar.CommitTran();
  10621. // return Ok(JsonView(false, "操作成功!"));
  10622. //}
  10623. //public class CounrtiesDto
  10624. //{
  10625. // public List<CountitiesInfo> MyProperty { get; set; }
  10626. //}
  10627. //public class CountitiesInfo
  10628. //{
  10629. // /// <summary>
  10630. // /// 圣约翰
  10631. // /// </summary>
  10632. // public string capital_name_chinese { get; set; }
  10633. // /// <summary>
  10634. // ///
  10635. // /// </summary>
  10636. // public string capital_name { get; set; }
  10637. // /// <summary>
  10638. // ///
  10639. // /// </summary>
  10640. // public string country_type { get; set; }
  10641. // /// <summary>
  10642. // /// 安提瓜和巴布达
  10643. // /// </summary>
  10644. // public string country_name_chinese { get; set; }
  10645. // /// <summary>
  10646. // /// 安提瓜和巴布达
  10647. // /// </summary>
  10648. // public string country_name_chinese_short { get; set; }
  10649. // /// <summary>
  10650. // /// 安提瓜和巴布达
  10651. // /// </summary>
  10652. // public string country_name_chinese_UN { get; set; }
  10653. // /// <summary>
  10654. // ///
  10655. // /// </summary>
  10656. // public string country_name_english_abbreviation { get; set; }
  10657. // /// <summary>
  10658. // ///
  10659. // /// </summary>
  10660. // public string country_name_english_formal { get; set; }
  10661. // /// <summary>
  10662. // ///
  10663. // /// </summary>
  10664. // public string country_name_english_UN { get; set; }
  10665. // /// <summary>
  10666. // ///
  10667. // /// </summary>
  10668. // public string continent_name { get; set; }
  10669. // /// <summary>
  10670. // ///
  10671. // /// </summary>
  10672. // public string subregion_name { get; set; }
  10673. // /// <summary>
  10674. // ///
  10675. // /// </summary>
  10676. // public string country_code2 { get; set; }
  10677. // /// <summary>
  10678. // ///
  10679. // /// </summary>
  10680. // public string country_code3 { get; set; }
  10681. // /// <summary>
  10682. // ///
  10683. // /// </summary>
  10684. // public string phone_code { get; set; }
  10685. //}
  10686. //public class CountriesInfo : BasicInfo
  10687. //{
  10688. // public List<CitiesInfo> c { get; set; }
  10689. //}
  10690. //public class CitiesInfo : BasicInfo
  10691. //{
  10692. // public List<AreaInfo> c { get; set; }
  10693. //}
  10694. //public class AreaInfo : BasicInfo
  10695. //{
  10696. // public List<AreaInfo> c { get; set; }
  10697. //}
  10698. //public class BasicInfo
  10699. //{
  10700. // public string code { get; set; }
  10701. // public string cn { get; set; }
  10702. // public string lv { get; set; }
  10703. // public string en { get; set; }
  10704. //}
  10705. #endregion
  10706. #region 查看邀请方
  10707. /// <summary>
  10708. /// 查看邀请方
  10709. /// 邀请方信息 Init
  10710. /// </summary>
  10711. /// <param name="dto"></param>
  10712. /// <returns></returns>
  10713. [HttpPost]
  10714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10715. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10716. {
  10717. string sqlWhere = string.Empty;
  10718. if (!string.IsNullOrEmpty(dto.Search))
  10719. {
  10720. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10721. }
  10722. string sql = string.Format($@"Select
  10723. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10724. Id,
  10725. UnitName
  10726. From Res_InvitationOfficialActivityData
  10727. Where IsDel = 0
  10728. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10729. RefAsync<int> total = 0;
  10730. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10731. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10732. }
  10733. /// <summary>
  10734. /// 查看邀请方
  10735. /// 国家信息 Init
  10736. /// </summary>
  10737. /// <param name="dto"></param>
  10738. /// <returns></returns>
  10739. [HttpPost]
  10740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10741. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10742. {
  10743. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10744. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10745. var diids = groupInfos.Select(it => it.Id).ToList();
  10746. List<string> countrys = new List<string>();
  10747. foreach (var item in country)
  10748. {
  10749. var data = _groupRepository.FormartTeamName(item);
  10750. var dataArray = _groupRepository.GroupSplitCountry(data);
  10751. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10752. }
  10753. countrys = countrys.Distinct().ToList();
  10754. for (int i = 0; i < countrys.Count; i++)
  10755. {
  10756. string item = countrys[i];
  10757. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10758. {
  10759. countrys.Remove(item);
  10760. i--;
  10761. }
  10762. }
  10763. RefAsync<int> total = 0;
  10764. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10765. .Where(it => countrys.Contains(it.Name_CN))
  10766. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10767. .Select(it => new { id = it.Id, name = it.Name_CN })
  10768. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10769. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10770. }
  10771. /// <summary>
  10772. /// 查看邀请方
  10773. /// 城市信息 Init
  10774. /// </summary>
  10775. /// <param name="dto"></param>
  10776. /// <returns></returns>
  10777. [HttpPost]
  10778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10779. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10780. {
  10781. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10782. RefAsync<int> total = 0;
  10783. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10784. .Where(it => it.CountriesId == dto.CountiesId)
  10785. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10786. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10787. .Select(it => new { id = it.Id, name = it.Name_CN })
  10788. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10789. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10790. }
  10791. /// <summary>
  10792. /// 查看邀请方
  10793. /// 团组名称 Init
  10794. /// </summary>
  10795. /// <param name="dto"></param>
  10796. /// <returns></returns>
  10797. [HttpPost]
  10798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10799. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10800. {
  10801. var watch = new Stopwatch();
  10802. watch.Start();
  10803. RefAsync<int> total = 0;
  10804. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10805. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  10806. .Where((oa, di) => oa.IsDel == 0)
  10807. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10808. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10809. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10810. .Distinct()
  10811. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10812. watch.Stop();
  10813. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10814. }
  10815. /// <summary>
  10816. /// 查看邀请方
  10817. /// 团组 & 邀请方信息
  10818. /// </summary>
  10819. /// <param name="dto"></param>
  10820. /// <returns></returns>
  10821. [HttpPost]
  10822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10823. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10824. {
  10825. var watch = new Stopwatch();
  10826. watch.Start();
  10827. RefAsync<int> total = 0;
  10828. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10829. .AS("Grp_DelegationInfo")
  10830. .Includes(x => x.InvitingInfos)
  10831. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10832. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10833. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10834. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10835. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10836. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10837. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10838. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10839. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10840. infos.ForEach(x =>
  10841. {
  10842. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10843. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10844. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10845. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10846. });
  10847. watch.Stop();
  10848. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10849. }
  10850. #endregion
  10851. #region 报批行程
  10852. /// <summary>
  10853. /// 报批行程初始化
  10854. /// </summary>
  10855. /// <param name="dto"></param>
  10856. /// <returns></returns>
  10857. [HttpPost]
  10858. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10859. {
  10860. const int chiNumber = 5;
  10861. var jw = JsonView(false);
  10862. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10863. var group = groupList.First();
  10864. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10865. group = groupList.First(x => x.Id == diid);
  10866. if (group == null)
  10867. {
  10868. jw.Msg = "暂无团组!";
  10869. return Ok(jw);
  10870. }
  10871. var data = new
  10872. {
  10873. groupList = groupList.Select(x => new
  10874. {
  10875. x.TeamName,
  10876. x.Id
  10877. }),
  10878. content = new ArrayList(),
  10879. groupInfo = new
  10880. {
  10881. group.VisitDays,
  10882. group.TourCode,
  10883. group.VisitPNumber,
  10884. group.TeamName,
  10885. group.Id,
  10886. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10887. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10888. },
  10889. };
  10890. var resultArr = new ArrayList();
  10891. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10892. if (content.Count == 0)
  10893. {
  10894. var stay = "-";
  10895. var cityPath = "-";
  10896. //添加城市路径以及住宿地
  10897. //黑屏代码数据
  10898. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10899. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10900. {
  10901. jw = JsonView(true, "黑屏代码有误!", data);
  10902. return Ok(jw);
  10903. }
  10904. foreach (DataRow row in dtBlack.Rows)
  10905. {
  10906. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10907. {
  10908. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  10909. return Ok(jw);
  10910. }
  10911. }
  10912. //黑屏代码获取时间区间
  10913. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  10914. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10915. _sqlSugar.BeginTran();
  10916. for (int i = 0; i < timeArr.Count; i++)
  10917. {
  10918. stay = "-";
  10919. cityPath = "-";
  10920. DateTime NewData = DateTime.Parse(timeArr[i]);
  10921. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10922. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10923. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10924. if (tbSelect.Length > 0)
  10925. {
  10926. List<string> threeCodeStr = new List<string>();
  10927. foreach (var item in tbSelect)
  10928. {
  10929. var threeCode = item["Three"].ToString() ?? "";
  10930. if (threeCode.Length == 6)
  10931. {
  10932. var start = threeCode.Substring(0, 3);
  10933. var end = threeCode.Substring(3, 3);
  10934. if (threeCodeStr.Count == 0)
  10935. {
  10936. threeCodeStr.Add(start);
  10937. threeCodeStr.Add(end);
  10938. }
  10939. else
  10940. {
  10941. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  10942. {
  10943. threeCodeStr.Add(end);
  10944. }
  10945. else
  10946. {
  10947. threeCodeStr.Add(start);
  10948. threeCodeStr.Add(end);
  10949. }
  10950. }
  10951. }
  10952. }
  10953. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  10954. var last = threeCodeStr.Last();
  10955. foreach (var item in threeCodeStr)
  10956. {
  10957. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  10958. if (item.Equals(last))
  10959. {
  10960. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10961. }
  10962. }
  10963. cityPath = cityPath.Trim('-');
  10964. }
  10965. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10966. appro.Diid = diid ?? -1;
  10967. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10968. appro.Id = thisId;
  10969. appro.CreateUserId = dto.UserId;
  10970. appro.CreateTime = DateTime.Now;
  10971. content.Add(appro);
  10972. }
  10973. _sqlSugar.CommitTran();
  10974. }
  10975. foreach (var x in content)
  10976. {
  10977. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  10978. if (chiList.Count < chiNumber)
  10979. {
  10980. for (int i = chiList.Count; i < chiNumber; i++)
  10981. {
  10982. chiList.Add(new Grp_ApprovalTravelDetails());
  10983. }
  10984. }
  10985. resultArr.Add(new
  10986. {
  10987. x.Id,
  10988. x.Date,
  10989. x.Diid,
  10990. chiList = chiList.Select(x1 => new
  10991. {
  10992. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  10993. x1.Details,
  10994. x1.ParentId,
  10995. x1.Id
  10996. })
  10997. });
  10998. }
  10999. data = data with
  11000. {
  11001. content = resultArr,
  11002. };
  11003. jw = JsonView(true, "获取成功!", data);
  11004. return Ok(jw);
  11005. }
  11006. /// <summary>
  11007. /// 报批行程删除
  11008. /// </summary>
  11009. /// <param name="dto"></param>
  11010. /// <returns></returns>
  11011. [HttpPost]
  11012. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11013. {
  11014. var jw = JsonView(false);
  11015. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11016. if (group == null)
  11017. {
  11018. jw.Msg = "团组参数有误!";
  11019. return Ok(jw);
  11020. }
  11021. try
  11022. {
  11023. _sqlSugar.BeginTran();
  11024. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  11025. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11026. {
  11027. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11028. DeleteUserId = dto.uesrId,
  11029. IsDel = 1
  11030. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11031. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11032. {
  11033. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11034. DeleteUserId = dto.uesrId,
  11035. IsDel = 1
  11036. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11037. _sqlSugar.CommitTran();
  11038. jw = JsonView(true, "删除成功");
  11039. }
  11040. catch (Exception ex)
  11041. {
  11042. jw = JsonView(false, ex.Message);
  11043. }
  11044. return Ok(jw);
  11045. }
  11046. /// <summary>
  11047. /// 报批行程保存
  11048. /// </summary>
  11049. /// <param name="dto"></param>
  11050. /// <returns></returns>
  11051. [HttpPost]
  11052. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11053. {
  11054. var jw = JsonView(false);
  11055. var Find = dto.Arr.Find(x => x.id == 0);
  11056. if (Find != null)
  11057. {
  11058. jw.Msg = "生成的ID为0!";
  11059. return Ok(jw);
  11060. }
  11061. foreach (var item in dto.Arr)
  11062. {
  11063. foreach (var chi in item.chiList)
  11064. {
  11065. if (chi.parentId == 0)
  11066. {
  11067. chi.parentId = item.id;
  11068. }
  11069. }
  11070. }
  11071. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11072. _sqlSugar.BeginTran();
  11073. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  11074. {
  11075. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11076. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  11077. {
  11078. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11079. DeleteUserId = dto.UserId,
  11080. IsDel = 1
  11081. }).ExecuteCommand();
  11082. }
  11083. try
  11084. {
  11085. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11086. {
  11087. CreateTime = DateTime.Now,
  11088. CreateUserId = dto.UserId,
  11089. Details = x.details,
  11090. ParentId = x.parentId,
  11091. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11092. Remark = "",
  11093. IsDel = 0
  11094. }).ToList()).ExecuteCommand();
  11095. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11096. {
  11097. Id = x.id,
  11098. Details = x.details,
  11099. ParentId = x.parentId,
  11100. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11101. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11102. {
  11103. Details = x.Details,
  11104. ParentId = x.ParentId,
  11105. Time = x.Time
  11106. }).ExecuteCommand();
  11107. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11108. {
  11109. Id = x.id,
  11110. Date = x.date,
  11111. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11112. {
  11113. Date = x.Date
  11114. }).ExecuteCommand();
  11115. _sqlSugar.CommitTran();
  11116. jw = JsonView(true, "保存成功!");
  11117. }
  11118. catch (Exception ex)
  11119. {
  11120. _sqlSugar.RollbackTran();
  11121. jw = JsonView(false, "保存失败!" + ex.Message);
  11122. }
  11123. return Ok(jw);
  11124. }
  11125. /// <summary>
  11126. /// 报批行程生成
  11127. /// </summary>
  11128. /// <param name="dto"></param>
  11129. /// <returns></returns>
  11130. [HttpPost]
  11131. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11132. {
  11133. var jw = JsonView(false);
  11134. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11135. if (group == null)
  11136. {
  11137. jw.Msg = "暂无该团组!";
  11138. return Ok(jw);
  11139. }
  11140. //黑屏代码数据
  11141. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11142. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11143. {
  11144. jw.Msg = "黑屏代码有误!";
  11145. return Ok(jw);
  11146. }
  11147. foreach (DataRow row in dtBlack.Rows)
  11148. {
  11149. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11150. {
  11151. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11152. return Ok(jw);
  11153. }
  11154. }
  11155. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11156. var resultArr = new ArrayList();
  11157. if (officialActivitiesArr.Count == 0)
  11158. {
  11159. jw.Msg = "暂无公务出访信息!";
  11160. return Ok(jw);
  11161. }
  11162. try
  11163. {
  11164. _sqlSugar.BeginTran();
  11165. DeleteApprovalJourney(new
  11166. Domain.Dtos.Groups.DeleteApprovalJourney
  11167. {
  11168. Diid = dto.Diid,
  11169. uesrId = dto.Userid
  11170. });
  11171. var stay = "-";
  11172. var cityPath = "-";
  11173. //添加城市路径以及住宿地
  11174. //黑屏代码获取时间区间
  11175. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11176. var empty = "【未收入该三字码!请机票同事录入】";
  11177. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11178. for (int i = 0; i < timeArr.Count; i++)
  11179. {
  11180. stay = "-";
  11181. cityPath = "-";
  11182. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11183. DateTime NewData = DateTime.Parse(timeArr[i]);
  11184. 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();
  11185. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11186. if (tbSelect.Length > 0)
  11187. {
  11188. List<string> threeCodeStr = new List<string>();
  11189. bool isTrade = false;
  11190. string trip = string.Empty;
  11191. var rowLast = tbSelect.Last();
  11192. var rowFirst = tbSelect.First();
  11193. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11194. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11195. var takeOffTime = DateTime.Parse(timeArr[i]);
  11196. var fallToTime = DateTime.Parse(timeArr[i]);
  11197. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11198. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11199. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11200. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11201. foreach (var item in tbSelect)
  11202. {
  11203. var start = string.Empty;
  11204. var end = string.Empty;
  11205. var threeCode = item["Three"].ToString() ?? "";
  11206. if (threeCode.Length == 6)
  11207. {
  11208. start = threeCode.Substring(0, 3);
  11209. end = threeCode.Substring(3, 3);
  11210. if (threeCodeStr.Count == 0)
  11211. {
  11212. threeCodeStr.Add(start);
  11213. threeCodeStr.Add(end);
  11214. }
  11215. else
  11216. {
  11217. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11218. {
  11219. threeCodeStr.Add(end);
  11220. }
  11221. else
  11222. {
  11223. threeCodeStr.Add(start);
  11224. threeCodeStr.Add(end);
  11225. }
  11226. }
  11227. }
  11228. //处理机票信息
  11229. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11230. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11231. if (start_Object == null)
  11232. {
  11233. start_Object = new Res_ThreeCode()
  11234. {
  11235. AirPort = empty,
  11236. AirPort_En = empty,
  11237. City = empty,
  11238. Country = empty,
  11239. Four = empty,
  11240. Three = empty,
  11241. };
  11242. }
  11243. if (end_Object == null)
  11244. {
  11245. end_Object = new Res_ThreeCode()
  11246. {
  11247. AirPort = empty,
  11248. AirPort_En = empty,
  11249. City = empty,
  11250. Country = empty,
  11251. Four = empty,
  11252. Three = empty,
  11253. };
  11254. }
  11255. //机型判断
  11256. string airModel = item["AirModel"].ToString();
  11257. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11258. string flightTime = item["FlightTime"].ToString();
  11259. if (flightTime!.Contains(":"))
  11260. {
  11261. flightTime = flightTime.Replace(":", "小时");
  11262. flightTime += "分钟";
  11263. }
  11264. if (flightTime.Contains("H"))
  11265. {
  11266. flightTime = flightTime.Replace("H", "小时");
  11267. }
  11268. if (flightTime.Contains("M"))
  11269. {
  11270. flightTime = flightTime.Replace("M", "分钟");
  11271. }
  11272. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11273. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11274. {
  11275. flightTime = flightDataTime.Hour > 0
  11276. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11277. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11278. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11279. }
  11280. //航班号
  11281. string flightcode = item["Fliagtcode"].ToString();
  11282. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11283. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11284. if (aircompany == null)
  11285. {
  11286. aircompany = new Res_AirCompany
  11287. {
  11288. CnName = hsEmpty,
  11289. EnName = hsEmpty,
  11290. ShortCode = hsEmpty,
  11291. };
  11292. }
  11293. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11294. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11295. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11296. if (isTrade)
  11297. {
  11298. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  11299. }
  11300. else
  11301. {
  11302. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11303. }
  11304. }
  11305. chiarr.Add(new Grp_ApprovalTravelDetails
  11306. {
  11307. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11308. CreateTime = DateTime.Now,
  11309. CreateUserId = dto.Userid,
  11310. ParentId = 0,
  11311. Details = trip
  11312. });
  11313. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11314. var last = threeCodeStr.Last();
  11315. foreach (var item in threeCodeStr)
  11316. {
  11317. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11318. if (item.Equals(last))
  11319. {
  11320. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11321. }
  11322. }
  11323. cityPath = cityPath.Trim('-');
  11324. }
  11325. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11326. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11327. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11328. appro.Diid = dto.Diid;
  11329. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11330. appro.Id = thisId;
  11331. appro.CreateUserId = dto.Userid;
  11332. appro.CreateTime = DateTime.Now;
  11333. foreach (var item in gwinfo)
  11334. {
  11335. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11336. chi.Details = "拜访" + item.Client;
  11337. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  11338. {
  11339. chi.Details += "," + item.ReqSample;
  11340. }
  11341. chi.ParentId = thisId;
  11342. chi.Time = item.Time;
  11343. chiarr.Add(chi);
  11344. }
  11345. if (chiarr.Count < 5)
  11346. {
  11347. for (int j = chiarr.Count; j < 5; j++)
  11348. {
  11349. chiarr.Add(new
  11350. Grp_ApprovalTravelDetails());
  11351. }
  11352. }
  11353. resultArr.Add(new
  11354. {
  11355. appro.Id,
  11356. appro.Date,
  11357. appro.Diid,
  11358. chiList = chiarr.Select(x1 => new
  11359. {
  11360. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11361. x1.Details,
  11362. x1.ParentId,
  11363. x1.Id
  11364. })
  11365. });
  11366. }
  11367. _sqlSugar.CommitTran();
  11368. jw = JsonView(true, "生成成功!", resultArr);
  11369. }
  11370. catch (Exception ex)
  11371. {
  11372. jw.Code = 400;
  11373. jw.Msg = "生成失败!" + ex.Message;
  11374. }
  11375. return Ok(jw);
  11376. }
  11377. /// <summary>
  11378. /// 报批行程word导出
  11379. /// </summary>
  11380. /// <param name="dto"></param>
  11381. /// <returns></returns>
  11382. [HttpPost]
  11383. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11384. {
  11385. var jw = JsonView(false);
  11386. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11387. if (group == null)
  11388. {
  11389. jw.Msg = "暂无该团组!";
  11390. return Ok(jw);
  11391. }
  11392. //模板路径
  11393. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  11394. //载入模板
  11395. Document doc = new Document(tempPath);
  11396. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11397. //获取所填表格的序数
  11398. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11399. Aspose.Words.Tables.Row titleRowClone = null;
  11400. Aspose.Words.Tables.Row CenterRowClone = null;
  11401. int index = 0;
  11402. int indexChi = 0;
  11403. int SetIndex = 0;
  11404. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11405. //获取数据,放到datatable
  11406. foreach (var item in ApprovalTravelArr)
  11407. {
  11408. if (index > 0)
  11409. {
  11410. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11411. tableOne.AppendChild(titleRowClone);
  11412. }
  11413. var textTime = item.Date;
  11414. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11415. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11416. SetIndex++;
  11417. if (ChiRep.Count > 0)
  11418. {
  11419. foreach (var itemChi in ChiRep)
  11420. {
  11421. var txtTime = itemChi.Time;
  11422. var txtDetail = itemChi.Details;
  11423. if (indexChi > 0)
  11424. {
  11425. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11426. tableOne.AppendChild(CenterRowClone);
  11427. }
  11428. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11429. {
  11430. SetCells(tableOne, doc, SetIndex, 0, "");
  11431. SetCells(tableOne, doc, SetIndex, 1, "");
  11432. indexChi++;
  11433. SetIndex++;
  11434. break;
  11435. }
  11436. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11437. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11438. indexChi++;
  11439. SetIndex++;
  11440. }
  11441. }
  11442. else
  11443. {
  11444. if (indexChi > 0)
  11445. {
  11446. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11447. tableOne.AppendChild(CenterRowClone);
  11448. }
  11449. SetCells(tableOne, doc, SetIndex, 0, "");
  11450. SetCells(tableOne, doc, SetIndex, 1, "");
  11451. indexChi++;
  11452. SetIndex++;
  11453. }
  11454. index++;
  11455. }
  11456. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11457. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11458. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11459. jw.Code = 200;
  11460. jw.Msg = "";
  11461. return Ok(jw);
  11462. }
  11463. private string intToString(int numberVal)
  11464. {
  11465. string numberval = numberVal.ToString();
  11466. Dictionary<char, string> Number = new Dictionary<char, string>();
  11467. Number.Add('1', "一");
  11468. Number.Add('2', "二");
  11469. Number.Add('3', "三");
  11470. Number.Add('4', "四");
  11471. Number.Add('5', "五");
  11472. Number.Add('6', "六");
  11473. Number.Add('7', "七");
  11474. Number.Add('8', "八");
  11475. Number.Add('9', "九");
  11476. string stringNumberVal = string.Empty;
  11477. for (int i = 0; i < numberval.Length; i++)
  11478. {
  11479. if (i == 0)
  11480. {
  11481. stringNumberVal += Number[numberval[i]];
  11482. }
  11483. else if (i >= 1)
  11484. {
  11485. if (numberval[i] == '0')
  11486. {
  11487. stringNumberVal = "十";
  11488. }
  11489. else
  11490. {
  11491. stringNumberVal += "十" + Number[numberval[i]];
  11492. }
  11493. }
  11494. }
  11495. return stringNumberVal;
  11496. }
  11497. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11498. {
  11499. //获取table中的某个单元格,从0开始
  11500. Cell lshCell = table.Rows[rows].Cells[cells];
  11501. //将单元格中段落移除
  11502. foreach (Node item in lshCell.Paragraphs)
  11503. {
  11504. lshCell.Paragraphs.Remove(item);
  11505. }
  11506. if (val.Contains("\r\n"))
  11507. {
  11508. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  11509. foreach (var item in spArr)
  11510. {
  11511. //新建一个段落
  11512. Paragraph p = new Paragraph(doc);
  11513. var r = new Run(doc, item);
  11514. //把设置的值赋给之前新建的段落
  11515. p.AppendChild(r);
  11516. //将此段落加到单元格内
  11517. lshCell.AppendChild(p);
  11518. }
  11519. }
  11520. else
  11521. {
  11522. //新建一个段落
  11523. Paragraph p = new Paragraph(doc);
  11524. var r = new Run(doc, val);
  11525. //把设置的值赋给之前新建的段落
  11526. p.AppendChild(r);
  11527. //将此段落加到单元格内
  11528. lshCell.AppendChild(p);
  11529. }
  11530. }
  11531. [HttpPost]
  11532. public async Task<IActionResult> ServerHttp(string paramStr)
  11533. {
  11534. paramStr = paramStr.TrimEnd('\'');
  11535. paramStr = paramStr.TrimStart('\'');
  11536. JsonView jw = JsonView(false);
  11537. JObject param = JObject.Parse(paramStr);
  11538. if (!param.ContainsKey("url"))
  11539. {
  11540. jw.Msg = "url null";
  11541. return Ok(jw);
  11542. }
  11543. string url = param["url"]!.ToString();
  11544. var methon = "get";
  11545. Dictionary<string, string> bodyValues = null;
  11546. Dictionary<string, string> headValues = null;
  11547. if (param.ContainsKey("methon"))
  11548. {
  11549. methon = param["methon"]!.ToString();
  11550. }
  11551. if (param.ContainsKey("header"))
  11552. {
  11553. var header = param["header"]!.ToString();
  11554. JObject headerJobject = JObject.Parse(header);
  11555. headValues = new Dictionary<string, string>();
  11556. foreach (JProperty item in headerJobject.Properties())
  11557. {
  11558. var value = item.Value.ToString();
  11559. var head = item.Path;
  11560. headValues.Add(head, value);
  11561. }
  11562. }
  11563. if (param.ContainsKey("body"))
  11564. {
  11565. var body = param["body"]!.ToString();
  11566. bodyValues = new Dictionary<string, string>();
  11567. JObject bodyJobject = JObject.Parse(body);
  11568. foreach (JProperty item in bodyJobject.Properties())
  11569. {
  11570. var value = item.Value.ToString();
  11571. var head = item.Path;
  11572. bodyValues.Add(head, value);
  11573. }
  11574. }
  11575. HttpClient client = new HttpClient();
  11576. string responseString = string.Empty;
  11577. if (param.ContainsKey("isJson"))
  11578. {
  11579. }
  11580. if (headValues != null)
  11581. {
  11582. foreach (var item in headValues.Keys)
  11583. {
  11584. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11585. }
  11586. }
  11587. try
  11588. {
  11589. if (methon == "get")
  11590. {
  11591. responseString = await client.GetStringAsync(url);
  11592. }
  11593. else if (methon == "post")
  11594. {
  11595. if (bodyValues == null)
  11596. {
  11597. jw.Msg = "methon post body null";
  11598. return Ok(jw);
  11599. }
  11600. // 数据转化为 key=val 格式
  11601. var content = new FormUrlEncodedContent(bodyValues);
  11602. var response = await client.PostAsync(url, content);
  11603. // 获取数据
  11604. responseString = await response.Content.ReadAsStringAsync();
  11605. }
  11606. else
  11607. {
  11608. jw.Msg = "methon error";
  11609. }
  11610. jw = JsonView(true, "success", responseString);
  11611. }
  11612. catch (Exception ex)
  11613. {
  11614. jw.Msg = "error " + ex.Message;
  11615. jw.Data = ex.StackTrace;
  11616. }
  11617. finally
  11618. {
  11619. client.Dispose();
  11620. }
  11621. return Ok(jw);
  11622. }
  11623. #endregion
  11624. // /// <summary>
  11625. // ///
  11626. // /// </summary>
  11627. // /// <param name="_dto"></param>
  11628. // /// <returns></returns>
  11629. // [HttpPost]
  11630. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11631. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11632. // {
  11633. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11634. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11635. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11636. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11637. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11638. // dic_psg.Add("客人", 974);
  11639. // dic_psg.Add("司机", 975);
  11640. // dic_psg.Add("导游", 976);
  11641. // dic_psg.Add("公司内部人员", 977);
  11642. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11643. // foreach (var item in list_visa)
  11644. // {
  11645. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11646. // temp.Id = item.Id;
  11647. // temp.DIId = item.DIId;
  11648. // temp.VisaClient = item.VisaClient;
  11649. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11650. // temp.VisaCurrency = item.VisaCurrency;
  11651. // temp.IsThird = item.IsThird;
  11652. // if (dic_psg.ContainsKey(item.PassengerType))
  11653. // {
  11654. // temp.PassengerType = dic_psg[item.PassengerType];
  11655. // }
  11656. // else {
  11657. // temp.PassengerType = -1;
  11658. // }
  11659. // temp.VisaNumber = item.VisaNumber;
  11660. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11661. // temp.CreateUserId = item.Operators;
  11662. // DateTime dt_ct;
  11663. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11664. // if (b_ct)
  11665. // {
  11666. // temp.CreateTime = dt_ct;
  11667. // }
  11668. // else
  11669. // {
  11670. // temp.CreateTime = DateTime.Now;
  11671. // }
  11672. // temp.DeleteTime = "";
  11673. // temp.DeleteUserId = 0;
  11674. // temp.Remark = item.Remark;
  11675. // if (string.IsNullOrEmpty(temp.Remark)) {
  11676. // temp.Remark = "";
  11677. // }
  11678. // temp.IsDel = item.IsDel;
  11679. // temp.VisaDescription = item.VisaAttachment;
  11680. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11681. //([Id]
  11682. // ,[DIId]
  11683. // ,[VisaClient]
  11684. // ,[VisaPrice]
  11685. // ,[VisaCurrency]
  11686. // ,[IsThird]
  11687. // ,[PassengerType]
  11688. // ,[VisaNumber]
  11689. // ,[VisaFreeNumber]
  11690. // ,[CreateUserId]
  11691. // ,[CreateTime]
  11692. // ,[DeleteTime]
  11693. // ,[DeleteUserId]
  11694. // ,[Remark]
  11695. // ,[IsDel]
  11696. // ,[visaDescription])
  11697. // VALUES
  11698. // ({0},{1},'{2}',{3},{4}
  11699. //,{5},{6},{7},{8},{9}
  11700. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11701. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11702. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11703. //);
  11704. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11705. // }
  11706. // return Ok(JsonView(true, "操作成功!"));
  11707. // }
  11708. /// <summary>
  11709. /// 123132123
  11710. /// </summary>
  11711. /// <param name="_dto"></param>
  11712. /// <returns></returns>
  11713. [HttpPost]
  11714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11715. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11716. {
  11717. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11718. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11719. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11720. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11721. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11722. dicDetail.Add(789, 1034);
  11723. dicDetail.Add(790, 1035);
  11724. dicDetail.Add(791, 1036);
  11725. dicDetail.Add(792, 1037);
  11726. dicDetail.Add(793, 1038);
  11727. dicDetail.Add(794, 1039);
  11728. dicDetail.Add(795, 1040);
  11729. dicDetail.Add(796, 1041);
  11730. dicDetail.Add(797, 1042);
  11731. dicDetail.Add(798, 1043);
  11732. dicDetail.Add(801, 1044);
  11733. dicDetail.Add(802, 1045);
  11734. dicDetail.Add(803, 1046);
  11735. Dictionary<int, int> dic = new Dictionary<int, int>();
  11736. dic.Add(806, 1027);
  11737. dic.Add(807, 1028);
  11738. dic.Add(808, 1029);
  11739. dic.Add(809, 1030);
  11740. dic.Add(810, 1031);
  11741. dic.Add(811, 1032);
  11742. dic.Add(812, 1033);
  11743. foreach (var item in list_visa)
  11744. {
  11745. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11746. temp.Coefficient = item.coefficient;
  11747. DateTime dtCrt;
  11748. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11749. if (b1)
  11750. {
  11751. temp.CreateTime = dtCrt;
  11752. }
  11753. else
  11754. {
  11755. temp.CreateTime = DateTime.Now;
  11756. }
  11757. temp.CreateUserId = item.Operators;
  11758. temp.DeleteTime = "";
  11759. temp.DeleteUserId = 0;
  11760. temp.DiId = int.Parse(item.DIID);
  11761. temp.FilePath = item.FilePath;
  11762. temp.IsDel = item.IsDel;
  11763. temp.Price = item.Price;
  11764. temp.PriceCount = 1;
  11765. temp.PriceCurrency = item.Currency;
  11766. int detailId = 0;
  11767. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11768. {
  11769. detailId = dicDetail[item.PriceTypeDetail];
  11770. }
  11771. temp.PriceDetailType = detailId;
  11772. temp.PriceDt = DateTime.Now;
  11773. temp.PriceName = item.PriceName;
  11774. temp.PriceSum = item.Price;
  11775. int tid = 0;
  11776. if (dic.ContainsKey(item.PriceType))
  11777. {
  11778. tid = dic[item.PriceType];
  11779. }
  11780. temp.PriceType = tid;
  11781. temp.Remark = item.Remark;
  11782. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11783. }
  11784. return Ok(JsonView(true, "操作成功!"));
  11785. }
  11786. }
  11787. }