GroupsController.cs 616 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495
  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. namespace OASystem.API.Controllers
  93. {
  94. /// <summary>
  95. /// 团组相关
  96. /// </summary>
  97. //[Authorize]
  98. [Route("api/[controller]/[action]")]
  99. public class GroupsController : ControllerBase
  100. {
  101. private readonly GrpScheduleRepository _grpScheduleRep;
  102. private readonly IMapper _mapper;
  103. private readonly DelegationInfoRepository _groupRepository;
  104. private readonly TaskAssignmentRepository _taskAssignmentRep;
  105. private readonly AirTicketResRepository _airTicketResRep;
  106. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  107. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  108. private readonly DelegationEnDataRepository _delegationEnDataRep;
  109. private readonly DelegationVisaRepository _delegationVisaRep;
  110. private readonly VisaPriceRepository _visaPriceRep;
  111. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  112. private readonly HotelPriceRepository _hotelPriceRep;
  113. private readonly CustomersRepository _customersRep;
  114. private readonly MessageRepository _message;
  115. private readonly SqlSugarClient _sqlSugar;
  116. private readonly TourClientListRepository _tourClientListRep;
  117. private readonly TeamRateRepository _teamRateRep;
  118. #region 成本相关
  119. private readonly CheckBoxsRepository _checkBoxs;
  120. private readonly GroupCostRepository _GroupCostRepository;
  121. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  122. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  123. #endregion
  124. private readonly SetDataRepository _setDataRep;
  125. private string url;
  126. private string path;
  127. private readonly EnterExitCostRepository _enterExitCostRep;
  128. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  129. private readonly UsersRepository _usersRep;
  130. private readonly IJuHeApiService _juHeApi;
  131. private readonly InvertedListRepository _invertedListRep;
  132. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  133. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  134. private readonly ThreeCodeRepository _threeCodeRepository;
  135. private readonly HotelInquiryRepository _hotelInquiryRep;
  136. private readonly FeeAuditRepository _feeAuditRep;
  137. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  138. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  139. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  140. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  141. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  142. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  143. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  144. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep,
  145. ThreeCodeRepository threeCodeRepository, FeeAuditRepository feeAuditRep)
  146. {
  147. _mapper = mapper;
  148. _grpScheduleRep = grpScheduleRep;
  149. _groupRepository = groupRepository;
  150. _taskAssignmentRep = taskAssignmentRep;
  151. _airTicketResRep = airTicketResRep;
  152. _sqlSugar = sqlSugar;
  153. url = AppSettingsHelper.Get("ExcelBaseUrl");
  154. path = AppSettingsHelper.Get("ExcelBasePath");
  155. if (!System.IO.Directory.Exists(path))
  156. {
  157. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  158. }
  159. _decreasePaymentsRep = decreasePaymentsRep;
  160. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  161. _delegationEnDataRep = delegationEnDataRep;
  162. _enterExitCostRep = enterExitCostRep;
  163. _delegationVisaRep = delegationVisaRep;
  164. _message = message;
  165. _visaPriceRep = visaPriceRep;
  166. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  167. _checkBoxs = checkBoxs;
  168. _GroupCostRepository = GroupCostRepository;
  169. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  170. _GroupCostParameterRepository = GroupCostParameterRepository;
  171. _hotelPriceRep = hotelPriceRep;
  172. _customersRep = customersRep;
  173. _setDataRep = setDataRep;
  174. _tourClientListRep = tourClientListRep;
  175. _teamRateRep = teamRateRep;
  176. _hubContext = hubContext;
  177. _usersRep = usersRep;
  178. _juHeApi = juHeApi;
  179. _invertedListRep = invertedListRep;
  180. _visaFeeInfoRep = visaFeeInfoRep;
  181. _ticketBlackCodeRep = ticketBlackCodeRep;
  182. _hotelInquiryRep = hotelInquiryRep;
  183. _threeCodeRepository = threeCodeRepository;
  184. _feeAuditRep = feeAuditRep;
  185. }
  186. #region 流程管控
  187. /// <summary>
  188. /// 获取团组流程管控信息
  189. /// </summary>
  190. /// <param name="paras">参数Json字符串</param>
  191. /// <returns></returns>
  192. [HttpPost]
  193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  194. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  195. {
  196. if (string.IsNullOrEmpty(_jsonDto.Paras))
  197. {
  198. return Ok(JsonView(false, "参数为空"));
  199. }
  200. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  201. if (_ScheduleDto != null)
  202. {
  203. if (_ScheduleDto.SearchType == 2)//获取列表
  204. {
  205. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  206. return Ok(JsonView(_grpScheduleViewList));
  207. }
  208. else//获取对象
  209. {
  210. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  211. if (_grpScheduleView != null)
  212. {
  213. return Ok(JsonView(_grpScheduleView));
  214. }
  215. }
  216. }
  217. else
  218. {
  219. return Ok(JsonView(false, "参数反序列化失败"));
  220. }
  221. return Ok(JsonView(false, "暂无数据!"));
  222. }
  223. /// <summary>
  224. /// 修改团组流程管控详细表数据
  225. /// </summary>
  226. /// <param name="paras"></param>
  227. /// <returns></returns>
  228. [HttpPost]
  229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  230. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  231. {
  232. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  233. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  234. .SetColumns(it => it.Duty == _detail.Duty)
  235. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  236. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  237. .SetColumns(it => it.JobContent == _detail.JobContent)
  238. .SetColumns(it => it.Remark == _detail.Remark)
  239. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  240. .Where(s => s.Id == dto.Id)
  241. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  242. .ExecuteCommandAsync();
  243. if (result > 0)
  244. {
  245. return Ok(JsonView(true, "保存成功!"));
  246. }
  247. return Ok(JsonView(false, "保存失败!"));
  248. }
  249. /// <summary>
  250. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  251. /// </summary>
  252. /// <param name="dto"></param>
  253. /// <returns></returns>
  254. [HttpPost]
  255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  256. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  257. {
  258. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  259. _detail.IsDel = 1;
  260. _detail.DeleteUserId = dto.Duty;
  261. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  262. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  263. .SetColumns(it => it.IsDel == _detail.IsDel)
  264. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  265. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  266. .Where(it => it.Id == dto.Id)
  267. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  268. //.WhereColumns(s => s.Id == dto.Id)
  269. .ExecuteCommandAsync();
  270. if (result > 0)
  271. {
  272. return Ok(JsonView(true, "删除成功!"));
  273. }
  274. return Ok(JsonView(false, "删除失败!"));
  275. }
  276. /// <summary>
  277. /// 增加团组流程管控详细表数据
  278. /// </summary>
  279. /// <param name="dto"></param>
  280. /// <returns></returns>
  281. [HttpPost]
  282. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  283. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  284. {
  285. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  286. if (DateTime.Now < _detail.ExpectBeginDt)
  287. {
  288. _detail.StepStatus = 0;
  289. }
  290. else
  291. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  292. _detail.StepStatus = 1;
  293. }
  294. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  295. if (result > 0)
  296. {
  297. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  298. return Ok(JsonView(true, "添加成功!", _result));
  299. }
  300. return Ok(JsonView(false, "添加失败!"));
  301. }
  302. #endregion
  303. #region 团组基本信息
  304. /// <summary>
  305. /// 接团信息列表
  306. /// </summary>
  307. /// <param name="dto">团组列表请求dto</param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  312. {
  313. var groupData = await _groupRepository.GetGroupList(dto);
  314. if (groupData.Code != 0)
  315. {
  316. return Ok(JsonView(false, groupData.Msg));
  317. }
  318. return Ok(JsonView(groupData.Data));
  319. }
  320. /// <summary>
  321. /// 接团信息列表 Page
  322. /// </summary>
  323. /// <param name="dto">团组列表请求dto</param>
  324. /// <returns></returns>
  325. [HttpPost]
  326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  327. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  328. {
  329. #region 参数验证
  330. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  331. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  332. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  333. #region 页面操作权限验证
  334. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  335. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  336. #endregion
  337. #endregion
  338. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  339. {
  340. string sqlWhere = string.Empty;
  341. if (dto.IsSure == 0) //未完成
  342. {
  343. sqlWhere += string.Format(@" And IsSure = 0");
  344. }
  345. else if (dto.IsSure == 1) //已完成
  346. {
  347. sqlWhere += string.Format(@" And IsSure = 1");
  348. }
  349. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  350. {
  351. string tj = dto.SearchCriteria;
  352. 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}%')",
  353. tj, tj, tj, tj, tj);
  354. }
  355. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  356. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  357. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  358. JietuanOperator,IsSure,CreateTime
  359. From (
  360. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  361. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  362. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  363. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  364. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  365. From Grp_DelegationInfo gdi
  366. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  367. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  368. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  369. Where gdi.IsDel = 0 {0}
  370. ) temp", sqlWhere);
  371. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  372. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  373. #region 处理所属部门
  374. /*
  375. * 1.sq 和 gyy 等显示 市场部
  376. * 2.王鸽和主管及张总还有管理员号统一国交部
  377. * 2-1. 4 管理员 ,21 张海麟
  378. */
  379. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  380. List<int> userIds1 = new List<int>() { 4, 21 };
  381. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  382. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  383. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  384. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  385. .ToList();
  386. foreach (var item in _DelegationList)
  387. {
  388. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  389. }
  390. #endregion
  391. var _view = new
  392. {
  393. PageFuncAuth = pageFunAuthView,
  394. Data = _DelegationList
  395. };
  396. return Ok(JsonView(true, "查询成功!", _view, total));
  397. }
  398. else
  399. {
  400. return Ok(JsonView(false, "查询失败"));
  401. }
  402. }
  403. /// <summary>
  404. /// 团组列表
  405. /// </summary>
  406. /// <returns></returns>
  407. [HttpPost]
  408. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  409. {
  410. #region 参数验证
  411. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  412. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  413. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  414. #region 页面操作权限验证
  415. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  416. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  417. #endregion
  418. #endregion
  419. if (dto.PortType != 1 && dto.PortType != 2)
  420. {
  421. return Ok(JsonView(false, "查询失败!"));
  422. }
  423. string orderbyStr = "order by gdi.CreateTime Desc";
  424. string sqlWhere = string.Empty;
  425. if (dto.IsSure == 0) //未完成
  426. {
  427. sqlWhere += string.Format(@" And IsSure = 0");
  428. }
  429. else if (dto.IsSure == 1) //已完成
  430. {
  431. sqlWhere += string.Format(@" And IsSure = 1");
  432. }
  433. //团组类型
  434. if (dto.TeamDid > 0)
  435. {
  436. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  437. }
  438. //团组名称
  439. if (!string.IsNullOrEmpty(dto.TeamName))
  440. {
  441. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  442. }
  443. //客户名称
  444. if (!string.IsNullOrEmpty(dto.ClientName))
  445. {
  446. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  447. }
  448. //客户单位
  449. if (!string.IsNullOrEmpty(dto.ClientUnit))
  450. {
  451. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  452. }
  453. //出访时间
  454. if (!string.IsNullOrEmpty(dto.visitDataTime))
  455. {
  456. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  457. orderbyStr = "order by gdi.VisitDate";
  458. }
  459. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  460. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  461. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  462. JietuanOperator,IsSure,CreateTime
  463. From (
  464. Select row_number() over({0}) as Row_Number,
  465. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  466. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  467. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  468. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  469. From Grp_DelegationInfo gdi
  470. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  471. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  472. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  473. Where gdi.IsDel = 0 {1}
  474. ) temp ", orderbyStr, sqlWhere);
  475. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  476. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  477. #region 处理所属部门
  478. /*
  479. * 1.sq 和 gyy 等显示 市场部
  480. * 2.王鸽和主管及张总还有管理员号统一国交部
  481. * 2-1. 4 管理员 ,21 张海麟
  482. */
  483. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  484. List<int> userIds1 = new List<int>() { 4, 21 };
  485. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  486. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  487. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  488. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  489. .ToList();
  490. foreach (var item in _DelegationList)
  491. {
  492. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  493. }
  494. #endregion
  495. var _view = new
  496. {
  497. PageFuncAuth = pageFunAuthView,
  498. Data = _DelegationList
  499. };
  500. return Ok(JsonView(true, "查询成功!", _view, total));
  501. }
  502. /// <summary>
  503. /// 接团信息详情
  504. /// </summary>
  505. /// <param name="dto">团组info请求dto</param>
  506. /// <returns></returns>
  507. [HttpPost]
  508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  509. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  510. {
  511. var groupData = await _groupRepository.GetGroupInfo(dto);
  512. if (groupData.Code != 0)
  513. {
  514. return Ok(JsonView(false, groupData.Msg));
  515. }
  516. return Ok(JsonView(groupData.Data));
  517. }
  518. /// <summary>
  519. /// 接团信息 编辑添加
  520. /// 基础信息数据源
  521. /// </summary>
  522. /// <param name="dto"></param>
  523. /// <returns></returns>
  524. [HttpPost]
  525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  526. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  527. {
  528. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  529. if (groupData.Code != 0)
  530. {
  531. return Ok(JsonView(false, groupData.Msg));
  532. }
  533. return Ok(JsonView(groupData.Data));
  534. }
  535. /// <summary>
  536. /// 接团信息 操作(增改)
  537. /// </summary>
  538. /// <param name="dto"></param>
  539. /// <returns></returns>
  540. [HttpPost]
  541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  542. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  543. {
  544. try
  545. {
  546. var groupData = await _groupRepository.GroupOperation(dto);
  547. if (groupData.Code != 0)
  548. {
  549. return Ok(JsonView(false, groupData.Msg));
  550. }
  551. int diId = 0;
  552. //添加时 默认加入团组汇率
  553. if (dto.Status == 1) //添加
  554. {
  555. diId = groupData.Data;
  556. //添加默认币种
  557. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  558. //默认分配权限
  559. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  560. //消息提示 王鸽 主管号
  561. List<int> _managerIds = new List<int>() { 22, 32 };
  562. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  563. if (userIds.Count > 0)
  564. {
  565. userIds.Add(208);
  566. //创建团组管控
  567. GroupStepForDelegation.CreateWorkStep(diId);
  568. //发送消息
  569. string groupName = dto.TeamName;
  570. string createGroupUser = string.Empty;
  571. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  572. if (userInfo != null) createGroupUser = userInfo.CnName;
  573. string title = $"系统通知";
  574. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  575. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  576. }
  577. //默认创建倒推表
  578. await _invertedListRep._Create(dto.UserId, diId);
  579. }
  580. else if (dto.Status == 2)
  581. {
  582. diId = dto.Id;
  583. }
  584. return Ok(JsonView(true, "操作成功!", diId));
  585. }
  586. catch (Exception ex)
  587. {
  588. Logs("[response]" + JsonConvert.SerializeObject(dto));
  589. Logs(ex.Message);
  590. return Ok(JsonView(false, ex.Message));
  591. }
  592. }
  593. /// <summary>
  594. /// 接团流程操作(增改)
  595. /// 安卓端使用 建团时添加客户名单
  596. /// </summary>
  597. /// <param name="dto"></param>
  598. /// <returns></returns>
  599. [HttpPost]
  600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  601. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  602. {
  603. try
  604. {
  605. #region 参数验证
  606. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  607. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  608. #region 页面操作权限验证
  609. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  610. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  611. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  612. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  613. #endregion
  614. #endregion
  615. _sqlSugar.BeginTran();
  616. var _dto = new GroupOperationDto();
  617. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  618. var groupData = await _groupRepository.GroupOperation(_dto);
  619. if (groupData.Code != 0)
  620. {
  621. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  622. }
  623. int diId = 0;
  624. //添加时 默认加入团组汇率
  625. if (dto.Status == 1) //添加
  626. {
  627. diId = groupData.Data;
  628. //添加默认币种
  629. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  630. //默认分配权限
  631. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  632. //消息提示 王鸽 主管号
  633. List<int> _managerIds = new List<int>() { 22, 32 };
  634. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  635. if (userIds.Count > 0)
  636. {
  637. userIds.Add(208);
  638. //创建团组管控
  639. GroupStepForDelegation.CreateWorkStep(diId);
  640. //发送消息
  641. string groupName = dto.TeamName;
  642. string createGroupUser = string.Empty;
  643. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  644. if (userInfo != null) createGroupUser = userInfo.CnName;
  645. string title = $"系统通知";
  646. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  647. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  648. }
  649. }
  650. if (dto.Status == 2)
  651. {
  652. diId = dto.Id;
  653. if (diId == 0)
  654. {
  655. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  656. }
  657. }
  658. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  659. if (viewData.Code != 0)
  660. {
  661. _sqlSugar.RollbackTran();
  662. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  663. }
  664. _sqlSugar.CommitTran();
  665. return Ok(JsonView(true, "添加成功"));
  666. }
  667. catch (Exception ex)
  668. {
  669. _sqlSugar.RollbackTran();
  670. return Ok(JsonView(false, ex.Message));
  671. }
  672. }
  673. /// <summary>
  674. /// 接团信息 操作(删除)
  675. /// </summary>
  676. /// <param name="dto"></param>
  677. /// <returns></returns>
  678. [HttpPost]
  679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  680. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  681. {
  682. try
  683. {
  684. var groupData = await _groupRepository.GroupDel(dto);
  685. if (groupData.Code != 0)
  686. {
  687. return Ok(JsonView(false, groupData.Msg));
  688. }
  689. return Ok(JsonView(true));
  690. }
  691. catch (Exception ex)
  692. {
  693. Logs("[response]" + JsonConvert.SerializeObject(dto));
  694. Logs(ex.Message);
  695. return Ok(JsonView(false, ex.Message));
  696. }
  697. }
  698. /// <summary>
  699. /// 获取团组销售报价号
  700. /// 团组添加时 使用
  701. /// </summary>
  702. /// <returns></returns>
  703. [HttpPost]
  704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  705. public async Task<IActionResult> GetGroupSalesQuoteNo()
  706. {
  707. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  708. if (groupData.Code != 0)
  709. {
  710. return Ok(JsonView(false, groupData.Msg));
  711. }
  712. object salesQuoteNo = new
  713. {
  714. SalesQuoteNo = groupData.Data
  715. };
  716. return Ok(JsonView(salesQuoteNo));
  717. }
  718. /// <summary>
  719. /// 设置确认出团
  720. /// </summary>
  721. /// <param name="dto"></param>
  722. /// <returns></returns>
  723. [HttpPost]
  724. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  725. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  726. {
  727. var groupData = await _groupRepository.ConfirmationGroup(dto);
  728. if (groupData.Code != 0)
  729. {
  730. return Ok(JsonView(false, groupData.Msg));
  731. }
  732. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  733. #region OA消息推送
  734. try
  735. {
  736. string groupName = groupInfo.TeamName;
  737. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  738. List<int> userIds = new List<int>();
  739. listUser.ForEach(s => userIds.Add(s.Id));
  740. string title = $"系统通知";
  741. string content = $"团组[{groupName}]已确认出团!";
  742. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  743. }
  744. catch (Exception ex)
  745. {
  746. }
  747. #endregion
  748. #region 应用推送
  749. try
  750. {
  751. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  752. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  753. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  754. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  755. {
  756. List<string> userList = new List<string>() { users.QiyeChatUserId };
  757. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  758. }
  759. }
  760. catch (Exception ex)
  761. {
  762. }
  763. #endregion
  764. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  765. return Ok(JsonView(true, "操作成功!", groupData.Data));
  766. }
  767. /// <summary>
  768. /// 获取团组名称data And 签证国别Data
  769. /// </summary>
  770. /// <param name="dto"></param>
  771. /// <returns></returns>
  772. [HttpPost]
  773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  774. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  775. {
  776. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  777. if (groupData.Code != 0)
  778. {
  779. return Ok(JsonView(false, groupData.Msg));
  780. }
  781. return Ok(JsonView(groupData.Data));
  782. }
  783. /// <summary>
  784. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  785. /// </summary>
  786. /// <returns></returns>
  787. [HttpPost]
  788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  789. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  790. {
  791. try
  792. {
  793. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  794. if (groupData.Code != 0)
  795. {
  796. return Ok(JsonView(false, groupData.Msg));
  797. }
  798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  799. }
  800. catch (Exception ex)
  801. {
  802. return Ok(JsonView(false, "程序错误!"));
  803. throw;
  804. }
  805. }
  806. #endregion
  807. #region 团组&签证
  808. /// <summary>
  809. /// 根据团组Id获取签证客户信息List
  810. /// </summary>
  811. /// <param name="dto">请求dto</param>
  812. /// <returns></returns>
  813. [HttpPost]
  814. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  815. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  816. {
  817. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  818. if (groupData.Code != 0)
  819. {
  820. return Ok(JsonView(false, groupData.Msg));
  821. }
  822. return Ok(JsonView(groupData.Data));
  823. }
  824. /// <summary>
  825. /// IOS获取团组签证拍照上传进度01(团组列表)
  826. /// </summary>
  827. /// <param name="dto">请求dto</param>
  828. /// <returns></returns>
  829. [HttpPost]
  830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  831. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  832. {
  833. if (dto == null)
  834. {
  835. return Ok(JsonView(false, "参数为空"));
  836. }
  837. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  838. return Ok(JsonView(visaList));
  839. }
  840. /// <summary>
  841. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  842. /// </summary>
  843. /// <returns></returns>
  844. [HttpPost]
  845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  846. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  847. {
  848. if (dto == null)
  849. {
  850. return Ok(JsonView(false, "请求错误:"));
  851. }
  852. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  853. return Ok(JsonView(list));
  854. }
  855. /// <summary>
  856. /// IOS获取团组签证拍照上传进度03(相册)
  857. /// </summary>
  858. /// <returns></returns>
  859. [HttpPost]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  862. {
  863. if (dto == null)
  864. {
  865. return Ok(JsonView(false, "请求错误:"));
  866. }
  867. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  868. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  869. list.ForEach(s => s.url = url);
  870. return Ok(JsonView(list));
  871. }
  872. /// <summary>
  873. /// IOS获取团组签证拍照上传进度04(图片上传)
  874. /// </summary>
  875. /// <param name="dto"></param>
  876. /// <returns></returns>
  877. [HttpPost]
  878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  879. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  880. {
  881. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  882. //if (!string.IsNullOrEmpty(result))
  883. //{
  884. //}
  885. //else {
  886. // return Ok(JsonView(false, "上传失败"));
  887. //}
  888. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  889. int sucNum = 0;
  890. try
  891. {
  892. foreach (var item in dto.base64DataList)
  893. {
  894. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  895. string result = decodeBase64ToImage(item, imageName);
  896. if (!string.IsNullOrEmpty(result))
  897. {
  898. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  899. pic.CreateUserId = dto.CreateUserId;
  900. pic.PicName = imageName;
  901. pic.PicPath = result;
  902. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  903. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  904. if (insertResult > 0)
  905. {
  906. sucNum++;
  907. }
  908. }
  909. }
  910. }
  911. catch (Exception ex)
  912. {
  913. return Ok(JsonView(false, ex.Message));
  914. }
  915. string msg = string.Format(@"成功上传{0}张", sucNum);
  916. return Ok(JsonView(true, msg));
  917. }
  918. private string decodeBase64ToImage(string base64DataURL, string imgName)
  919. {
  920. string filename = "";//声明一个string类型的相对路径
  921. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  922. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  923. try//会有异常抛出,try,catch一下
  924. {
  925. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  926. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  927. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  928. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  929. //文件名称
  930. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  931. //上传的文件的路径
  932. string filePath = "";
  933. if (!Directory.Exists(fileDir))
  934. {
  935. Directory.CreateDirectory(fileDir);
  936. }
  937. //上传的文件的路径
  938. filePath = fileDir + filename;
  939. //string url = HttpRuntime.AppDomainAppPath.ToString();
  940. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  941. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  942. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  943. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  944. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  945. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  946. ms.Close();//关闭当前流,并释放所有与之关联的资源
  947. bitmap.Dispose();
  948. }
  949. catch (Exception e)
  950. {
  951. string massage = e.Message;
  952. Logs("IOS图片上传Error:" + massage);
  953. //filename = e.Message;
  954. }
  955. return filename;//返回相对路径
  956. }
  957. /// <summary>
  958. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  959. /// </summary>
  960. /// <param name="dto"></param>
  961. /// <returns></returns>
  962. [HttpPost]
  963. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  964. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  965. {
  966. if (dto == null)
  967. {
  968. return Ok(JsonView(false, "请求错误:"));
  969. }
  970. string msg = "参数错误";
  971. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  972. {
  973. try
  974. {
  975. //_delegationVisaRep.BeginTran();
  976. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  977. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  978. .Where(s => s.Id == dto.visaProgressCustomerId)
  979. .ExecuteCommandAsync();
  980. if (updCount > 0 && dto.publishCode == 1)
  981. {
  982. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  983. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  984. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  985. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  986. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  987. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  988. if (groupData == null)
  989. {
  990. _delegationVisaRep.RollbackTran();
  991. }
  992. string title = string.Format(@"[签证进度更新]");
  993. string content = string.Format(@"测试文本");
  994. bool rst = await _message.AddMsg(new MessageDto()
  995. {
  996. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  997. IssuerId = dto.publisher,
  998. Title = title,
  999. Content = content,
  1000. ReleaseTime = DateTime.Now,
  1001. UIdList = new List<int> {
  1002. 234
  1003. }
  1004. });
  1005. if (rst)
  1006. {
  1007. return Ok(JsonView(true, "发送通知成功"));
  1008. }
  1009. }
  1010. //_delegationVisaRep.CommitTran();
  1011. }
  1012. catch (Exception)
  1013. {
  1014. //_delegationVisaRep.RollbackTran();
  1015. }
  1016. }
  1017. return Ok(JsonView(true, msg));
  1018. }
  1019. #endregion
  1020. #region 团组任务分配
  1021. /// <summary>
  1022. /// 团组任务分配初始化
  1023. /// </summary>
  1024. /// <param name="dto"></param>
  1025. /// <returns></returns>
  1026. [HttpPost]
  1027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1028. public async Task<IActionResult> GetTaskAssignmen()
  1029. {
  1030. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1031. if (groupData.Code != 0)
  1032. {
  1033. return Ok(JsonView(false, groupData.Msg));
  1034. }
  1035. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1036. }
  1037. /// <summary>
  1038. /// 团组任务分配查询
  1039. /// </summary>
  1040. /// <param name="dto"></param>
  1041. /// <returns></returns>
  1042. [HttpPost]
  1043. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1044. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1045. {
  1046. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1047. if (groupData.Code != 0)
  1048. {
  1049. return Ok(JsonView(false, groupData.Msg));
  1050. }
  1051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1052. }
  1053. /// <summary>
  1054. /// 团组任务分配操作
  1055. /// </summary>
  1056. /// <param name="dto"></param>
  1057. /// <returns></returns>
  1058. [HttpPost]
  1059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1060. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1061. {
  1062. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1063. if (groupData.Code != 0)
  1064. {
  1065. return Ok(JsonView(false, groupData.Msg));
  1066. }
  1067. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1068. }
  1069. #endregion
  1070. #region 团组费用审核
  1071. /// <summary>
  1072. /// 费用审核
  1073. /// 团组列表 Page
  1074. /// </summary>
  1075. /// <param name="_dto">团组列表请求dto</param>
  1076. /// <returns></returns>
  1077. [HttpPost]
  1078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1079. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1080. {
  1081. #region 参数验证
  1082. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1083. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1084. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1085. #region 页面操作权限验证
  1086. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1087. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1088. #endregion
  1089. #endregion
  1090. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1091. {
  1092. string sqlWhere = string.Empty;
  1093. if (_dto.IsSure == 0) //未完成
  1094. {
  1095. sqlWhere += string.Format(@" And IsSure = 0");
  1096. }
  1097. else if (_dto.IsSure == 1) //已完成
  1098. {
  1099. sqlWhere += string.Format(@" And IsSure = 1");
  1100. }
  1101. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1102. {
  1103. string tj = _dto.SearchCriteria;
  1104. 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}%')",
  1105. tj, tj, tj, tj, tj);
  1106. }
  1107. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1108. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1109. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1110. From (
  1111. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1112. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1113. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1114. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1115. From Grp_DelegationInfo gdi
  1116. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1117. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1118. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1119. Where gdi.IsDel = 0 {0}
  1120. ) temp ", sqlWhere);
  1121. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1122. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1123. var _view = new
  1124. {
  1125. PageFuncAuth = pageFunAuthView,
  1126. Data = _DelegationList
  1127. };
  1128. return Ok(JsonView(true, "查询成功!", _view, total));
  1129. }
  1130. else
  1131. {
  1132. return Ok(JsonView(false, "查询失败"));
  1133. }
  1134. }
  1135. /// <summary>
  1136. /// 获取团组费用审核
  1137. /// </summary>
  1138. /// <param name="paras">参数Json字符串</param>
  1139. /// <returns></returns>
  1140. [HttpPost]
  1141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1142. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1143. {
  1144. try
  1145. {
  1146. #region 参数验证
  1147. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1148. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1149. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1150. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1151. #region 页面操作权限验证
  1152. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1153. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1154. #endregion
  1155. #endregion
  1156. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1157. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1158. #region 费用清单
  1159. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1160. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1161. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1162. List<Grp_CreditCardPayment> entityList = _groupRepository
  1163. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1164. .Where(exp.ToExpression())
  1165. .ToList();
  1166. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1167. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1168. /*
  1169. * 76://酒店预订
  1170. */
  1171. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1172. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1173. .ToListAsync();
  1174. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1175. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. /*
  1178. * 79://车/导游地接
  1179. */
  1180. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1181. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1182. .ToListAsync();
  1183. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1184. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. * 80: //签证
  1188. */
  1189. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1190. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. *81: //邀请/公务活动
  1194. */
  1195. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1196. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1197. .ToListAsync();
  1198. /*
  1199. * 82: //团组客户保险
  1200. */
  1201. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1202. /*
  1203. * Lable = 85 机票预订
  1204. */
  1205. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1206. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1207. .ToListAsync();
  1208. /*
  1209. * 85 机票预定
  1210. */
  1211. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1212. /*
  1213. * 98 其他款项
  1214. */
  1215. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1216. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 285:收款退还
  1220. */
  1221. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1222. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1223. .ToListAsync();
  1224. /*
  1225. * 1015: //超支费用
  1226. */
  1227. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1228. /*
  1229. * 币种信息
  1230. */
  1231. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1232. /*
  1233. * 车/导游地接 费用类型
  1234. */
  1235. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 车/导游地接 费用类型
  1238. */
  1239. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1240. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1241. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1242. /*
  1243. * 用户信息
  1244. */
  1245. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1246. /*
  1247. * 费用模块
  1248. */
  1249. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1250. string priceModule = string.Empty;
  1251. if (sdPriceName != null)
  1252. {
  1253. priceModule = sdPriceName.Name;
  1254. }
  1255. /*
  1256. * 成本信息
  1257. */
  1258. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1259. decimal _groupRate = 0.0000M;
  1260. string _groupCurrencyCode = "-";
  1261. if (groupCost != null)
  1262. {
  1263. _groupRate = groupCost.Rate;
  1264. if (int.TryParse(groupCost.Currency, out int _currency))
  1265. {
  1266. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1267. }
  1268. else _groupCurrencyCode = groupCost.Currency;
  1269. }
  1270. string costContentSql = $"Select * From Grp_GroupCost";
  1271. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1272. //处理日期为空的天数
  1273. for (int i = 0; i < groupCostDetails.Count; i++)
  1274. if (i != 0)
  1275. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1276. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1277. /*
  1278. * 处理详情数据
  1279. */
  1280. foreach (var entity in entityList)
  1281. {
  1282. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1283. _detail.Id = entity.Id;
  1284. _detail.PriceName = priceModule;
  1285. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1286. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1287. /*
  1288. * 应付款金额
  1289. */
  1290. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1291. string PaymentCurrency_WaitPay = "Unknown";
  1292. string hotelCurrncyCode = "Unknown";
  1293. string hotelCurrncyName = "Unknown";
  1294. if (sdPaymentCurrency_WaitPay != null)
  1295. {
  1296. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1297. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1298. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1299. if (hotelCurrncyCode.Equals("CNY"))
  1300. {
  1301. entity.DayRate = 1.0000M;
  1302. }
  1303. }
  1304. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1305. /*
  1306. * 此次付款金额
  1307. */
  1308. decimal CurrPayStr = 0;
  1309. if (entity.PayPercentage == 0)
  1310. {
  1311. if (entity.PayThenMoney != 0)
  1312. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1313. }
  1314. else
  1315. {
  1316. if (entity.PayMoney != 0)
  1317. {
  1318. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1319. }
  1320. }
  1321. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1322. /*
  1323. * 剩余尾款
  1324. */
  1325. decimal BalanceStr = 0;
  1326. if (CurrPayStr != 0)
  1327. {
  1328. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1329. BalanceStr = 0;
  1330. else
  1331. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1332. }
  1333. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1334. /*
  1335. * Bus名称
  1336. */
  1337. _detail.BusName = "待增加";
  1338. /*
  1339. *费用所属
  1340. */
  1341. switch (entity.CTable)
  1342. {
  1343. case 76://酒店预订
  1344. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1345. if (hotelReservations != null)
  1346. {
  1347. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1348. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1349. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1350. string roomFeeStr = "", roomFeestr1 = "";
  1351. //是否比较房型价格
  1352. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1353. roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1354. if (hotelReservations.SingleRoomPrice > 0)
  1355. { roomFeestr1 += $"单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}"; __isSingle = true; }
  1356. if (hotelReservations.DoubleRoomPrice > 0)
  1357. { roomFeestr1 += $"双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}"; __isDouble = true; }
  1358. if (hotelReservations.SuiteRoomPrice > 0)
  1359. { roomFeestr1 += $"套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}"; __isSuite = true; }
  1360. if (hotelReservations.OtherRoomPrice > 0)
  1361. { roomFeestr1 += $"其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}"; __isOther = true; }
  1362. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1;
  1363. else roomFeeStr += " 0.00 * 0";
  1364. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1365. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1366. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1367. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1368. /*
  1369. * 费用类型
  1370. * 1:房费
  1371. * 2:早餐
  1372. * 3:地税
  1373. * 4:城市税
  1374. * </summary>
  1375. */
  1376. //地税
  1377. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1378. if (governmentRentData != null)
  1379. {
  1380. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1381. governmentRentFee = governmentRentData.Price;
  1382. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1383. if (governmentRentCurrData != null)
  1384. {
  1385. governmentRentCode = governmentRentCurrData.Name;
  1386. governmentRentName = $"({governmentRentCurrData.Remark})";
  1387. }
  1388. }
  1389. //城市税
  1390. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1391. if (cityTaxData != null)
  1392. {
  1393. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1394. cityTaxFee = cityTaxData.Price;
  1395. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1396. if (cityTaxCurrData != null)
  1397. {
  1398. cityTaxCode = cityTaxCurrData.Name;
  1399. cityTaxName = $"({cityTaxCurrData.Remark})";
  1400. }
  1401. }
  1402. //酒店早餐
  1403. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1404. if (breakfastData != null)
  1405. {
  1406. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1407. breakfastFee = breakfastData.Price;
  1408. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1409. if (breakfastCurrData != null)
  1410. {
  1411. breakfastCode = breakfastCurrData.Name;
  1412. breakfastName = $"({breakfastCurrData.Remark})";
  1413. }
  1414. }
  1415. //房间费用
  1416. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1417. if (roomData != null)
  1418. {
  1419. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1420. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1421. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1422. roomFee = roomData.Price;
  1423. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1424. if (roomCurrData != null)
  1425. {
  1426. roomCode = roomCurrData.Name;
  1427. roomName = $"({roomCurrData.Remark})";
  1428. }
  1429. }
  1430. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  1431. string hotelCostStr = "";
  1432. decimal hotelCsotTotal = 0.00M;
  1433. if (groupCost != null)
  1434. {
  1435. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  1436. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  1437. }
  1438. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  1439. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  1440. string hotelCost_day = "";
  1441. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  1442. foreach (var item in hotelCostDetails1)
  1443. {
  1444. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  1445. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  1446. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  1447. else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  1448. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  1449. else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  1450. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  1451. else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  1452. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  1453. else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  1454. hotelCost_day += @$"</br>";
  1455. }
  1456. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  1457. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/><br/>";
  1458. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/><br/>";
  1459. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1460. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  1461. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  1462. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  1463. $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1464. $"房间说明: {hotelReservations.Remark} <br/>" +
  1465. $"房间费用: {roomCode} {roomName} 当时汇率 {roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接代付:{roomBool}<br/><br/>" +
  1466. $"{hotelBreakfastStr}" +
  1467. $"{hotelGovernmentRentStr}" +
  1468. $"{hotelCityTaxStr}";
  1469. _detail.PriceNameContent = hotelReservations.HotelName;
  1470. }
  1471. break;
  1472. case 79://车/导游地接
  1473. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1474. if (touristGuideGroundReservations != null)
  1475. {
  1476. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1477. {
  1478. _detail.BusName = touristGuideGroundReservations.BusName;
  1479. }
  1480. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1481. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1482. //if (isInt)
  1483. //{
  1484. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1485. // if (cityInfo != null)
  1486. // {
  1487. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1488. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1489. // if (carFeeItem != null)
  1490. // {
  1491. // nameContent += $@"({carFeeItem.Name})";
  1492. // }
  1493. // _detail.PriceNameContent = nameContent;
  1494. // }
  1495. //}
  1496. //else
  1497. //{
  1498. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1499. //}
  1500. var touristGuideGroundReservationsContents =
  1501. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1502. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  1503. foreach (var item in touristGuideGroundReservationsContents)
  1504. {
  1505. string typeName = "Unknown";
  1506. string carCurrencyCode = "Unknown";
  1507. string carCurrencyName = "Unknown";
  1508. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1509. if (carTypeData != null) typeName = carTypeData.Name;
  1510. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1511. if (currencyData != null)
  1512. {
  1513. carCurrencyCode = currencyData.Name;
  1514. carCurrencyName = currencyData.Remark;
  1515. }
  1516. string opCostStr = string.Empty;
  1517. decimal opCostTypePrice = 0.00M;
  1518. #region 处理成本各项费用
  1519. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  1520. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  1521. if (opCost.Count > 0)
  1522. {
  1523. switch (item.SId)
  1524. {
  1525. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  1526. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  1527. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  1528. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  1529. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  1530. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  1531. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  1532. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  1533. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  1534. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  1535. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  1536. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  1537. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  1538. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  1539. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  1540. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  1541. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  1542. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  1543. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  1544. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  1545. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  1546. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  1547. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  1548. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  1549. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  1550. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  1551. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  1552. }
  1553. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  1554. }
  1555. #endregion
  1556. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  1557. $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")}) {opCostStr}<br/>" +
  1558. $"明细:{item.PriceContent ?? "-"}<br/>" +
  1559. $"备注:{item.Remark ?? "-"}<br/><br/>";
  1560. }
  1561. _detail.PriceMsgContent = priceMsg;
  1562. }
  1563. break;
  1564. case 80: //签证
  1565. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1566. if (visaInfo != null)
  1567. {
  1568. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1569. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1570. }
  1571. break;
  1572. case 81: //邀请/公务活动
  1573. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1574. if (_ioa != null)
  1575. {
  1576. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1577. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1578. sendCurrName = "Unknown", //快递费用币种 Name
  1579. sendCurrCode = "Unknown", //快递费用币种 Code
  1580. eventsCurrName = "Unknown", //公务活动费币种 Name
  1581. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1582. translateCurrName = "Unknown", //公务翻译费 Name
  1583. translateCurrCode = "Unknown"; //公务翻译费 Code
  1584. #region 处理费用币种
  1585. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1586. if (inviteCurrData != null)
  1587. {
  1588. inviteCurrName = inviteCurrData.Remark;
  1589. inviteCurrCode = inviteCurrData.Name;
  1590. }
  1591. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1592. if (sendCurrData != null)
  1593. {
  1594. sendCurrName = sendCurrData.Remark;
  1595. sendCurrCode = sendCurrData.Name;
  1596. }
  1597. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1598. if (eventsCurrData != null)
  1599. {
  1600. eventsCurrName = eventsCurrData.Remark;
  1601. eventsCurrCode = eventsCurrData.Name;
  1602. }
  1603. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1604. if (translateCurrData != null)
  1605. {
  1606. translateCurrName = translateCurrData.Remark;
  1607. translateCurrCode = translateCurrData.Name;
  1608. }
  1609. #endregion
  1610. _detail.PriceNameContent = _ioa.InviterArea;
  1611. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1612. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1613. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1614. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1615. $@"备注:" + _ioa.Remark + "<br/>";
  1616. }
  1617. break;
  1618. case 82: //团组客户保险
  1619. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1620. if (customers != null)
  1621. {
  1622. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1623. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1624. }
  1625. break;
  1626. case 85: //机票预订
  1627. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1628. if (jpRes != null)
  1629. {
  1630. string FlightsDescription = jpRes.FlightsDescription;
  1631. string PriceDescription = jpRes.PriceDescription;
  1632. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1633. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1634. }
  1635. break;
  1636. case 98://其他款项
  1637. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1638. if (gdpRes != null)
  1639. {
  1640. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1641. _detail.PriceNameContent = gdpRes.PriceName;
  1642. }
  1643. break;
  1644. case 285://收款退还
  1645. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1646. if (refundAndOtherMoney != null)
  1647. {
  1648. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1649. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1650. }
  1651. break;
  1652. case 751://酒店早餐
  1653. break;
  1654. case 1015://超支费用
  1655. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1656. if (groupExtraCost != null)
  1657. {
  1658. _detail.PriceNameContent = groupExtraCost.PriceName;
  1659. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1660. }
  1661. break;
  1662. default:
  1663. break;
  1664. }
  1665. /*
  1666. * 申请人
  1667. */
  1668. string operatorName = " - ";
  1669. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1670. if (_opUser != null)
  1671. {
  1672. operatorName = _opUser.CnName;
  1673. }
  1674. _detail.OperatorName = operatorName;
  1675. /*
  1676. * 审核人
  1677. */
  1678. string auditOperatorName = "Unknown";
  1679. if (entity.AuditGMOperate == 0)
  1680. auditOperatorName = " - ";
  1681. else if (entity.AuditGMOperate == 4)
  1682. auditOperatorName = "自动审核";
  1683. else
  1684. {
  1685. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1686. if (_adUser != null)
  1687. {
  1688. auditOperatorName = _adUser.CnName;
  1689. }
  1690. }
  1691. _detail.AuditOperatorName = auditOperatorName;
  1692. /*
  1693. * 超预算比例
  1694. */
  1695. string overBudgetStr = "";
  1696. if (entity.ExceedBudget == -1)
  1697. overBudgetStr = sdPriceName.Name + "尚无预算";
  1698. else if (entity.ExceedBudget == 0)
  1699. {
  1700. if (entity.CTable == 76 || entity.CTable == 79)
  1701. {
  1702. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  1703. else overBudgetStr = "超预算";
  1704. }
  1705. else
  1706. {
  1707. overBudgetStr = "未超预算";
  1708. }
  1709. }
  1710. else
  1711. overBudgetStr = entity.ExceedBudget.ToString("P");
  1712. _detail.OverBudget = overBudgetStr;
  1713. /*
  1714. * 费用总计
  1715. */
  1716. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1717. {
  1718. CurrencyId = entity.PaymentCurrency,
  1719. CurrencyName = PaymentCurrency_WaitPay,
  1720. AmountPayable = entity.PayMoney,
  1721. ThisPayment = CurrPayStr,
  1722. BalancePayment = BalanceStr,
  1723. AuditedFunds = CurrPayStr
  1724. });
  1725. _detail.IsAuditGM = entity.IsAuditGM;
  1726. detailList.Add(_detail);
  1727. }
  1728. #endregion
  1729. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1730. /*
  1731. * 下方描述处理
  1732. */
  1733. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1734. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1735. if (ccpCurrencyPrice != null)
  1736. {
  1737. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1738. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1739. }
  1740. else
  1741. {
  1742. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1743. }
  1744. string amountPayableStr = string.Format(@"应付款总金额: ");
  1745. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1746. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1747. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1748. foreach (var item in nonDuplicat)
  1749. {
  1750. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1751. if (strs.Count > 0)
  1752. {
  1753. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1754. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1755. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1756. //单独处理此次付款金额
  1757. if (item.CurrencyId == 836) //人民币
  1758. {
  1759. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1760. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1761. }
  1762. else
  1763. {
  1764. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1765. }
  1766. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1767. //单独处理已审核费用
  1768. if (item.CurrencyId == 836) //人民币
  1769. {
  1770. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1771. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1772. }
  1773. else
  1774. {
  1775. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1776. }
  1777. }
  1778. }
  1779. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1780. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1781. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1782. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1783. var _view1 = new
  1784. {
  1785. PageFuncAuth = pageFunAuthView,
  1786. Data = _view
  1787. };
  1788. return Ok(JsonView(_view1));
  1789. }
  1790. catch (Exception ex)
  1791. {
  1792. return Ok(JsonView(false, ex.Message));
  1793. }
  1794. }
  1795. /// <summary>
  1796. /// 费用审核
  1797. /// 修改团组费用审核状态
  1798. /// </summary>
  1799. /// <param name="_dto">参数Json字符串</param>
  1800. /// <returns></returns>
  1801. [HttpPost]
  1802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1803. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1804. {
  1805. #region 参数验证
  1806. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1807. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1808. #endregion
  1809. #region 页面操作权限验证
  1810. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1811. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1812. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1813. #endregion
  1814. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1815. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1816. DateTime dtNow = DateTime.Now;
  1817. _groupRepository.BeginTran();
  1818. int rst = 0;
  1819. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1820. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1821. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1822. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1823. List<dynamic> msgDatas = new List<dynamic>();
  1824. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1825. foreach (var item in idList)
  1826. {
  1827. int CreditId = int.Parse(item);
  1828. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1829. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1830. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1831. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1832. .Where(s => s.Id == CreditId)
  1833. .ExecuteCommandAsync();
  1834. if (result < 1)
  1835. {
  1836. rst = -1;
  1837. _groupRepository.RollbackTran();
  1838. return Ok(JsonView(false, "操作失败并回滚!"));
  1839. }
  1840. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1841. if (creditData != null)
  1842. {
  1843. #region 应用通知配置
  1844. try
  1845. {
  1846. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1847. }
  1848. catch (Exception ex)
  1849. {
  1850. }
  1851. #endregion
  1852. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1853. string groupNameStr = string.Empty;
  1854. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1855. if (groupData != null) groupNameStr = groupData.TeamName;
  1856. string creditTypeStr = string.Empty;
  1857. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1858. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1859. string creditCurrency = string.Empty;
  1860. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1861. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1862. if (creditCurrency.Equals("CNY"))
  1863. {
  1864. creditData.DayRate = 1.0000M;
  1865. }
  1866. if (creditData.PayPercentage == 0.00M)
  1867. {
  1868. creditData.PayPercentage = 100M;
  1869. }
  1870. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1871. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1872. string msgContent = "";
  1873. if (creditCurrency.Equals("CNY"))
  1874. {
  1875. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1876. }
  1877. else
  1878. {
  1879. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1880. }
  1881. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1882. }
  1883. }
  1884. if (rst == 0)
  1885. {
  1886. _groupRepository.CommitTran();
  1887. foreach (var item in msgDatas)
  1888. {
  1889. //发送消息
  1890. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1891. }
  1892. #region 应用推送
  1893. try
  1894. {
  1895. foreach (var ccpId in dic_ccp_user.Keys)
  1896. {
  1897. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1898. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1899. }
  1900. }
  1901. catch (Exception)
  1902. {
  1903. }
  1904. #endregion
  1905. return Ok(JsonView(true, "操作成功!"));
  1906. }
  1907. return Ok(JsonView(false, "操作失败!"));
  1908. }
  1909. #endregion
  1910. #region 机票费用录入
  1911. /// <summary>
  1912. /// 机票录入当前登录人可操作团组
  1913. /// </summary>
  1914. /// <param name="dto"></param>
  1915. /// <returns></returns>
  1916. [HttpPost]
  1917. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1918. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1919. {
  1920. try
  1921. {
  1922. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1923. if (groupData.Code != 0)
  1924. {
  1925. return Ok(JsonView(false, groupData.Msg));
  1926. }
  1927. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1928. }
  1929. catch (Exception ex)
  1930. {
  1931. return Ok(JsonView(false, "程序错误!"));
  1932. throw;
  1933. }
  1934. }
  1935. /// <summary>
  1936. /// 机票费用录入列表
  1937. /// </summary>
  1938. /// <param name="dto"></param>
  1939. /// <returns></returns>
  1940. [HttpPost]
  1941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1942. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1943. {
  1944. try
  1945. {
  1946. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1947. if (groupData.Code != 0)
  1948. {
  1949. return Ok(JsonView(false, groupData.Msg));
  1950. }
  1951. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1952. }
  1953. catch (Exception ex)
  1954. {
  1955. return Ok(JsonView(false, ex.Message));
  1956. throw;
  1957. }
  1958. }
  1959. /// <summary>
  1960. /// 根据id查询费用录入信息
  1961. /// </summary>
  1962. /// <param name="dto"></param>
  1963. /// <returns></returns>
  1964. [HttpPost]
  1965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1966. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1967. {
  1968. try
  1969. {
  1970. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1971. if (groupData.Code != 0)
  1972. {
  1973. return Ok(JsonView(false, groupData.Msg));
  1974. }
  1975. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1976. }
  1977. catch (Exception ex)
  1978. {
  1979. return Ok(JsonView(false, "程序错误!"));
  1980. throw;
  1981. }
  1982. }
  1983. /// <summary>
  1984. /// 机票费用录入操作(Status:1.新增,2.修改)
  1985. /// </summary>
  1986. /// <param name="dto"></param>
  1987. /// <returns></returns>
  1988. [HttpPost]
  1989. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1990. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1991. {
  1992. try
  1993. {
  1994. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1995. if (groupData.Code != 0)
  1996. {
  1997. return Ok(JsonView(false, groupData.Msg));
  1998. }
  1999. #region 应用推送
  2000. try
  2001. {
  2002. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2003. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2004. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2005. //机票费用录入变更通知
  2006. await AppNoticeLibrary.SendUserMsg_GroupShare_ToDP(dto.CardPaymentOpData.DIId, dto.CardPaymentOpData.CreateUserId);
  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. #endregion
  3127. #region 团组英文资料
  3128. /// <summary>
  3129. /// 查询团组英文所有资料
  3130. /// </summary>
  3131. /// <param name="dto"></param>
  3132. /// <returns></returns>
  3133. [HttpPost]
  3134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3135. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3136. {
  3137. try
  3138. {
  3139. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3140. if (groupData.Code != 0)
  3141. {
  3142. return Ok(JsonView(false, groupData.Msg));
  3143. }
  3144. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3145. }
  3146. catch (Exception ex)
  3147. {
  3148. return Ok(JsonView(false, "程序错误!"));
  3149. throw;
  3150. }
  3151. }
  3152. /// <summary>
  3153. /// 团组英文资料操作(Status:1.新增,2.修改)
  3154. /// </summary>
  3155. /// <param name="dto"></param>
  3156. /// <returns></returns>
  3157. [HttpPost]
  3158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3159. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3160. {
  3161. try
  3162. {
  3163. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3164. if (groupData.Code != 0)
  3165. {
  3166. return Ok(JsonView(false, groupData.Msg));
  3167. }
  3168. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3169. }
  3170. catch (Exception ex)
  3171. {
  3172. return Ok(JsonView(false, "程序错误!"));
  3173. throw;
  3174. }
  3175. }
  3176. /// <summary>
  3177. /// 团组英文资料Id查询数据
  3178. /// </summary>
  3179. /// <param name="dto"></param>
  3180. /// <returns></returns>
  3181. [HttpPost]
  3182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3183. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3184. {
  3185. try
  3186. {
  3187. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3188. if (_DelegationEnData != null)
  3189. {
  3190. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3191. }
  3192. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3193. }
  3194. catch (Exception ex)
  3195. {
  3196. return Ok(JsonView(false, "程序错误!"));
  3197. throw;
  3198. }
  3199. }
  3200. /// <summary>
  3201. /// 团组英文资料删除
  3202. /// </summary>
  3203. /// <param name="dto"></param>
  3204. /// <returns></returns>
  3205. [HttpPost]
  3206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3207. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3208. {
  3209. try
  3210. {
  3211. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3212. if (!res)
  3213. {
  3214. return Ok(JsonView(false, "删除失败"));
  3215. }
  3216. return Ok(JsonView(true, "删除成功!"));
  3217. }
  3218. catch (Exception ex)
  3219. {
  3220. return Ok(JsonView(false, "程序错误!"));
  3221. throw;
  3222. }
  3223. }
  3224. #endregion
  3225. #region 导出邀请函
  3226. /// <summary>
  3227. /// 导出邀请函页面初始化
  3228. /// </summary>
  3229. /// <param name="dto"></param>
  3230. /// <returns></returns>
  3231. [HttpPost]
  3232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3233. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3234. {
  3235. try
  3236. {
  3237. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3238. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3239. if (dto.DiId == 0)
  3240. {
  3241. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3242. }
  3243. else
  3244. {
  3245. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3246. }
  3247. return Ok(JsonView(true, "查询成功!", new
  3248. {
  3249. deleClient = crm_Deles,
  3250. delegations = grp_Delegations
  3251. }));
  3252. }
  3253. catch (Exception ex)
  3254. {
  3255. return Ok(JsonView(false, "程序错误!"));
  3256. throw;
  3257. }
  3258. }
  3259. /// <summary>
  3260. /// 导出邀请函
  3261. /// </summary>
  3262. /// <param name="dto"></param>
  3263. /// <returns></returns>
  3264. [HttpPost]
  3265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3266. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  3267. {
  3268. #region 参数验证
  3269. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3270. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3271. #endregion
  3272. try
  3273. {
  3274. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3275. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3276. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3277. From Grp_TourClientList tcl
  3278. Left Join
  3279. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3280. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3281. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3282. From Crm_DeleClient dc
  3283. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3284. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3285. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3286. Where dc.IsDel = 0) temp
  3287. On temp.DcId =tcl.ClientId
  3288. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3289. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3290. List<string> texts = new List<string>();
  3291. if (datas.Count != 0)
  3292. {
  3293. foreach (TourClientListDetailsView item in datas)
  3294. {
  3295. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3296. {
  3297. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3298. }
  3299. else
  3300. {
  3301. string name = item.LastName + item.FirstName;
  3302. texts.Add(name);
  3303. }
  3304. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3305. {
  3306. if (!transDic.ContainsKey(item.Job))
  3307. {
  3308. texts.Add(item.Job);
  3309. }
  3310. }
  3311. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3312. {
  3313. texts.Add(item.CompanyFullName);
  3314. }
  3315. }
  3316. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3317. if (transData.Count > 0)
  3318. {
  3319. foreach (TranslateResult item in transData)
  3320. {
  3321. if (!transDic.ContainsKey(item.Query))
  3322. {
  3323. transDic.Add(item.Query, item.Translation);
  3324. }
  3325. }
  3326. }
  3327. List<GuestList> list = new List<GuestList>();
  3328. foreach (TourClientListDetailsView dele in datas)
  3329. {
  3330. GuestList guestList = new GuestList();
  3331. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3332. {
  3333. guestList.Name = dele.Pinyin;
  3334. }
  3335. else
  3336. {
  3337. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3338. guestList.Name = Name;
  3339. }
  3340. if (dele.Sex == 0)
  3341. {
  3342. guestList.Sex = "Male";
  3343. }
  3344. else if (dele.Sex == 1)
  3345. {
  3346. guestList.Sex = "Female";
  3347. }
  3348. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3349. if (!string.IsNullOrEmpty(dele.Job))
  3350. {
  3351. guestList.Job = dele.Job;
  3352. }
  3353. list.Add(guestList);
  3354. }
  3355. //载入模板
  3356. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3357. DocumentBuilder builder = new DocumentBuilder(doc);
  3358. //获取word里所有表格
  3359. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3360. //获取所填表格的序数
  3361. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3362. var rowStart = tableOne.Rows[0]; //获取第1行
  3363. //循环赋值
  3364. for (int i = 0; i < list.Count; i++)
  3365. {
  3366. builder.MoveToCell(0, i + 1, 0, 0);
  3367. builder.Write(list[i].Name.ToString());
  3368. builder.MoveToCell(0, i + 1, 1, 0);
  3369. builder.Write(list[i].Sex.ToString());
  3370. builder.MoveToCell(0, i + 1, 2, 0);
  3371. builder.Write(list[i].DOB.ToString());
  3372. builder.MoveToCell(0, i + 1, 3, 0);
  3373. builder.Write(list[i].Job.ToString());
  3374. }
  3375. //删除多余行
  3376. while (tableOne.Rows.Count > list.Count + 1)
  3377. {
  3378. tableOne.Rows.RemoveAt(list.Count + 1);
  3379. }
  3380. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3381. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3382. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3383. doc.Save(filePath);
  3384. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3385. return Ok(JsonView(true, "操作成功!", Url));
  3386. }
  3387. else
  3388. {
  3389. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3390. }
  3391. }
  3392. catch (Exception ex)
  3393. {
  3394. return Ok(JsonView(false, ex.Message));
  3395. throw;
  3396. }
  3397. }
  3398. #endregion
  3399. #region 团组经理模块 出入境费用
  3400. ///// <summary>
  3401. ///// 团组模块 - 出入境费用
  3402. ///// </summary>
  3403. ///// <returns></returns>
  3404. //[HttpPost]
  3405. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3406. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3407. //{
  3408. // try
  3409. // {
  3410. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3411. // if (data.Code != 0)
  3412. // {
  3413. // return Ok(JsonView(false, data.Msg));
  3414. // }
  3415. // return Ok(JsonView(true, "查询成功!"));
  3416. // }
  3417. // catch (Exception ex)
  3418. // {
  3419. // return Ok(JsonView(false, ex.Message));
  3420. // throw;
  3421. // }
  3422. //}
  3423. /// <summary>
  3424. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3425. /// </summary>
  3426. /// <returns></returns>
  3427. [HttpPost]
  3428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3429. public async Task<IActionResult> SetDayAndCostAreaChange()
  3430. {
  3431. try
  3432. {
  3433. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3434. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3435. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3436. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3437. foreach (var item in unite) //处理交集数据
  3438. {
  3439. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3440. }
  3441. foreach (var item in merge) //处理差集数据
  3442. {
  3443. int nationalTravelFeeId = 0;
  3444. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3445. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3446. else
  3447. {
  3448. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3449. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3450. }
  3451. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3452. }
  3453. //只更新dayAndCost 的 nationalTravelFeeId;
  3454. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3455. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3456. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3457. }
  3458. catch (Exception ex)
  3459. {
  3460. return Ok(JsonView(false, ex.Message));
  3461. throw;
  3462. }
  3463. }
  3464. /// <summary>
  3465. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3466. /// </summary>
  3467. /// <returns></returns>
  3468. [HttpPost]
  3469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3470. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3471. {
  3472. try
  3473. {
  3474. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3475. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3476. //SetDataInfoView
  3477. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3478. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3479. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3480. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3481. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3482. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3483. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3484. //默认币种显示
  3485. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3486. {
  3487. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3488. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3489. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3490. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3491. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3492. };
  3493. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3494. if (_currencyRate.Count > 0)
  3495. {
  3496. foreach (var item in _currencyInfos)
  3497. {
  3498. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3499. if (rateInfo != null)
  3500. {
  3501. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3502. rate1 *= 1.035M;
  3503. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3504. }
  3505. }
  3506. }
  3507. return Ok(JsonView(true, "查询成功!", new
  3508. {
  3509. GroupNameData = groupNameData.Data,
  3510. CurrencyData = _CurrencyData,
  3511. WordTypeData = _WordTypeData,
  3512. ExcelTypeData = _ExcelTypeData,
  3513. CurrencyInit = _currencyInfos
  3514. }));
  3515. }
  3516. catch (Exception ex)
  3517. {
  3518. return Ok(JsonView(false, ex.Message));
  3519. throw;
  3520. }
  3521. }
  3522. /// <summary>
  3523. /// 团组模块 - 出入境费用
  3524. /// 实时汇率 tips
  3525. /// 签证费用 tips
  3526. /// </summary>
  3527. /// <returns></returns>
  3528. [HttpPost]
  3529. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3530. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3531. {
  3532. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3533. //默认币种显示
  3534. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3535. {
  3536. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3537. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3538. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3539. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3540. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3541. };
  3542. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3543. List<dynamic> reteInfos = new List<dynamic>();
  3544. if (_currencyRate.Count > 0)
  3545. {
  3546. foreach (var item in _currencyInfos)
  3547. {
  3548. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3549. if (rateInfo != null)
  3550. {
  3551. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3552. decimal rate1 = item.Rate;
  3553. rate1 *= 1.03M;
  3554. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3555. reteInfos.Add(new
  3556. {
  3557. currCode = item.CurrencyCode,
  3558. currName = item.CurrencyName,
  3559. rate = rate2,
  3560. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3561. });
  3562. }
  3563. }
  3564. }
  3565. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3566. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3567. return Ok(JsonView(true, "查询成功!", new
  3568. {
  3569. //GroupNameData = groupNameData.Data,
  3570. visaData = visaData.Data,
  3571. airData = airData.Data,
  3572. reteInfos = reteInfos
  3573. }));
  3574. }
  3575. /// <summary>
  3576. /// 团组模块 - 出入境费用 - Info
  3577. /// </summary>
  3578. /// <returns></returns>
  3579. [HttpPost]
  3580. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3581. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3582. {
  3583. try
  3584. {
  3585. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3586. if (data.Code != 0)
  3587. {
  3588. return Ok(JsonView(false, data.Msg));
  3589. }
  3590. return Ok(JsonView(true, "查询成功!", data.Data));
  3591. }
  3592. catch (Exception ex)
  3593. {
  3594. return Ok(JsonView(false, ex.Message));
  3595. }
  3596. }
  3597. /// <summary>
  3598. /// 团组模块 - 出入境费用 - Add And Update
  3599. /// </summary>
  3600. /// <returns></returns>
  3601. [HttpPost]
  3602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3603. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3604. {
  3605. try
  3606. {
  3607. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3608. if (data.Code != 0)
  3609. {
  3610. return Ok(JsonView(false, data.Msg));
  3611. }
  3612. //生成默认文件pdf并且通知人员
  3613. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  3614. {
  3615. DiId = dto.DiId,
  3616. ExportType = 1,
  3617. SubTypeId = 1005
  3618. }, "pdf");
  3619. //发送通知
  3620. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  3621. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  3622. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  3623. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign,fileUrl);
  3624. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208","233","21" }, dto.UserId, url);
  3625. return Ok(JsonView(true, data.Msg, data.Data));
  3626. }
  3627. catch (Exception ex)
  3628. {
  3629. return Ok(JsonView(false, ex.Message));
  3630. }
  3631. }
  3632. /// <summary>
  3633. /// 团组模块 - 出入境费用 - Confirm 费用
  3634. /// </summary>
  3635. /// <returns></returns>
  3636. [HttpPost]
  3637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3638. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  3639. {
  3640. //TODO:测试完毕需把对应的用户ID更改
  3641. //1、数据表添加字段
  3642. //2、更改字段接口()
  3643. var _view = await _enterExitCostRep.ConfirmCost(dto);
  3644. //3、确认成功 给财务发送消息
  3645. if (_view.Code == 200)
  3646. {
  3647. if (dto.Type == 1)
  3648. {
  3649. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  3650. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  3651. }
  3652. }
  3653. return Ok(_view);
  3654. }
  3655. /// <summary>
  3656. /// 团组模块 - 出入境费用 - File downlaod
  3657. /// </summary>
  3658. /// <param name="dto"></param>
  3659. /// <returns></returns>
  3660. [HttpPost]
  3661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3662. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3663. {
  3664. try
  3665. {
  3666. if (dto.DiId < 1)
  3667. {
  3668. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3669. }
  3670. if (dto.ExportType < 1)
  3671. {
  3672. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3673. }
  3674. if (dto.SubTypeId < 1)
  3675. {
  3676. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3677. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3678. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3679. 3 团组成员名单 1 团组成员名单"));
  3680. }
  3681. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3682. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3683. if (_EnterExitCosts == null)
  3684. {
  3685. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3686. }
  3687. //数据源
  3688. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3689. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3690. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3691. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3692. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3693. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3694. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3695. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3696. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3697. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3698. .Select((tcl, dc, cc) => new
  3699. {
  3700. Name = dc.LastName + dc.FirstName,
  3701. Sex = dc.Sex,
  3702. Birthday = dc.BirthDay,
  3703. Company = cc.CompanyFullName,
  3704. Job = dc.Job
  3705. })
  3706. .ToList();
  3707. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3708. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3709. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3710. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3711. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3712. if (dto.ExportType == 1) //明细表
  3713. {
  3714. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3715. {
  3716. //获取模板
  3717. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3718. //载入模板
  3719. Document doc = new Document(tempPath);
  3720. DocumentBuilder builder = new DocumentBuilder(doc);
  3721. //利用键值对存放数据
  3722. Dictionary<string, string> dic = new Dictionary<string, string>();
  3723. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3724. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3725. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3726. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3727. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3728. string row1_1 = "";
  3729. if (_EnterExitCosts.Visa > 0)
  3730. {
  3731. //insidePayTotal += _EnterExitCosts.Visa;
  3732. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3733. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3734. {
  3735. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3736. }
  3737. }
  3738. string row1_2 = "";
  3739. if (_EnterExitCosts.YiMiao > 0)
  3740. {
  3741. //insidePayTotal += _EnterExitCosts.YiMiao;
  3742. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3743. }
  3744. if (_EnterExitCosts.HeSuan > 0)
  3745. {
  3746. //insidePayTotal += _EnterExitCosts.HeSuan;
  3747. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3748. }
  3749. if (_EnterExitCosts.Service > 0)
  3750. {
  3751. //insidePayTotal += _EnterExitCosts.Service;
  3752. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3753. }
  3754. string row1_3 = "";
  3755. if (_EnterExitCosts.Safe > 0)
  3756. {
  3757. //insidePayTotal += _EnterExitCosts.Safe;
  3758. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3759. }
  3760. if (_EnterExitCosts.Ticket > 0)
  3761. {
  3762. //insidePayTotal += _EnterExitCosts.Ticket;
  3763. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3764. }
  3765. string row1 = "";
  3766. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3767. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3768. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3769. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3770. dic.Add("Row1Str", row1);
  3771. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3772. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3773. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3774. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3775. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3776. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3777. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3778. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3779. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3780. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3781. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3782. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3783. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3784. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3785. #region 填充word模板书签内容
  3786. foreach (var key in dic.Keys)
  3787. {
  3788. builder.MoveToBookmark(key);
  3789. builder.Write(dic[key]);
  3790. }
  3791. #endregion
  3792. #region 填充word表格内容
  3793. ////获读取指定表格方法二
  3794. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3795. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3796. for (int i = 0; i < dac1.Count; i++)
  3797. {
  3798. Grp_DayAndCost dac = dac1[i];
  3799. if (dac == null) continue;
  3800. builder.MoveToCell(0, i, 0, 0);
  3801. builder.Write("第" + dac.Days.ToString() + "晚:");
  3802. builder.MoveToCell(0, i, 1, 0);
  3803. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3804. //builder.Write(dac.Place == null ? "" : dac.Place);
  3805. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3806. builder.MoveToCell(0, i, 2, 0);
  3807. builder.Write("费用标准:");
  3808. string curr = "";
  3809. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3810. if (currData != null)
  3811. {
  3812. curr = currData.Name;
  3813. }
  3814. builder.MoveToCell(0, i, 3, 0);
  3815. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3816. builder.MoveToCell(0, i, 4, 0);
  3817. builder.Write("费用小计:");
  3818. builder.MoveToCell(0, i, 5, 0);
  3819. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3820. }
  3821. //删除多余行
  3822. while (table1.Rows.Count > dac1.Count)
  3823. {
  3824. table1.Rows.RemoveAt(dac1.Count);
  3825. }
  3826. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3827. for (int i = 0; i < dac2.Count; i++)
  3828. {
  3829. Grp_DayAndCost dac = dac2[i];
  3830. if (dac == null) continue;
  3831. builder.MoveToCell(1, i, 0, 0);
  3832. builder.Write("第" + dac.Days.ToString() + "天:");
  3833. builder.MoveToCell(1, i, 1, 0);
  3834. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3835. builder.MoveToCell(1, i, 2, 0);
  3836. builder.Write("费用标准:");
  3837. string curr = "";
  3838. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3839. if (currData != null)
  3840. {
  3841. curr = currData.Name;
  3842. }
  3843. builder.MoveToCell(1, i, 3, 0);
  3844. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3845. builder.MoveToCell(1, i, 4, 0);
  3846. builder.Write("费用小计:");
  3847. builder.MoveToCell(1, i, 5, 0);
  3848. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3849. }
  3850. //删除多余行
  3851. while (table2.Rows.Count > dac2.Count)
  3852. {
  3853. table2.Rows.RemoveAt(dac2.Count);
  3854. }
  3855. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3856. for (int i = 0; i < dac3.Count; i++)
  3857. {
  3858. Grp_DayAndCost dac = dac3[i];
  3859. if (dac == null) continue;
  3860. builder.MoveToCell(2, i, 0, 0);
  3861. builder.Write("第" + dac.Days.ToString() + "天:");
  3862. builder.MoveToCell(2, i, 1, 0);
  3863. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3864. builder.MoveToCell(2, i, 2, 0);
  3865. builder.Write("费用标准:");
  3866. string curr = "";
  3867. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3868. if (currData != null)
  3869. {
  3870. curr = currData.Name;
  3871. }
  3872. builder.MoveToCell(2, i, 3, 0);
  3873. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3874. builder.MoveToCell(2, i, 4, 0);
  3875. builder.Write("费用小计:");
  3876. builder.MoveToCell(2, i, 5, 0);
  3877. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3878. }
  3879. //删除多余行
  3880. while (table3.Rows.Count > dac3.Count)
  3881. {
  3882. table3.Rows.RemoveAt(dac3.Count);
  3883. }
  3884. #endregion
  3885. //文件名
  3886. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3887. AsposeHelper.removewatermark_v2180();
  3888. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3889. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3890. return Ok(JsonView(true, "成功", new { Url = url }));
  3891. }
  3892. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3893. {
  3894. //获取模板
  3895. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3896. //载入模板
  3897. Document doc = new Document(tempPath);
  3898. DocumentBuilder builder = new DocumentBuilder(doc);
  3899. Dictionary<string, string> dic = new Dictionary<string, string>();
  3900. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3901. {
  3902. List<string> list = new List<string>();
  3903. try
  3904. {
  3905. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3906. foreach (var item in spilitArr)
  3907. {
  3908. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3909. var depCode = spDotandEmpty[2].Substring(0, 3);
  3910. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3911. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3912. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3913. list.Add(depName);
  3914. list.Add(arrName);
  3915. }
  3916. list = list.Distinct().ToList();
  3917. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3918. }
  3919. catch (Exception)
  3920. {
  3921. dic.Add("ReturnCode", "行程录入不正确!");
  3922. }
  3923. }
  3924. else
  3925. {
  3926. dic.Add("ReturnCode", "未录入行程!");
  3927. }
  3928. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3929. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3930. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3931. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3932. {
  3933. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3934. dic.Add("Day", sp.Days.ToString());
  3935. }
  3936. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3937. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3938. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3939. //dic.Add("Names", Names);
  3940. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3941. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3942. decimal dac1totalPrice = 0.00M;
  3943. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3944. foreach (var dac in dac1)
  3945. {
  3946. if (dac.SubTotal == 0.00M)
  3947. {
  3948. continue;
  3949. }
  3950. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3951. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3952. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3953. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3954. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3955. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3956. builder.Write(currency);//币种
  3957. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3958. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3959. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3960. builder.Write("");//人数
  3961. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3962. builder.Write("");//天数
  3963. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3964. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3965. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3966. decimal rate = 0.00M;
  3967. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3968. builder.Write(rate.ToString("#0.0000"));//汇率
  3969. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3970. decimal rbmPrice = dac.SubTotal;
  3971. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3972. accommodationStartIndex++;
  3973. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3974. }
  3975. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3976. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3977. {
  3978. table1.Rows.RemoveAt(i - 1);
  3979. foodandotherStartIndex--;
  3980. }
  3981. if (dac2.Count == dac3.Count)//国家 币种 金额
  3982. {
  3983. for (int i = 0; i < dac2.Count; i++)
  3984. {
  3985. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3986. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3987. }
  3988. }
  3989. decimal dac2totalPrice = 0.00M;
  3990. foreach (var dac in dac2)
  3991. {
  3992. if (dac.SubTotal == 0)
  3993. {
  3994. continue;
  3995. }
  3996. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3997. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3998. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3999. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  4000. builder.Write(currency);//币种
  4001. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4002. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4003. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4004. builder.Write("");//人数
  4005. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4006. builder.Write("");//天数
  4007. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4008. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4009. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4010. decimal rate = 0.00M;
  4011. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  4012. builder.Write(rate.ToString("#0.0000"));//汇率
  4013. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4014. decimal rbmPrice = dac.SubTotal;
  4015. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4016. foodandotherStartIndex++;
  4017. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  4018. }
  4019. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4020. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  4021. {
  4022. table1.Rows.RemoveAt(i - 1);
  4023. }
  4024. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4025. string otherFeeStr = "";
  4026. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4027. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4028. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4029. if (otherFeeStr.Length > 0)
  4030. {
  4031. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4032. otherFeeStr = $"({otherFeeStr})";
  4033. dic.Add("OtherFeeStr", otherFeeStr);
  4034. }
  4035. //总计
  4036. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  4037. //国际旅费
  4038. string outsideJJ = "";
  4039. string allPriceJJ = "";
  4040. if (_EnterExitCosts.SumJJC == 1)
  4041. {
  4042. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4043. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  4044. }
  4045. string outsideGW = "";
  4046. string allPriceGW = "";
  4047. if (_EnterExitCosts.SumGWC == 1)
  4048. {
  4049. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  4050. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4051. }
  4052. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  4053. {
  4054. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  4055. dic.Add("InTravelPrice", InTravelPriceStr);
  4056. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  4057. dic.Add("FinalSumPrice", FinalSumPriceStr);
  4058. }
  4059. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  4060. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  4061. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  4062. foreach (var key in dic.Keys)
  4063. {
  4064. builder.MoveToBookmark(key);
  4065. builder.Write(dic[key]);
  4066. }
  4067. //模板文件名
  4068. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  4069. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4070. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4071. return Ok(JsonView(true, "成功", new { Url = url }));
  4072. }
  4073. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  4074. {
  4075. //获取模板
  4076. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  4077. //载入模板
  4078. WorkbookDesigner designer = new WorkbookDesigner();
  4079. designer.Workbook = new Workbook(tempPath);
  4080. Dictionary<string, string> dic = new Dictionary<string, string>();
  4081. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4082. {
  4083. List<string> list = new List<string>();
  4084. try
  4085. {
  4086. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4087. foreach (var item in spilitArr)
  4088. {
  4089. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4090. var depCode = spDotandEmpty[2].Substring(0, 3);
  4091. var arrCode = spDotandEmpty[2].Substring(3, 3);
  4092. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  4093. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  4094. list.Add(depName);
  4095. list.Add(arrName);
  4096. }
  4097. list = list.Distinct().ToList();
  4098. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4099. }
  4100. catch (Exception)
  4101. {
  4102. dic.Add("ReturnCode", "行程录入不正确!");
  4103. }
  4104. }
  4105. else
  4106. {
  4107. dic.Add("ReturnCode", "未录入行程!");
  4108. }
  4109. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4110. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4111. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4112. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4113. {
  4114. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4115. dic.Add("Day", sp.Days.ToString());
  4116. }
  4117. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4118. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4119. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  4120. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  4121. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  4122. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  4123. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  4124. designer.SetDataSource("Name", Names);
  4125. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  4126. designer.SetDataSource("Day", dic["Day"] + "天");
  4127. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  4128. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  4129. int startIndex = 10;
  4130. const int startIndexcopy = 10;
  4131. if (dac2.Count == dac3.Count)//国家 币种 金额
  4132. {
  4133. for (int i = 0; i < dac2.Count; i++)
  4134. {
  4135. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4136. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4137. }
  4138. }
  4139. DataTable dtdac1 = new DataTable();
  4140. List<string> place = new List<string>();
  4141. dtdac1.Columns.AddRange(new DataColumn[] {
  4142. new DataColumn(){ ColumnName = "city"},
  4143. new DataColumn(){ ColumnName = "curr"},
  4144. new DataColumn(){ ColumnName = "criterion"},
  4145. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4146. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4147. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4148. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4149. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  4150. });
  4151. DataTable dtdac2 = new DataTable();
  4152. dtdac2.Columns.AddRange(new DataColumn[] {
  4153. new DataColumn(){ ColumnName = "city"},
  4154. new DataColumn(){ ColumnName = "curr"},
  4155. new DataColumn(){ ColumnName = "criterion"},
  4156. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  4157. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  4158. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  4159. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  4160. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  4161. });
  4162. dtdac1.TableName = "tb1";
  4163. dtdac2.TableName = "tb2";
  4164. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  4165. foreach (var item in dac1)
  4166. {
  4167. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4168. if (place.Contains(item.Place))
  4169. {
  4170. continue;
  4171. }
  4172. DataRow row = dtdac1.NewRow();
  4173. row["city"] = item.Place;
  4174. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4175. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4176. row["curr"] = currency;
  4177. row["rate"] = rate.ToString("#0.0000");
  4178. row["criterion"] = item.Cost.ToString("#0.00");
  4179. row["number"] = 1;
  4180. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4181. //row["costRMB"] = rbmPrice;
  4182. dtdac1.Rows.Add(row);
  4183. place.Add(item.Place);
  4184. }
  4185. place = new List<string>();
  4186. foreach (var item in dac2)
  4187. {
  4188. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4189. if (place.Contains(item.Place))
  4190. {
  4191. continue;
  4192. }
  4193. DataRow row = dtdac2.NewRow();
  4194. row["city"] = item.Place;
  4195. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4196. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4197. row["curr"] = currency;
  4198. row["rate"] = rate.ToString("#0.0000");
  4199. row["criterion"] = item.Cost.ToString("#0.00");
  4200. row["number"] = 1;
  4201. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4202. //row["cost"] = item.SubTotal;
  4203. //row["costRMB"] = rbmPrice;
  4204. dtdac2.Rows.Add(row);
  4205. place.Add(item.Place);
  4206. //dac2totalPrice += rbmPrice;
  4207. }
  4208. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4209. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4210. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4211. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4212. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4213. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4214. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4215. string cellStr = $" 5.其他费用(";
  4216. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4217. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4218. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4219. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4220. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4221. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4222. if (cellStr.Length > 8)
  4223. {
  4224. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4225. }
  4226. cellStr += ")";
  4227. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4228. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4229. decimal pxFee = dac4.Sum(it => it.Cost);
  4230. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4231. string celllastStr1 = "";
  4232. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4233. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4234. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4235. celllastStr1 += $",国际旅费 元";
  4236. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4237. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4238. designer.SetDataSource("cell4Str", cell4Str);
  4239. designer.SetDataSource("cellStr", cellStr);
  4240. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4241. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4242. designer.SetDataSource("celllastStr", celllastStr);
  4243. Workbook wb = designer.Workbook;
  4244. var sheet = wb.Worksheets[0];
  4245. //绑定datatable数据集
  4246. designer.SetDataSource(dtdac1);
  4247. designer.SetDataSource(dtdac2);
  4248. designer.Process();
  4249. var rowStart = dtdac1.Rows.Count;
  4250. while (rowStart > 0)
  4251. {
  4252. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4253. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4254. startIndex++;
  4255. rowStart--;
  4256. }
  4257. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4258. startIndex += 1; //总计行
  4259. rowStart = dtdac2.Rows.Count;
  4260. while (rowStart > 0)
  4261. {
  4262. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4263. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4264. startIndex++;
  4265. rowStart--;
  4266. }
  4267. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4268. wb.CalculateFormula(true);
  4269. //模板文件名
  4270. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls"; ;//$".xls";
  4271. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4272. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4273. return Ok(JsonView(true, "成功", new { Url = url }));
  4274. }
  4275. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4276. {
  4277. //获取模板
  4278. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4279. //载入模板
  4280. Document doc = new Document(tempPath);
  4281. DocumentBuilder builder = new DocumentBuilder(doc);
  4282. Dictionary<string, string> dic = new Dictionary<string, string>();
  4283. dic.Add("GroupName", _DelegationInfo.TeamName);
  4284. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4285. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4286. string missionLeaderJob = "";//负责人job
  4287. int groupNumber = 0; //团人数
  4288. if (DeleClientList.Count > 0)
  4289. {
  4290. missionLeader = DeleClientList[0]?.Name ?? "";
  4291. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4292. }
  4293. dic.Add("MissionLeader", missionLeader); //团负责人
  4294. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4295. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4296. #region MyRegion
  4297. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4298. //{
  4299. // List<string> list = new List<string>();
  4300. // try
  4301. // {
  4302. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4303. // foreach (var item in spilitArr)
  4304. // {
  4305. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4306. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4307. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4308. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4309. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4310. // list.Add(depName);
  4311. // list.Add(arrName);
  4312. // }
  4313. // list = list.Distinct().ToList();
  4314. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4315. // }
  4316. // catch (Exception)
  4317. // {
  4318. // dic.Add("ReturnCode", "行程录入不正确!");
  4319. // }
  4320. //}
  4321. //else
  4322. //{
  4323. // dic.Add("ReturnCode", "未录入行程!");
  4324. //}
  4325. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4326. dic.Add("ReturnCode", string.Join("、", countrys));
  4327. #endregion
  4328. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4329. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4330. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4331. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4332. //{
  4333. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4334. // dic.Add("Day", sp.Days.ToString());
  4335. //}
  4336. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4337. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4338. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4339. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4340. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4341. //培训人员名单
  4342. int cultivateRowIndex = 7;
  4343. foreach (var item in DeleClientList)
  4344. {
  4345. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4346. builder.Write(item.Name);
  4347. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4348. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4349. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4350. string birthDay = "";
  4351. if (item.Birthday != null)
  4352. {
  4353. DateTime dt = Convert.ToDateTime(item.Birthday);
  4354. birthDay = $"{dt.Year}.{dt.Month}";
  4355. }
  4356. builder.Write(birthDay);
  4357. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4358. builder.Write(item.Company);
  4359. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4360. builder.Write(item.Job);
  4361. cultivateRowIndex++;
  4362. }
  4363. //删除多余行
  4364. //cultivateRowIndex -= 2;
  4365. int delRows = 10 + 7 - cultivateRowIndex;
  4366. if (delRows > 0)
  4367. {
  4368. for (int i = 0; i < delRows; i++)
  4369. {
  4370. table1.Rows.RemoveAt(cultivateRowIndex);
  4371. //cultivateRowIndex++;
  4372. }
  4373. }
  4374. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4375. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4376. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4377. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4378. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4379. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4380. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4381. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4382. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4383. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4384. //其他费用
  4385. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4386. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4387. //其他费用合计
  4388. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4389. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4390. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4391. //公务舱合计
  4392. //国际旅费
  4393. string outsideJJ = "";
  4394. string allPriceJJ = "";
  4395. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4396. {
  4397. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4398. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4399. }
  4400. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4401. {
  4402. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4403. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4404. }
  4405. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4406. {
  4407. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4408. dic.Add("AirFeeTotal", airFeeTotalStr);
  4409. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4410. dic.Add("FeeTotal", feeTotalStr);
  4411. }
  4412. foreach (var key in dic.Keys)
  4413. {
  4414. builder.MoveToBookmark(key);
  4415. builder.Write(dic[key]);
  4416. }
  4417. //模板文件名
  4418. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4419. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4420. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4421. return Ok(JsonView(true, "成功", new { Url = url }));
  4422. }
  4423. }
  4424. else if (dto.ExportType == 2) //表格
  4425. {
  4426. //利用键值对存放数据
  4427. Dictionary<string, string> dic = new Dictionary<string, string>();
  4428. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4429. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4430. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4431. dic.Add("Day", sp.Days.ToString());
  4432. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4433. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4434. {
  4435. //获取模板
  4436. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4437. //载入模板
  4438. Document doc = new Document(tempPath);
  4439. DocumentBuilder builder = new DocumentBuilder(doc);
  4440. dic.Add("TeamName", _DelegationInfo.TeamName);
  4441. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4442. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4443. string missionLeaderName = "",
  4444. missionLeaderJob = "";
  4445. if (DeleClientList.Count > 0)
  4446. {
  4447. missionLeaderName = DeleClientList[0].Name;
  4448. missionLeaderJob = DeleClientList[0].Job;
  4449. }
  4450. dic.Add("MissionLeaderName", missionLeaderName);
  4451. dic.Add("MissionLeaderJob", missionLeaderJob);
  4452. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4453. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4454. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4455. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4456. int rowCount = 10;//总人数行
  4457. int startRowIndex = 7; //起始行
  4458. for (int i = 0; i < DeleClientList.Count; i++)
  4459. {
  4460. builder.MoveToCell(0, startRowIndex, 0, 0);
  4461. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4462. builder.MoveToCell(0, startRowIndex, 1, 0);
  4463. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4464. builder.Write(sex);//性别
  4465. builder.MoveToCell(0, startRowIndex, 2, 0);
  4466. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4467. builder.MoveToCell(0, startRowIndex, 3, 0);
  4468. builder.Write(DeleClientList[i].Company);//工作单位
  4469. builder.MoveToCell(0, startRowIndex, 4, 0);
  4470. builder.Write(DeleClientList[i].Job);//职务及级别
  4471. builder.MoveToCell(0, startRowIndex, 5, 0);
  4472. builder.Write("");//人员属性
  4473. builder.MoveToCell(0, startRowIndex, 6, 0);
  4474. builder.Write("");//上次出国时间
  4475. startRowIndex++;
  4476. }
  4477. int nullRow = rowCount - DeleClientList.Count;//空行
  4478. for (int i = 0; i < nullRow; i++)
  4479. {
  4480. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4481. }
  4482. foreach (var key in dic.Keys)
  4483. {
  4484. builder.MoveToBookmark(key);
  4485. builder.Write(dic[key]);
  4486. }
  4487. //模板文件名
  4488. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4489. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4490. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4491. return Ok(JsonView(true, "成功", new { Url = url }));
  4492. }
  4493. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4494. {
  4495. //获取模板
  4496. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4497. //载入模板
  4498. Document doc = new Document(tempPath);
  4499. DocumentBuilder builder = new DocumentBuilder(doc);
  4500. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4501. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4502. dic.Add("Names", Names);
  4503. int accommodationRows = 12, foodandotherRows = 12;
  4504. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4505. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4506. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4507. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4508. int accommodationStartIndex = 6;
  4509. decimal dac1totalPrice = 0.00M;
  4510. foreach (var dac in dac1)
  4511. {
  4512. if (dac.SubTotal == 0)
  4513. {
  4514. continue;
  4515. }
  4516. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4517. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4518. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4519. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4520. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4521. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4522. builder.Write(currency);//币种
  4523. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4524. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4525. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4526. builder.Write("");//人数
  4527. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4528. builder.Write("");//天数
  4529. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4530. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4531. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4532. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4533. builder.Write(rate.ToString("#0.0000"));//汇率
  4534. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4535. decimal rbmPrice = rate * dac.SubTotal;
  4536. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4537. accommodationStartIndex++;
  4538. dac1totalPrice += rbmPrice;
  4539. }
  4540. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4541. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4542. builder.Write("小计");
  4543. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4544. builder.Write(dac1totalPrice.ToString("#0.00"));
  4545. accommodationStartIndex++;
  4546. int nullRow = accommodationRows - dac1.Count;
  4547. //删除空行
  4548. //if (nullRow > 0)
  4549. //{
  4550. // int rowIndex = accommodationStartIndex;
  4551. // for (int i = 0; i < nullRow; i++)
  4552. // {
  4553. // Row row = table1.Rows[rowIndex];
  4554. // row.Remove();
  4555. // rowIndex++;
  4556. // }
  4557. //}
  4558. if (dac2.Count == dac3.Count)//国家 币种 金额
  4559. {
  4560. for (int i = 0; i < dac2.Count; i++)
  4561. {
  4562. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4563. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4564. }
  4565. }
  4566. int foodandotherStartIndex = 19;//
  4567. decimal dac2totalPrice = 0.00M;
  4568. foreach (var dac in dac2)
  4569. {
  4570. if (dac.SubTotal == 0)
  4571. {
  4572. continue;
  4573. }
  4574. //foodandotherStartIndex = 12;
  4575. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4576. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4577. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4578. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4579. builder.Write(currency);//币种
  4580. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4581. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4582. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4583. builder.Write("");//人数
  4584. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4585. builder.Write("");//天数
  4586. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4587. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4588. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4589. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4590. builder.Write(rate.ToString("#0.0000"));//汇率
  4591. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4592. decimal rbmPrice = rate * dac.SubTotal;
  4593. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4594. foodandotherStartIndex++;
  4595. dac2totalPrice += rbmPrice;
  4596. }
  4597. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4598. //删除空行
  4599. if (dac2.Count < foodandotherRows)
  4600. {
  4601. //int nullRow = accommodationRows - dac2.Count;
  4602. //while (table2.Rows.Count > dac2.Count)
  4603. //{
  4604. // table2.Rows.RemoveAt(dac2.Count);
  4605. //}
  4606. }
  4607. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4608. string otherFeeStr = "";
  4609. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4610. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4611. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4612. if (otherFeeStr.Length > 0)
  4613. {
  4614. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4615. otherFeeStr = $"({otherFeeStr})";
  4616. dic.Add("OtherFeeStr", otherFeeStr);
  4617. }
  4618. foreach (var key in dic.Keys)
  4619. {
  4620. builder.MoveToBookmark(key);
  4621. builder.Write(dic[key]);
  4622. }
  4623. //模板文件名
  4624. string strFileName = $"省级单位出(境)经费报销单.docx";
  4625. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4626. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4627. return Ok(JsonView(true, "成功", new { Url = url }));
  4628. }
  4629. }
  4630. else if (dto.ExportType == 3)
  4631. {
  4632. if (dto.SubTypeId == 1) //团组成员名单
  4633. {
  4634. if (DeleClientList.Count < 1)
  4635. {
  4636. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4637. }
  4638. //获取模板
  4639. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4640. //载入模板
  4641. Document doc = new Document(tempPath);
  4642. DocumentBuilder builder = new DocumentBuilder(doc);
  4643. //获取word里所有表格
  4644. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4645. //获取所填表格的序数
  4646. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4647. var rowStart = tableOne.Rows[0]; //获取第1行
  4648. //循环赋值
  4649. for (int i = 0; i < DeleClientList.Count; i++)
  4650. {
  4651. builder.MoveToCell(0, i + 1, 0, 0);
  4652. builder.Write(DeleClientList[i].Name);
  4653. builder.MoveToCell(0, i + 1, 1, 0);
  4654. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4655. builder.Write(sex);
  4656. builder.MoveToCell(0, i + 1, 2, 0);
  4657. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4658. builder.MoveToCell(0, i + 1, 3, 0);
  4659. builder.Write(DeleClientList[i].Company);
  4660. builder.MoveToCell(0, i + 1, 4, 0);
  4661. builder.Write(DeleClientList[i].Job);
  4662. }
  4663. //删除多余行
  4664. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4665. {
  4666. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4667. }
  4668. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4669. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4670. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4671. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4672. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4673. return Ok(JsonView(true, "成功", new { Url = url }));
  4674. }
  4675. }
  4676. return Ok(JsonView(false, "操作失败!"));
  4677. }
  4678. catch (Exception ex)
  4679. {
  4680. return Ok(JsonView(false, ex.Message));
  4681. }
  4682. }
  4683. /// <summary>
  4684. /// 获取三公费用标准city
  4685. /// </summary>
  4686. /// <param name="placeData"></param>
  4687. /// <param name="nationalTravelFeeId"></param>
  4688. /// <returns></returns>
  4689. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4690. {
  4691. string _city = string.Empty;
  4692. if (placeData.Count < 1) return _city;
  4693. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4694. if (data == null) return _city;
  4695. string country = data.Country;
  4696. string city = data.City;
  4697. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4698. else _city = city;
  4699. return _city;
  4700. }
  4701. /// <summary>
  4702. /// 团组模块 - 出入境费用 - 明细表导出
  4703. /// </summary>
  4704. /// <returns></returns>
  4705. [HttpPost]
  4706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4707. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4708. {
  4709. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4710. if (data.Code != 0)
  4711. {
  4712. return Ok(JsonView(false, data.Msg));
  4713. }
  4714. return Ok(JsonView(true, data.Msg, data.Data));
  4715. }
  4716. /// <summary>
  4717. /// 团组模块 - 出入境费用 - 一键清空
  4718. /// </summary>
  4719. /// <returns></returns>
  4720. [HttpPost]
  4721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4722. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4723. {
  4724. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4725. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4726. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4727. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4728. if (_view.Code == 0)
  4729. {
  4730. return Ok(JsonView(true, "操作成功"));
  4731. }
  4732. return Ok(JsonView(false, "操作失败"));
  4733. }
  4734. /// <summary>
  4735. /// 团组模块 - 出入境费用 - 子项删除
  4736. /// </summary>
  4737. /// <returns></returns>
  4738. [HttpPost]
  4739. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4740. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4741. {
  4742. try
  4743. {
  4744. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4745. if (data.Code != 0)
  4746. {
  4747. return Ok(JsonView(false, data.Msg));
  4748. }
  4749. return Ok(JsonView(true, "操作成功!", data.Data));
  4750. }
  4751. catch (Exception ex)
  4752. {
  4753. return Ok(JsonView(false, ex.Message));
  4754. }
  4755. }
  4756. /// <summary>
  4757. /// 团组模块 - 出入境国家费用标准 List
  4758. /// </summary>
  4759. /// <returns></returns>
  4760. [HttpPost]
  4761. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4762. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4763. {
  4764. try
  4765. {
  4766. Stopwatch sw = new Stopwatch();
  4767. sw.Start();
  4768. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4769. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4770. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4771. Where gntf.Isdel = 0");
  4772. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4773. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4774. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4775. //foreach (var item in nationalTravel)
  4776. //{
  4777. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4778. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4779. // if (otherData != null)
  4780. // {
  4781. // cityData.Remove(otherData);
  4782. // cityData.Add(otherData);
  4783. // }
  4784. // nationalTravelFeeData1.Add(new
  4785. // {
  4786. // Country = item.Country,
  4787. // CityData = cityData
  4788. // });
  4789. //}
  4790. sw.Stop();
  4791. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4792. }
  4793. catch (Exception ex)
  4794. {
  4795. return Ok(JsonView(false, ex.Message));
  4796. throw;
  4797. }
  4798. }
  4799. /// <summary>
  4800. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4801. /// </summary>
  4802. /// <returns></returns>
  4803. [HttpPost]
  4804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4805. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4806. {
  4807. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4808. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4809. List<string> countryData = new List<string>();
  4810. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4811. countryData = countryData.Distinct().ToList();
  4812. List<dynamic> dataSource = new List<dynamic>();
  4813. foreach (var item in countryData)
  4814. {
  4815. List<string> cityData1 = new List<string>();
  4816. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4817. var countryData2 = new
  4818. {
  4819. CountryName = item,
  4820. CityData = cityData1
  4821. };
  4822. dataSource.Add(countryData2);
  4823. }
  4824. return Ok(JsonView(true, "查询成功!", dataSource));
  4825. }
  4826. /// <summary>
  4827. /// 团组模块 - 出入境国家费用标准 Page List
  4828. /// </summary>
  4829. /// <returns></returns>
  4830. [HttpPost]
  4831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4832. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4833. {
  4834. int portId = dto.PortType;
  4835. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4836. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4837. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4838. string whereSql = string.Empty;
  4839. if (!string.IsNullOrEmpty(dto.Country))
  4840. {
  4841. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4842. }
  4843. if (!string.IsNullOrEmpty(dto.City))
  4844. {
  4845. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4846. }
  4847. string pageSql = string.Format(@"Select * From (
  4848. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4849. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4850. From Grp_NationalTravelFee gntf
  4851. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4852. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4853. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4854. RefAsync<int> total = 0;
  4855. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4856. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4857. }
  4858. /// <summary>
  4859. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4860. /// </summary>
  4861. /// <returns></returns>
  4862. [HttpPost]
  4863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4864. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4865. {
  4866. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4867. int portId = dto.PortType;
  4868. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4869. string whereSql = string.Empty;
  4870. if (!string.IsNullOrEmpty(dto.Country))
  4871. {
  4872. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4873. }
  4874. if (!string.IsNullOrEmpty(dto.City))
  4875. {
  4876. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4877. }
  4878. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4879. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4880. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4881. From Grp_NationalTravelFee gntf
  4882. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4883. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4884. Where gntf.Isdel = 0 {0} ", whereSql);
  4885. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4886. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4887. }
  4888. /// <summary>
  4889. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4890. /// </summary>
  4891. /// <returns></returns>
  4892. [HttpPost]
  4893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4894. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4895. {
  4896. try
  4897. {
  4898. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4899. if (data.Code != 0)
  4900. {
  4901. return Ok(JsonView(false, data.Msg));
  4902. }
  4903. return Ok(JsonView(true, "操作成功!", data.Data));
  4904. }
  4905. catch (Exception ex)
  4906. {
  4907. return Ok(JsonView(false, ex.Message));
  4908. }
  4909. }
  4910. /// <summary>
  4911. /// 团组模块 - 出入境国家费用标准 - Del
  4912. /// </summary>
  4913. /// <returns></returns>
  4914. [HttpPost]
  4915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4916. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4917. {
  4918. try
  4919. {
  4920. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4921. {
  4922. Id = dto.Id,
  4923. DeleteUserId = dto.DeleteUserId,
  4924. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4925. IsDel = 1
  4926. };
  4927. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4928. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4929. .WhereColumns(it => new { it.Id })
  4930. .ExecuteCommandAsync();
  4931. if (delStatus <= 0)
  4932. {
  4933. return Ok(JsonView(false, "删除失败!"));
  4934. }
  4935. return Ok(JsonView(true, "操作成功!"));
  4936. }
  4937. catch (Exception ex)
  4938. {
  4939. return Ok(JsonView(false, ex.Message));
  4940. }
  4941. }
  4942. #endregion
  4943. #region 签证费用录入
  4944. /// <summary>
  4945. /// 根据diid查询签证费用列表
  4946. /// </summary>
  4947. /// <param name="dto"></param>
  4948. /// <returns></returns>
  4949. [HttpPost]
  4950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4951. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4952. {
  4953. try
  4954. {
  4955. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4956. if (groupData.Code != 0)
  4957. {
  4958. return Ok(JsonView(false, groupData.Msg));
  4959. }
  4960. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4961. }
  4962. catch (Exception ex)
  4963. {
  4964. return Ok(JsonView(false, ex.Message));
  4965. }
  4966. }
  4967. /// <summary>
  4968. /// 根据签证费用Id查询单条数据及c表数据
  4969. /// </summary>
  4970. /// <param name="dto"></param>
  4971. /// <returns></returns>
  4972. [HttpPost]
  4973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4974. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4975. {
  4976. try
  4977. {
  4978. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4979. if (groupData.Code != 0)
  4980. {
  4981. return Ok(JsonView(false, groupData.Msg));
  4982. }
  4983. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4984. }
  4985. catch (Exception ex)
  4986. {
  4987. return Ok(JsonView(false, ex.Message));
  4988. }
  4989. }
  4990. /// <summary>
  4991. /// 签证费用删除
  4992. /// </summary>
  4993. /// <param name="dto"></param>
  4994. /// <returns></returns>
  4995. [HttpPost]
  4996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4997. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4998. {
  4999. _sqlSugar.BeginTran();
  5000. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  5001. if (!res)
  5002. {
  5003. _sqlSugar.RollbackTran();
  5004. return Ok(JsonView(false, "删除失败"));
  5005. }
  5006. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5007. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  5008. .SetColumns(a => new Grp_CreditCardPayment()
  5009. {
  5010. IsDel = 1,
  5011. DeleteUserId = dto.DeleteUserId,
  5012. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5013. }).ExecuteCommand();
  5014. if (resSub < 1)
  5015. {
  5016. _sqlSugar.RollbackTran();
  5017. return Ok(JsonView(false, "删除失败"));
  5018. }
  5019. _sqlSugar.CommitTran();
  5020. return Ok(JsonView(true, "删除成功!"));
  5021. }
  5022. /// <summary>
  5023. /// 签证费用录入下拉框初始化
  5024. /// </summary>
  5025. /// <returns></returns>
  5026. [HttpPost]
  5027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5028. public async Task<IActionResult> VisaPriceAddSelect()
  5029. {
  5030. try
  5031. {
  5032. //支付方式
  5033. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  5034. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  5035. //币种
  5036. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  5037. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  5038. //乘客类型
  5039. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  5040. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  5041. //卡类型
  5042. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  5043. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  5044. var data = new
  5045. {
  5046. Payment = _Payment,
  5047. CurrencyList = _CurrencyList,
  5048. PassengerType = _PassengerType,
  5049. BankCard = _BankCard
  5050. };
  5051. return Ok(JsonView(true, "查询成功!", data));
  5052. }
  5053. catch (Exception ex)
  5054. {
  5055. return Ok(JsonView(false, "程序错误!"));
  5056. throw;
  5057. }
  5058. }
  5059. /// <summary>
  5060. /// 签证费用录入操作(Status:1.新增,2.修改)
  5061. /// </summary>
  5062. /// <param name="dto"></param>
  5063. /// <returns></returns>
  5064. [HttpPost]
  5065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5066. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  5067. {
  5068. try
  5069. {
  5070. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  5071. if (groupData.Code != 0)
  5072. {
  5073. return Ok(JsonView(false, groupData.Msg));
  5074. }
  5075. #region 应用推送
  5076. try
  5077. {
  5078. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5079. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5080. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5081. }
  5082. catch (Exception ex)
  5083. {
  5084. }
  5085. #endregion
  5086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5087. }
  5088. catch (Exception ex)
  5089. {
  5090. return Ok(JsonView(false, ex.Message));
  5091. }
  5092. }
  5093. #endregion
  5094. #region op费用录入
  5095. /// <summary>
  5096. /// 根据diid查询op费用列表
  5097. /// </summary>
  5098. /// <param name="dto"></param>
  5099. /// <returns></returns>
  5100. [HttpPost]
  5101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5102. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  5103. {
  5104. try
  5105. {
  5106. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  5107. if (groupData.Code != 0)
  5108. {
  5109. return Ok(JsonView(false, groupData.Msg));
  5110. }
  5111. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5112. }
  5113. catch (Exception ex)
  5114. {
  5115. return Ok(JsonView(false, ex.Message));
  5116. }
  5117. }
  5118. /// <summary>
  5119. /// 根据op费用Id查询单条数据及c表数据
  5120. /// </summary>
  5121. /// <param name="dto"></param>
  5122. /// <returns></returns>
  5123. [HttpPost]
  5124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5125. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  5126. {
  5127. try
  5128. {
  5129. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  5130. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  5131. var data = new
  5132. {
  5133. CarTouristGuideGround = _groupData,
  5134. CreditCardPayment = _creditCardPayment
  5135. };
  5136. return Ok(JsonView(true, "查询成功!", data));
  5137. }
  5138. catch (Exception ex)
  5139. {
  5140. return Ok(JsonView(false, "程序错误!"));
  5141. }
  5142. }
  5143. /// <summary>
  5144. /// op费用删除
  5145. /// </summary>
  5146. /// <param name="dto"></param>
  5147. /// <returns></returns>
  5148. [HttpPost]
  5149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5150. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  5151. {
  5152. try
  5153. {
  5154. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5155. if (!res)
  5156. {
  5157. return Ok(JsonView(false, "删除失败"));
  5158. }
  5159. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  5160. {
  5161. IsDel = 1,
  5162. DeleteUserId = dto.DeleteUserId,
  5163. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5164. }).ExecuteCommandAsync();
  5165. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  5166. {
  5167. IsDel = 1,
  5168. DeleteUserId = dto.DeleteUserId,
  5169. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5170. }).ExecuteCommandAsync();
  5171. return Ok(JsonView(true, "删除成功!"));
  5172. }
  5173. catch (Exception ex)
  5174. {
  5175. return Ok(JsonView(false, "程序错误!"));
  5176. throw;
  5177. }
  5178. }
  5179. /// <summary>
  5180. /// op费用录入操作(Status:1.新增,2.修改)
  5181. /// </summary>
  5182. /// <param name="dto"></param>
  5183. /// <returns></returns>
  5184. [HttpPost]
  5185. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5186. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5187. {
  5188. try
  5189. {
  5190. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5191. if (groupData.Code != 0)
  5192. {
  5193. return Ok(JsonView(false, groupData.Msg));
  5194. }
  5195. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5196. }
  5197. catch (Exception ex)
  5198. {
  5199. return Ok(JsonView(false, ex.Message));
  5200. }
  5201. }
  5202. /// <summary>
  5203. /// 填写费用详细页面初始化绑定
  5204. /// </summary>
  5205. /// <param name="dto"></param>
  5206. /// <returns></returns>
  5207. [HttpPost]
  5208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5209. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5210. {
  5211. try
  5212. {
  5213. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5214. if (groupData.Code != 0)
  5215. {
  5216. return Ok(JsonView(false, groupData.Msg));
  5217. }
  5218. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5219. }
  5220. catch (Exception ex)
  5221. {
  5222. return Ok(JsonView(false, ex.Message));
  5223. }
  5224. }
  5225. /// <summary>
  5226. /// 根据op费用Id查询详细数据
  5227. /// </summary>
  5228. /// <param name="dto"></param>
  5229. /// <returns></returns>
  5230. [HttpPost]
  5231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5232. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5233. {
  5234. try
  5235. {
  5236. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5237. if (groupData.Code != 0)
  5238. {
  5239. return Ok(JsonView(false, groupData.Msg));
  5240. }
  5241. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5242. }
  5243. catch (Exception ex)
  5244. {
  5245. return Ok(JsonView(false, ex.Message));
  5246. }
  5247. }
  5248. /// <summary>
  5249. /// OP费用录入填写详情
  5250. /// </summary>
  5251. /// <param name="dto"></param>
  5252. /// <returns></returns>
  5253. [HttpPost]
  5254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5255. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5256. {
  5257. try
  5258. {
  5259. #region 参数校验
  5260. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5261. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5262. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5263. #endregion
  5264. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5265. if (groupData.Code != 0)
  5266. {
  5267. return Ok(JsonView(false, groupData.Msg));
  5268. }
  5269. //自动审核
  5270. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  5271. #region 应用推送
  5272. try
  5273. {
  5274. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5275. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5276. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5277. }
  5278. catch (Exception ex)
  5279. {
  5280. }
  5281. #endregion
  5282. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5283. }
  5284. catch (Exception ex)
  5285. {
  5286. return Ok(JsonView(false, ex.Message));
  5287. }
  5288. }
  5289. /// <summary>
  5290. /// 获取三公详细所有城市
  5291. /// </summary>
  5292. /// <returns></returns>
  5293. [HttpGet]
  5294. public IActionResult OpCarCityResult()
  5295. {
  5296. var jw = JsonView(false);
  5297. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5298. {
  5299. x.Id,
  5300. x.Country,
  5301. x.City,
  5302. }).ToList();
  5303. if (data.Count > 0)
  5304. {
  5305. jw = JsonView(true, "获取成功!", data);
  5306. }
  5307. else
  5308. {
  5309. jw.Msg = "城市数据为空!";
  5310. jw.Data = new string[0];
  5311. }
  5312. return Ok(jw);
  5313. }
  5314. /// <summary>
  5315. /// 导出地接费用明细
  5316. /// </summary>
  5317. /// <param name="dto"></param>
  5318. /// <returns></returns>
  5319. [HttpPost]
  5320. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5321. {
  5322. var jw = JsonView(false);
  5323. if (dto.Diid < 1)
  5324. {
  5325. jw.Msg = "请输入正确的diid!";
  5326. return Ok(jw);
  5327. }
  5328. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5329. if (group == null)
  5330. {
  5331. jw.Msg = "未找到团组信息!";
  5332. return Ok(jw);
  5333. }
  5334. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5335. if (localGuideArr.Count == 0)
  5336. {
  5337. jw.Msg = "该团组暂无地接信息!";
  5338. return Ok(jw);
  5339. }
  5340. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5341. var overspendSoure = new Dictionary<int, int>
  5342. {
  5343. { 91, 982 }, //车
  5344. { 92 , 1059} ,//导游
  5345. { 994 , 1073}, //翻译
  5346. { 988 , 1074 }, //早餐
  5347. { 93 , 1075 }, //午餐
  5348. { 989 , 1076 }, //晚餐
  5349. };
  5350. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5351. foreach (var groupArr in localGroup)
  5352. {
  5353. var keyValue = groupArr.Key;
  5354. if (int.TryParse(keyValue, out int cityid))
  5355. {
  5356. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5357. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5358. }
  5359. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5360. foreach (var item in groupArr)
  5361. {
  5362. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5363. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5364. new Grp_CarTouristGuideGroundReservationsContentExtend
  5365. {
  5366. Count = a.Count,
  5367. CreateTime = a.CreateTime,
  5368. CreateUserId = a.CreateUserId,
  5369. CTGGRId = a.CTGGRId,
  5370. Currency = a.Currency,
  5371. DatePrice = a.DatePrice,
  5372. DeleteTime = a.DeleteTime,
  5373. DeleteUserId = a.DeleteUserId,
  5374. DiId = a.DiId,
  5375. Id = a.Id,
  5376. IsDel = a.IsDel,
  5377. Price = a.Price,
  5378. PriceContent = a.PriceContent,
  5379. Remark = a.Remark,
  5380. SId = a.SId,
  5381. SidName = b.Name,
  5382. Units = a.Units,
  5383. }
  5384. ).ToList();
  5385. if (content.Count > 0)
  5386. {
  5387. contentArr.Add(content);
  5388. }
  5389. }
  5390. //open excel
  5391. //set excel
  5392. //save excel
  5393. try
  5394. {
  5395. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5396. IWorkbook workbook;
  5397. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5398. {
  5399. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5400. }
  5401. else
  5402. {
  5403. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5404. }
  5405. ISheet sheet = workbook.GetSheetAt(0);
  5406. var rowStartIndex = 2;
  5407. var clounmCount = 10;
  5408. var initStyleRow = sheet.GetRow(2);
  5409. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5410. //var overspendArrDetail =
  5411. var existsId = new List<CarCompare>();
  5412. var lastElem = arr.Last();
  5413. var thisSid = -1;
  5414. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5415. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5416. {
  5417. Name = "未知币种!",
  5418. Remark = "未知币种!",
  5419. };
  5420. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5421. Action cloneRowFn = () =>
  5422. {
  5423. rowStartIndex++;
  5424. var cloneRow = sheet.CreateRow(rowStartIndex);
  5425. // 复制样式
  5426. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5427. {
  5428. ICell sourceCell = initStyleRow.GetCell(i);
  5429. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5430. // 确保单元格存在样式
  5431. if (sourceCell.CellStyle != null)
  5432. {
  5433. targetCell.CellStyle = sourceCell.CellStyle;
  5434. }
  5435. }
  5436. };
  5437. var mergeRow = () =>
  5438. {
  5439. for (int i = 2; i < sheet.LastRowNum; i++)
  5440. {
  5441. var row = sheet.GetRow(i);
  5442. var cellFirst = row.GetCell(0);
  5443. var thisIndex = i + 1;
  5444. while (thisIndex < sheet.LastRowNum)
  5445. {
  5446. var nextRow = sheet.GetRow(thisIndex);
  5447. var nextCellFirst = nextRow.GetCell(0);
  5448. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5449. {
  5450. thisIndex++;
  5451. }
  5452. else
  5453. {
  5454. break;
  5455. }
  5456. }
  5457. thisIndex--;
  5458. if (thisIndex != i)
  5459. {
  5460. //合并row
  5461. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5462. i, // 起始行索引(0-based)
  5463. thisIndex, // 结束行索引(0-based)
  5464. 0, // 起始列索引(0-based)
  5465. 0 // 结束列索引(0-based)
  5466. );
  5467. sheet.AddMergedRegion(cellRangeAddress);
  5468. i = thisIndex;
  5469. }
  5470. }
  5471. };
  5472. var chaoshiNumber = 0;
  5473. var totalNumber = 0.00M;
  5474. string lastStr = "";
  5475. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5476. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5477. {
  5478. b.IsAuditGM,
  5479. x.Id,
  5480. x.Area,
  5481. b.PayPercentage,
  5482. b.PayMoney,
  5483. }).ToList();
  5484. string yesPayment = "", noPayment = "";
  5485. foreach (var item in queryCarArrByCityAndDiid)
  5486. {
  5487. if (item.IsAuditGM == 1)
  5488. {
  5489. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5490. }
  5491. else
  5492. {
  5493. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5494. }
  5495. }
  5496. lastStr = yesPayment + noPayment;
  5497. foreach (var item in arr)
  5498. {
  5499. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5500. {
  5501. if (thisSid != item.SId)
  5502. {
  5503. if (thisSid == -1)
  5504. {
  5505. thisSid = item.SId;
  5506. }
  5507. else
  5508. {
  5509. //合并小计行
  5510. //创建合并区域的实例
  5511. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5512. rowStartIndex, // 起始行索引(0-based)
  5513. rowStartIndex, // 结束行索引(0-based)
  5514. 0, // 起始列索引(0-based)
  5515. 3 // 结束列索引(0-based)
  5516. );
  5517. sheet.AddMergedRegion(cellRangeAddress);
  5518. var CellStyle = workbook.CreateCellStyle();
  5519. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5520. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5521. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5522. for (int i = 0; i <= clounmCount; i++)
  5523. {
  5524. if (i > 6)
  5525. {
  5526. var CellStyle1 = workbook.CreateCellStyle();
  5527. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5528. IFont Font = workbook.CreateFont(); // 创建字体
  5529. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5530. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5531. CellStyle1.SetFont(Font);
  5532. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5533. }
  5534. else
  5535. {
  5536. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5537. }
  5538. }
  5539. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5540. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5541. //超时合计
  5542. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5543. //超时数
  5544. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5545. //超时合计费用
  5546. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5547. thisSid = item.SId;
  5548. cloneRowFn();
  5549. chaoshiNumber = 0;
  5550. totalNumber = 0;
  5551. }
  5552. }
  5553. IRow row = sheet.GetRow(rowStartIndex);
  5554. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5555. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5556. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5557. if (isOpenOverspendSoure)
  5558. {
  5559. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5560. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5561. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5562. }
  5563. for (int i = 0; i <= clounmCount; i++)
  5564. {
  5565. var cell = row.GetCell(i);
  5566. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5567. if (cell == null)
  5568. {
  5569. cell = row.CreateCell(i);
  5570. }
  5571. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5572. fontRed.CloneStyleFrom(cell.CellStyle);
  5573. IFont Font = workbook.CreateFont(); // 创建字体
  5574. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5575. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5576. fontRed.SetFont(Font);
  5577. byte[] rgb = new byte[3] { 255, 242, 204 };
  5578. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5579. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5580. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5581. if (workbook is XSSFWorkbook)
  5582. {
  5583. BackgroundColor255_242_204.FillForegroundColor = 0;
  5584. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5585. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5586. }
  5587. else
  5588. {
  5589. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5590. }
  5591. if (i == 1 || i > 6)
  5592. {
  5593. if (i > 6)
  5594. {
  5595. fontRed.FillForegroundColor = 0;
  5596. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5597. fontRed.FillPattern = FillPattern.SolidForeground;
  5598. }
  5599. cell.CellStyle = fontRed;
  5600. }
  5601. if (i > 2 && i < 7)
  5602. {
  5603. cell.CellStyle = BackgroundColor255_242_204;
  5604. }
  5605. cell.SetCellValue(setCellValue); //写入单元格
  5606. }
  5607. if (overspendSoure.ContainsKey(thisSid))
  5608. {
  5609. var overspendId = overspendSoure[thisSid];
  5610. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5611. }
  5612. cloneRowFn();
  5613. existsId.Add(new CarCompare
  5614. {
  5615. DataPrice = item.DatePrice.ObjToDate(),
  5616. Sid = item.SId
  5617. });
  5618. }
  5619. if (item.Equals(lastElem))
  5620. {
  5621. //合并小计行
  5622. //创建合并区域的实例
  5623. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5624. rowStartIndex, // 起始行索引(0-based)
  5625. rowStartIndex, // 结束行索引(0-based)
  5626. 0, // 起始列索引(0-based)
  5627. 3 // 结束列索引(0-based)
  5628. );
  5629. sheet.AddMergedRegion(cellRangeAddress);
  5630. var CellStyle = workbook.CreateCellStyle();
  5631. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5632. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5633. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5634. for (int i = 0; i <= clounmCount; i++)
  5635. {
  5636. if (i > 6)
  5637. {
  5638. var CellStyle1 = workbook.CreateCellStyle();
  5639. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5640. IFont Font = workbook.CreateFont(); // 创建字体
  5641. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5642. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5643. CellStyle1.SetFont(Font);
  5644. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5645. }
  5646. else
  5647. {
  5648. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5649. }
  5650. }
  5651. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5652. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5653. //超时合计
  5654. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5655. //超时数
  5656. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5657. //超时合计费用
  5658. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5659. cloneRowFn();
  5660. // 创建合并区域的实例
  5661. cellRangeAddress = new CellRangeAddress(
  5662. rowStartIndex, // 起始行索引(0-based)
  5663. rowStartIndex, // 结束行索引(0-based)
  5664. 0, // 起始列索引(0-based)
  5665. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5666. );
  5667. // 添加合并区域
  5668. sheet.AddMergedRegion(cellRangeAddress);
  5669. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5670. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5671. }
  5672. }
  5673. mergeRow();
  5674. // 保存修改后的Excel文件到新文件
  5675. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5676. // new FileStream(newFilePath, FileMode.CreateNew)
  5677. using (var stream = new MemoryStream())
  5678. {
  5679. workbook.Write(stream, true);
  5680. stream.Flush();
  5681. stream.Seek(0, SeekOrigin.Begin);
  5682. MemoryStream memoryStream = new MemoryStream();
  5683. stream.CopyTo(memoryStream);
  5684. memoryStream.Seek(0, SeekOrigin.Begin);
  5685. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5686. }
  5687. workbook.Close();
  5688. workbook.Dispose();
  5689. }
  5690. catch (Exception ex)
  5691. {
  5692. jw.Msg = "出现异常!" + ex.Message;
  5693. return Ok(jw);
  5694. }
  5695. }
  5696. if (Zips.Count > 0)
  5697. {
  5698. IOOperatorHelper io = new IOOperatorHelper();
  5699. var byts = io.ConvertZipStream(Zips);
  5700. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5701. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5702. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5703. }
  5704. else
  5705. {
  5706. jw.Msg = "暂无生成文件!";
  5707. }
  5708. return Ok(jw);
  5709. }
  5710. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5711. {
  5712. string outStr = string.Empty;
  5713. switch (i)
  5714. {
  5715. case 0:
  5716. outStr = arr[0].SidName;
  5717. break;
  5718. case 1:
  5719. outStr = arr[0].DataPriceStr;
  5720. break;
  5721. case 2:
  5722. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5723. break;
  5724. case 4:
  5725. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5726. break;
  5727. case 7:
  5728. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5729. {
  5730. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5731. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5732. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5733. }
  5734. break;
  5735. case 8:
  5736. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5737. {
  5738. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5739. }
  5740. break;
  5741. case 9:
  5742. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5743. {
  5744. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5745. }
  5746. break;
  5747. case 10:
  5748. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5749. {
  5750. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5751. }
  5752. break;
  5753. }
  5754. return outStr;
  5755. }
  5756. #region OP行程单
  5757. /// <summary>
  5758. /// OP行程单初始化
  5759. /// </summary>
  5760. /// <param name="dto"></param>
  5761. /// <returns></returns>
  5762. [HttpPost]
  5763. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5764. {
  5765. var jw = JsonView(false);
  5766. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5767. var group = groupList.First();
  5768. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5769. if (group == null)
  5770. {
  5771. jw.Msg = "暂无团组!";
  5772. return Ok(jw);
  5773. }
  5774. group = groupList.Find(x => x.Id == diid);
  5775. if (group == null)
  5776. {
  5777. jw.Msg = "请输入正确的团组ID!";
  5778. return Ok(jw);
  5779. }
  5780. string city = string.Empty;
  5781. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5782. if (blackCode.Count > 0)
  5783. {
  5784. var black = blackCode.First();
  5785. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5786. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5787. if (blackSp.Length > 0)
  5788. {
  5789. try
  5790. {
  5791. var cityArrCode = new List<string>(20);
  5792. foreach (var item in blackSp)
  5793. {
  5794. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5795. var IndexSelect = itemSp[2];
  5796. var cityArrCodeLength = cityArrCode.Count - 1;
  5797. var startCity = IndexSelect.Substring(0, 3);
  5798. if (cityArrCodeLength > 0)
  5799. {
  5800. var arrEndCity = cityArrCode[cityArrCodeLength];
  5801. if (arrEndCity != startCity)
  5802. {
  5803. cityArrCode.Add(startCity.ToUpper());
  5804. }
  5805. }
  5806. else
  5807. {
  5808. cityArrCode.Add(startCity.ToUpper());
  5809. }
  5810. var endCity = IndexSelect.Substring(3, 3);
  5811. cityArrCode.Add(endCity.ToUpper());
  5812. }
  5813. var cityThree = string.Empty;
  5814. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5815. cityThree = cityThree.TrimEnd(',');
  5816. if (string.IsNullOrWhiteSpace(cityThree))
  5817. {
  5818. throw new
  5819. Exception("error");
  5820. }
  5821. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5822. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5823. foreach (var item in cityArrCode)
  5824. {
  5825. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5826. if (find != null)
  5827. {
  5828. city += find.City + "/";
  5829. }
  5830. else
  5831. {
  5832. city += item + "三字码未收入/";
  5833. }
  5834. }
  5835. city = city.TrimEnd('/');
  5836. }
  5837. catch (Exception e)
  5838. {
  5839. city = "黑屏代码格式不正确!";
  5840. }
  5841. }
  5842. }
  5843. else
  5844. {
  5845. city = "未录入黑屏代码";
  5846. }
  5847. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5848. {
  5849. Date = x.Date,
  5850. Days = x.Days,
  5851. Diffgroup = x.Diffgroup,
  5852. Diid = x.Diid,
  5853. Traffic_First = x.Traffic_First,
  5854. Traffic_Second = x.Traffic_Second,
  5855. Trip = x.Trip,
  5856. WeekDay = x.WeekDay,
  5857. Id = x.Id
  5858. }).ToList();
  5859. jw.Data = new
  5860. {
  5861. groupList = groupList.Select(x => new
  5862. {
  5863. x.Id,
  5864. x.TeamName,
  5865. x.TourCode
  5866. }).ToList(),
  5867. groupInfo = new
  5868. {
  5869. group.VisitDays,
  5870. group.TourCode,
  5871. group.VisitPNumber,
  5872. group.TeamName,
  5873. city
  5874. },
  5875. OpTravelList
  5876. };
  5877. jw.Code = 200;
  5878. jw.Msg = "操作成功!";
  5879. return Ok(jw);
  5880. }
  5881. /// <summary>
  5882. /// 删除团组行程单
  5883. /// </summary>
  5884. /// <returns></returns>
  5885. [HttpPost]
  5886. public IActionResult DelTravel(DelOpTravelDto dto)
  5887. {
  5888. var jw = JsonView(false);
  5889. if (dto.UserId <= 0 || dto.Diid <= 0)
  5890. {
  5891. jw.Msg = "请输入正确的参数!";
  5892. return Ok(jw);
  5893. }
  5894. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5895. .SetColumns(x => new Grp_TravelList
  5896. {
  5897. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5898. DeleteUserId = dto.UserId,
  5899. IsDel = 1,
  5900. }).ExecuteCommand();
  5901. jw = JsonView(true);
  5902. return Ok(jw);
  5903. }
  5904. /// <summary>
  5905. /// 行程单保存
  5906. /// </summary>
  5907. /// <returns></returns>
  5908. [HttpPost]
  5909. public IActionResult TravelSave(TravelSaveDto dto)
  5910. {
  5911. var jw = JsonView(false);
  5912. if (dto.Arr.Count > 0)
  5913. {
  5914. try
  5915. {
  5916. _sqlSugar.BeginTran();
  5917. foreach (var item in dto.Arr)
  5918. {
  5919. if (item.Id == 0)
  5920. {
  5921. throw new Exception("请传入正确的Id");
  5922. }
  5923. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5924. .SetColumns(x => new Grp_TravelList
  5925. {
  5926. Trip = item.Trip
  5927. }).ExecuteCommand();
  5928. }
  5929. _sqlSugar.CommitTran();
  5930. jw = JsonView(true);
  5931. }
  5932. catch (Exception ex)
  5933. {
  5934. _sqlSugar.RollbackTran();
  5935. jw.Msg = "程序异常!" + ex.Message;
  5936. }
  5937. }
  5938. else
  5939. {
  5940. jw.Msg = "请传入正确的参数!";
  5941. }
  5942. return Ok(jw);
  5943. }
  5944. /// <summary>
  5945. /// 导出行程单
  5946. /// </summary>
  5947. /// <param name="dto"></param>
  5948. /// <returns></returns>
  5949. [HttpPost]
  5950. public IActionResult ExportTravel(ExportTravelDto dto)
  5951. {
  5952. var jw = JsonView(false);
  5953. jw.Data = "";
  5954. int diid = 0;
  5955. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5956. if (Find == null)
  5957. {
  5958. jw.Msg = "请选择正确的团组!";
  5959. return Ok(jw);
  5960. }
  5961. else
  5962. {
  5963. diid = Find.Id;
  5964. }
  5965. //数据源
  5966. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5967. DataTable dtBlack = null;
  5968. try
  5969. {
  5970. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  5971. }
  5972. catch (Exception)
  5973. {
  5974. jw.Msg = "机票黑屏代码有误!";
  5975. return Ok(jw);
  5976. }
  5977. string CityStr = string.Empty;
  5978. if (dtBlack.Rows.Count == 0)
  5979. {
  5980. jw.Msg = "机票黑屏代码有误!";
  5981. return Ok(jw);
  5982. }
  5983. else
  5984. {
  5985. foreach (DataRow row in dtBlack.Rows)
  5986. {
  5987. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  5988. {
  5989. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  5990. return Ok(jw);
  5991. }
  5992. }
  5993. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  5994. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  5995. }
  5996. //创建数据源Table
  5997. DataTable dtSource = new DataTable();
  5998. dtSource.Columns.Add("Days", typeof(string));
  5999. dtSource.Columns.Add("Date", typeof(string));
  6000. dtSource.Columns.Add("Week", typeof(string));
  6001. dtSource.Columns.Add("Traffic", typeof(string));
  6002. dtSource.Columns.Add("Trip", typeof(string));
  6003. //获取数据,放到datatable
  6004. foreach (var item in _travelList)
  6005. {
  6006. DataRow dr = dtSource.NewRow();
  6007. dr["Days"] = item.Days;
  6008. dr["Date"] = item.Date;
  6009. dr["Week"] = item.WeekDay;
  6010. dr["Traffic"] = item.Traffic_First
  6011. + "\r\n"
  6012. + item.Traffic_Second;
  6013. dr["Trip"] = item.Trip;
  6014. dtSource.Rows.Add(dr);
  6015. }
  6016. Dictionary<string, string> dic = new Dictionary<string, string>();
  6017. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  6018. dic.Add("City", CityStr);
  6019. dic.Add("Days", Find.VisitDays.ToString());
  6020. dic.Add("DeleCode", Find.TourCode);
  6021. dic.Add("Pnum", Find.VisitPNumber.ToString());
  6022. //模板路径
  6023. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  6024. //载入模板
  6025. Document doc = null;
  6026. DocumentBuilder builder = null;
  6027. try
  6028. {
  6029. //载入模板
  6030. doc = new Document(tempPath);
  6031. builder = new DocumentBuilder(doc);
  6032. }
  6033. catch (Exception)
  6034. {
  6035. jw.Msg = "模板位置不存在!";
  6036. return Ok(jw);
  6037. }
  6038. foreach (var key in dic.Keys)
  6039. {
  6040. Bookmark bookmark = doc.Range.Bookmarks[key];
  6041. if (bookmark != null)
  6042. {
  6043. builder.MoveToBookmark(key);
  6044. builder.Write(dic[key]);
  6045. }
  6046. }
  6047. //获取word里所有表格
  6048. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6049. //获取所填表格的序数
  6050. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6051. try
  6052. {
  6053. //循环赋值
  6054. for (int i = 0; i < dtSource.Rows.Count; i++)
  6055. {
  6056. builder.MoveToCell(0, i + 1, 0, 0);
  6057. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6058. builder.MoveToCell(0, i + 1, 1, 0);
  6059. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6060. builder.MoveToCell(0, i + 1, 2, 0);
  6061. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6062. var trip = dtSource.Rows[i]["Trip"].ToString();
  6063. builder.MoveToCell(0, i + 1, 3, 0);
  6064. builder.Write(trip);
  6065. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6066. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6067. // 获取特定索引的段落
  6068. Paragraph paragraph = (Paragraph)paragraphs[0];
  6069. Run run = paragraph.Runs[0];
  6070. Aspose.Words.Font font = run.Font;
  6071. font.Name = "黑体";
  6072. //设置双休红色
  6073. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6074. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6075. paragraph = (Paragraph)paragraphs[1];
  6076. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6077. {
  6078. run = paragraph.Runs[0];
  6079. font = run.Font;
  6080. font.Color = Color.Red;
  6081. }
  6082. }
  6083. }
  6084. catch (Exception ex)
  6085. {
  6086. }
  6087. //删除多余行
  6088. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6089. {
  6090. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6091. }
  6092. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6093. if (!Directory.Exists(savePath))
  6094. {
  6095. try
  6096. {
  6097. Directory.CreateDirectory(savePath);
  6098. }
  6099. catch
  6100. {
  6101. }
  6102. }
  6103. string path = savePath + Find.TeamName + "出访日程";
  6104. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  6105. try
  6106. {
  6107. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  6108. string postfix = ".docx";
  6109. if (dto.IsPDF == 1)
  6110. {
  6111. saveFormat = Aspose.Words.SaveFormat.Pdf;
  6112. postfix = ".pdf";
  6113. }
  6114. doc.Save(path + postfix, saveFormat);
  6115. jw = JsonView(true, "导出成功", ftpPath + postfix);
  6116. }
  6117. catch (Exception)
  6118. {
  6119. jw = JsonView(false);
  6120. }
  6121. return Ok(jw);
  6122. }
  6123. /// <summary>
  6124. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6125. /// </summary>
  6126. /// <param name="num"></param>
  6127. /// <returns></returns>
  6128. string GetNum(string num)
  6129. {
  6130. string str = "";
  6131. switch (num)
  6132. {
  6133. case "1":
  6134. str = "一";
  6135. break;
  6136. case "2":
  6137. str = "二";
  6138. break;
  6139. case "3":
  6140. str = "三";
  6141. break;
  6142. case "4":
  6143. str = "四";
  6144. break;
  6145. case "5":
  6146. str = "五";
  6147. break;
  6148. case "6":
  6149. str = "六";
  6150. break;
  6151. case "7":
  6152. str = "七";
  6153. break;
  6154. case "8":
  6155. str = "八";
  6156. break;
  6157. case "9":
  6158. str = "九";
  6159. break;
  6160. case "10":
  6161. str = "十";
  6162. break;
  6163. case "11":
  6164. str = "十一";
  6165. break;
  6166. case "12":
  6167. str = "十二";
  6168. break;
  6169. case "一":
  6170. str = "1";
  6171. break;
  6172. case "二":
  6173. str = "2";
  6174. break;
  6175. case "三":
  6176. str = "3";
  6177. break;
  6178. case "四":
  6179. str = "4";
  6180. break;
  6181. case "五":
  6182. str = "5";
  6183. break;
  6184. case "六":
  6185. str = "6";
  6186. break;
  6187. case "七":
  6188. str = "7";
  6189. break;
  6190. case "八":
  6191. str = "8";
  6192. break;
  6193. case "九":
  6194. str = "9";
  6195. break;
  6196. case "十":
  6197. str = "10";
  6198. break;
  6199. case "十一":
  6200. str = "11";
  6201. break;
  6202. case "十二":
  6203. str = "12";
  6204. break;
  6205. }
  6206. return str;
  6207. }
  6208. #endregion
  6209. #endregion
  6210. #region 团组成本
  6211. /// <summary>
  6212. /// 团组成本数据初始化
  6213. /// </summary>
  6214. /// <param name="dto"></param>
  6215. /// <returns></returns>
  6216. [HttpPost]
  6217. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6218. {
  6219. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6220. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6221. WHEN COUNT(*) >= 0 THEN 'True'
  6222. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6223. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6224. ").ToList(); //团组列表
  6225. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6226. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6227. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6228. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6229. if (groupinfoValue != null)
  6230. {
  6231. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6232. var spArr = new string[1] { countryArr };
  6233. if (countryArr.Contains("|"))
  6234. {
  6235. spArr = countryArr.Split("|");
  6236. }
  6237. else if (countryArr.Contains("、"))
  6238. {
  6239. spArr = countryArr.Split("、");
  6240. }
  6241. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6242. {
  6243. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6244. if (dbQueryCountry != null)
  6245. {
  6246. visaCountryInfoArr.Add(dbQueryCountry);
  6247. }
  6248. }
  6249. }
  6250. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6251. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6252. var create = _GroupCostRepository.
  6253. CreateGroupCostByBlackCode(dto.Diid);
  6254. if (groupCost.Count == 0 && create.Code == 0)
  6255. {
  6256. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6257. }
  6258. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6259. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6260. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6261. groupCostMap = groupCostMap.Select(x =>
  6262. {
  6263. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6264. {
  6265. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6266. }
  6267. return x;
  6268. }).ToList();
  6269. //GroupCostParameter.Add(new
  6270. // Grp_GroupCostParameter());
  6271. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6272. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6273. return Ok(JsonView(new
  6274. {
  6275. groupList,
  6276. groupInfo,
  6277. groupChecks,
  6278. groupCost = groupCostMap,
  6279. hotelNumber,
  6280. GroupCostParameter = GroupCostParameterMap,
  6281. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6282. {
  6283. x.VisaCountry,
  6284. x.VisaPrice,
  6285. x.Id,
  6286. }).ToList(),
  6287. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6288. blackCodeIsTrue = create.Code == 0 ? true : false,
  6289. hotelIsTrue = hotelIsTrue,
  6290. }));
  6291. }
  6292. /// <summary>
  6293. /// 团组成本信息保存
  6294. /// </summary>
  6295. /// <param name="dto"></param>
  6296. /// <returns></returns>
  6297. [HttpPost]
  6298. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6299. {
  6300. if (dto.Diid <= 0 || dto.Userid <= 0)
  6301. {
  6302. return Ok(JsonView(false));
  6303. }
  6304. JsonView jw = null;
  6305. bool isTrue = false;
  6306. #region 复制团组成本
  6307. //if (dto.Diid == 2581)
  6308. //{
  6309. // dto.Diid = 2599;
  6310. // dto.CheckBoxs.ForEach(x =>
  6311. // {
  6312. // x.Diid = 2599;
  6313. // });
  6314. // dto.GroupCosts.ForEach(x =>
  6315. // {
  6316. // x.Diid = 2599;
  6317. // });
  6318. // dto.CostTypeHotelNumbers.ForEach(x =>
  6319. // {
  6320. // x.Diid = 2599;
  6321. // });
  6322. // dto.GroupCostParameters.ForEach(x =>
  6323. // {
  6324. // x.DiId = 2599;
  6325. // });
  6326. //}
  6327. #endregion
  6328. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6329. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6330. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6331. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6332. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6333. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6334. try
  6335. {
  6336. _sqlSugar.BeginTran();
  6337. isTrue = await _GroupCostRepository.
  6338. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6339. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6340. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6341. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6342. _sqlSugar.CommitTran();
  6343. jw = JsonView(true, "保存成功!", isTrue);
  6344. }
  6345. catch (Exception)
  6346. {
  6347. _sqlSugar.RollbackTran();
  6348. jw = JsonView(false);
  6349. }
  6350. return Ok(jw);
  6351. }
  6352. /// <summary>
  6353. /// 司兼导数据
  6354. /// </summary>
  6355. /// <param name="dto"></param>
  6356. /// <returns></returns>
  6357. [HttpPost]
  6358. public IActionResult GetCarGuides(CarGuidesDto dto)
  6359. {
  6360. JsonView jw = null;
  6361. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6362. jw = JsonView(true, "获取成功!", Data);
  6363. return Ok(jw);
  6364. }
  6365. /// <summary>
  6366. /// 导游数据
  6367. /// </summary>
  6368. /// <param name="dto"></param>
  6369. /// <returns></returns>
  6370. [HttpPost]
  6371. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6372. {
  6373. JsonView jw = null;
  6374. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6375. // 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
  6376. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6377. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6378. jw = JsonView(true, "获取成功!", Data);
  6379. return Ok(jw);
  6380. }
  6381. /// <summary>
  6382. /// 成本车数据
  6383. /// </summary>
  6384. /// <param name="dto"></param>
  6385. /// <returns></returns>
  6386. [HttpPost]
  6387. public IActionResult GetCarInfo(CarGuidesDto dto)
  6388. {
  6389. JsonView jw = null;
  6390. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6391. jw = JsonView(true, "获取成功!", Data);
  6392. return Ok(jw);
  6393. }
  6394. /// <summary>
  6395. /// 景点数据
  6396. /// </summary>
  6397. /// <param name="dto"></param>
  6398. /// <returns></returns>
  6399. [HttpPost]
  6400. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6401. {
  6402. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6403. return Ok(JsonView(true, "获取成功!", Data));
  6404. }
  6405. /// <summary>
  6406. /// 成本通知
  6407. /// </summary>
  6408. /// <param name="dto"></param>
  6409. /// <returns></returns>
  6410. [HttpPost]
  6411. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6412. {
  6413. if (dto.Diid < 0)
  6414. {
  6415. return Ok(JsonView(false));
  6416. }
  6417. JsonView jw = null;
  6418. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6419. if (GroupCostParameter != null)
  6420. {
  6421. int IsShare = 0;
  6422. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6423. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6424. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6425. string msg = string.Empty;
  6426. if (isTrue)
  6427. {
  6428. if (IsShare == 0)
  6429. {
  6430. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6431. }
  6432. else
  6433. {
  6434. #region 企微通知对应岗位用户
  6435. try
  6436. {
  6437. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6438. }
  6439. catch (Exception ex)
  6440. {
  6441. }
  6442. #endregion
  6443. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6444. }
  6445. jw = JsonView(isTrue, msg, new { IsShare });
  6446. }
  6447. else
  6448. {
  6449. msg = "修改失败!";
  6450. jw = JsonView(isTrue, msg);
  6451. }
  6452. }
  6453. else
  6454. {
  6455. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6456. }
  6457. return Ok(jw);
  6458. }
  6459. /// <summary>
  6460. /// 导出报价单
  6461. /// </summary>
  6462. /// <param name="dto"></param>
  6463. /// <returns></returns>
  6464. [HttpPost]
  6465. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6466. {
  6467. if (dto.Diid == 0)
  6468. {
  6469. return Ok(JsonView(false, "请传递团组id"));
  6470. }
  6471. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6472. if (deleInfo.Code != 0)
  6473. {
  6474. return Ok(JsonView(false, "团组信息查询失败!"));
  6475. }
  6476. var di = deleInfo.Data as DelegationInfoWebView;
  6477. if (di != null)
  6478. {
  6479. //文件名
  6480. string strFileName = di.TeamName + "-收款账单.doc";
  6481. //获取模板
  6482. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6483. //载入模板
  6484. Document doc = new Document(tmppath);
  6485. decimal TotalPrice = 0.00M;
  6486. string itemStr = string.Empty;
  6487. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6488. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6489. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6490. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  6491. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  6492. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  6493. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  6494. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  6495. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  6496. foreach (var cost in groupCostType)
  6497. {
  6498. var List = cost.ToList();
  6499. if (cost.Key == "A")
  6500. {
  6501. foreach (var ListItem in List)
  6502. {
  6503. if (ListItem.number > 0)
  6504. {
  6505. if (ListItem.code.Contains("TBR"))
  6506. {
  6507. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6508. }
  6509. else
  6510. {
  6511. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6512. }
  6513. TotalPrice += (ListItem.number * ListItem.price);
  6514. }
  6515. }
  6516. }
  6517. else
  6518. {
  6519. itemStr = itemStr.Insert(0, "A段\r\n");
  6520. itemStr += "B段\r\n";
  6521. foreach (var ListItem in List)
  6522. {
  6523. if (ListItem.number > 0)
  6524. {
  6525. if (ListItem.code.Contains("TBR"))
  6526. {
  6527. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6528. }
  6529. else
  6530. {
  6531. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  6532. }
  6533. TotalPrice += (ListItem.number * ListItem.price);
  6534. }
  6535. }
  6536. }
  6537. }
  6538. #region 替换Word模板书签内容
  6539. Dictionary<string, string> marks = new Dictionary<string, string>();
  6540. marks.Add("To", di.ClientUnit);//付款方
  6541. marks.Add("ToTel", di.TellPhone);//付款方电话
  6542. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  6543. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  6544. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  6545. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  6546. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  6547. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  6548. marks.Add("PayItemContent", itemStr);//详细信息
  6549. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  6550. #endregion
  6551. ////注
  6552. //if (doc.Range.Bookmarks["Attention"] != null)
  6553. //{
  6554. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  6555. // mark.Text = frList[0].Attention;
  6556. //}
  6557. foreach (var item in marks.Keys)
  6558. {
  6559. if (doc.Range.Bookmarks[item] != null)
  6560. {
  6561. Bookmark mark = doc.Range.Bookmarks[item];
  6562. mark.Text = marks[item];
  6563. }
  6564. }
  6565. byte[] bytes = null;
  6566. using (MemoryStream stream = new MemoryStream())
  6567. {
  6568. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  6569. bytes = stream.ToArray();
  6570. }
  6571. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  6572. return Ok(JsonView(true, "", new
  6573. {
  6574. Data = bytes,
  6575. strFileName,
  6576. }));
  6577. }
  6578. else
  6579. {
  6580. return Ok(JsonView(false, "团组信息不存在!"));
  6581. }
  6582. }
  6583. /// <summary>
  6584. /// 导出团组成本
  6585. /// </summary>
  6586. /// <param name="dto"></param>
  6587. /// <returns></returns>
  6588. [HttpPost]
  6589. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  6590. {
  6591. var jw = JsonView(false);
  6592. if (dto.Diid == 0)
  6593. {
  6594. return Ok(JsonView(false, "请传递团组id"));
  6595. }
  6596. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6597. if (deleInfo.Code != 0)
  6598. {
  6599. return Ok(JsonView(false, "团组信息查询失败!"));
  6600. }
  6601. var di = deleInfo.Data as DelegationInfoWebView;
  6602. if (di == null)
  6603. {
  6604. return Ok(JsonView(false, "团组信息查询失败!"));
  6605. }
  6606. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  6607. WorkbookDesigner designer = new WorkbookDesigner();
  6608. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  6609. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  6610. for (int i = 0; i < List_GC.Count; i++)
  6611. {
  6612. GroupCost_Excel gc = new GroupCost_Excel();
  6613. gc.Id = List_GC[i].Id;
  6614. gc.Diid = List_GC[i].Diid.ToString();
  6615. gc.DAY = List_GC[i].DAY;
  6616. string week = "";
  6617. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  6618. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  6619. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  6620. gc.ITIN = List_GC[i].ITIN;
  6621. gc.CarType = List_GC[i].CarType;
  6622. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  6623. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  6624. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  6625. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  6626. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  6627. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  6628. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  6629. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  6630. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  6631. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  6632. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  6633. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  6634. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6635. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  6636. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  6637. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  6638. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  6639. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  6640. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  6641. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  6642. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  6643. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  6644. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  6645. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  6646. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  6647. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  6648. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  6649. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  6650. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  6651. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  6652. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  6653. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  6654. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  6655. List_GC1.Add(gc);
  6656. }
  6657. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  6658. dt.TableName = "TB";
  6659. //报表标题等不用dt的值
  6660. designer.SetDataSource("TeamName", dto.title.TeamName);
  6661. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  6662. designer.SetDataSource("Tax", dto.title.Tax);
  6663. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  6664. designer.SetDataSource("Currency", dto.title.Currency);
  6665. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  6666. designer.SetDataSource("Rate", dto.title.Rate);
  6667. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  6668. var Aparams = hotels.Find(x => x.Type == "Default");
  6669. if (Aparams == null)
  6670. {
  6671. return Ok(jw);
  6672. }
  6673. //酒店数量
  6674. var txtSGRNumber = Aparams.SGR.ToString();
  6675. var txtTBRNumber = Aparams.TBR.ToString();
  6676. var txtJSESNumber = Aparams.JSES.ToString();
  6677. var txtSUITENumbe = Aparams.SUITE.ToString();
  6678. if (dto.costType == "B")
  6679. {
  6680. Aparams = hotels.Find(x => x.Type == "A");
  6681. var Bparams = hotels.Find(x => x.Type == "B");
  6682. if (Aparams == null || Bparams == null)
  6683. {
  6684. return Ok(jw);
  6685. }
  6686. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  6687. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  6688. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  6689. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  6690. }
  6691. designer.SetDataSource("SGRNumber", txtSGRNumber);
  6692. designer.SetDataSource("TBRNumber", txtTBRNumber);
  6693. designer.SetDataSource("JSESNumber", txtJSESNumber);
  6694. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  6695. var ws = designer.Workbook.Worksheets[0];
  6696. int Row = List_GC.Count;
  6697. int startIndex = 11;
  6698. int HideRows = 0;
  6699. List<int> hideRowsList = new List<int>();
  6700. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  6701. #region A段left数据
  6702. var left = dto.leftInfo.Find(x => x.Type == "A");
  6703. if (left == null)
  6704. {
  6705. return Ok(jw);
  6706. }
  6707. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  6708. if (leftBindData != null)
  6709. {
  6710. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  6711. designer.SetDataSource("VisaRS", leftBindData.rs);
  6712. designer.SetDataSource("VisaXS", leftBindData.xs);
  6713. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6714. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6715. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6716. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6717. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6718. }
  6719. else
  6720. {
  6721. hideRowsList.Add(Row + startIndex + HideRows);
  6722. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6723. }
  6724. HideRows += 2;
  6725. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  6726. if (leftBindData != null)
  6727. {
  6728. designer.SetDataSource("BXDRCB", leftBindData.cb);
  6729. designer.SetDataSource("BXRS", leftBindData.rs);
  6730. designer.SetDataSource("BXXS", leftBindData.xs);
  6731. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6732. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6733. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6734. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6735. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6736. }
  6737. else
  6738. {
  6739. hideRowsList.Add(Row + startIndex + HideRows);
  6740. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6741. }
  6742. HideRows += 2;
  6743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  6744. if (leftBindData != null)
  6745. {
  6746. designer.SetDataSource("HSDRCB", leftBindData.cb);
  6747. designer.SetDataSource("HSRS", leftBindData.rs);
  6748. designer.SetDataSource("HSXS", leftBindData.xs);
  6749. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6750. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6751. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6752. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6753. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6754. }
  6755. else
  6756. {
  6757. hideRowsList.Add(Row + startIndex + HideRows);
  6758. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6759. }
  6760. HideRows += 2;
  6761. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  6762. if (leftBindData != null)
  6763. {
  6764. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  6765. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  6766. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  6767. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6768. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6769. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6770. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6771. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6772. }
  6773. else
  6774. {
  6775. hideRowsList.Add(Row + startIndex + HideRows);
  6776. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6777. }
  6778. HideRows += 2;
  6779. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  6780. if (leftBindData != null)
  6781. {
  6782. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  6783. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  6784. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  6785. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6786. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6787. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6788. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6789. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6790. }
  6791. else
  6792. {
  6793. hideRowsList.Add(Row + startIndex + HideRows);
  6794. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6795. }
  6796. HideRows += 2;
  6797. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  6798. if (leftBindData != null)
  6799. {
  6800. ////TBR
  6801. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  6802. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  6803. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  6804. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6805. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6806. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6807. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6808. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6809. }
  6810. else
  6811. {
  6812. hideRowsList.Add(Row + startIndex + HideRows);
  6813. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6814. }
  6815. HideRows += 2;
  6816. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  6817. if (leftBindData != null)
  6818. {
  6819. ////SGR
  6820. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  6821. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  6822. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  6823. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6824. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6825. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6826. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6827. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6828. }
  6829. else
  6830. {
  6831. hideRowsList.Add(Row + startIndex + HideRows);
  6832. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6833. }
  6834. HideRows += 2;
  6835. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  6836. if (leftBindData != null)
  6837. {
  6838. ////JS/ES
  6839. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  6840. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  6841. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  6842. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6843. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6844. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6845. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6846. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6847. }
  6848. else
  6849. {
  6850. hideRowsList.Add(Row + startIndex + HideRows);
  6851. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6852. }
  6853. HideRows += 2;
  6854. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  6855. if (leftBindData != null)
  6856. {
  6857. ////SUITE
  6858. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  6859. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  6860. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  6861. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6862. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6863. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6864. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6865. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6866. }
  6867. else
  6868. {
  6869. hideRowsList.Add(Row + startIndex + HideRows);
  6870. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6871. }
  6872. HideRows += 2;
  6873. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  6874. if (leftBindData != null)
  6875. {
  6876. designer.SetDataSource("DJDRCB", leftBindData.cb);
  6877. designer.SetDataSource("DJRS", leftBindData.rs);
  6878. designer.SetDataSource("DJXS", leftBindData.xs);
  6879. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6880. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6881. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6882. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6883. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6884. }
  6885. else
  6886. {
  6887. hideRowsList.Add(Row + startIndex + HideRows);
  6888. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6889. }
  6890. HideRows += 2;
  6891. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  6892. if (leftBindData != null)
  6893. {
  6894. designer.SetDataSource("HCPCB", leftBindData.cb);
  6895. designer.SetDataSource("HCPRS", leftBindData.rs);
  6896. designer.SetDataSource("HCPXS", leftBindData.xs);
  6897. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6898. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6899. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6900. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6901. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6902. }
  6903. else
  6904. {
  6905. hideRowsList.Add(Row + startIndex + HideRows);
  6906. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6907. }
  6908. HideRows += 2;
  6909. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  6910. if (leftBindData != null)
  6911. {
  6912. designer.SetDataSource("CPCB", leftBindData.cb);
  6913. designer.SetDataSource("CPRS", leftBindData.rs);
  6914. designer.SetDataSource("CPXS", leftBindData.xs);
  6915. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6916. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6917. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6918. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6919. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6920. }
  6921. else
  6922. {
  6923. hideRowsList.Add(Row + startIndex + HideRows);
  6924. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6925. }
  6926. HideRows += 2;
  6927. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  6928. if (leftBindData != null)
  6929. {
  6930. designer.SetDataSource("GWDRCD", leftBindData.cb);
  6931. designer.SetDataSource("GWRS", leftBindData.rs);
  6932. designer.SetDataSource("GWXS", leftBindData.xs);
  6933. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6934. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6935. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6936. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6937. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6938. }
  6939. else
  6940. {
  6941. hideRowsList.Add(Row + startIndex + HideRows);
  6942. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6943. }
  6944. HideRows += 2;
  6945. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  6946. if (leftBindData != null)
  6947. {
  6948. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  6949. designer.SetDataSource("LYJRS", leftBindData.rs);
  6950. designer.SetDataSource("LYJXS", leftBindData.xs);
  6951. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  6952. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  6953. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  6954. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  6955. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  6956. }
  6957. else
  6958. {
  6959. hideRowsList.Add(Row + startIndex + HideRows);
  6960. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  6961. }
  6962. #endregion
  6963. #region A段Right信息
  6964. var right = dto.rightInfo.Find(x => x.Type == "A");
  6965. if (right == null)
  6966. {
  6967. return Ok(jw);
  6968. }
  6969. HideRows += 4;
  6970. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  6971. if (rightBindData != null)
  6972. {
  6973. //经济舱 + 双人间 TBR
  6974. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  6975. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  6976. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6977. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  6978. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6979. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  6980. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  6981. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  6982. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  6983. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  6984. }
  6985. else
  6986. {
  6987. hideRowsList.Add(Row + startIndex + HideRows);
  6988. }
  6989. HideRows += 2;
  6990. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  6991. if (rightBindData != null)
  6992. {
  6993. //经济舱 + 单人间 SGR
  6994. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  6995. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  6996. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  6997. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  6998. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  6999. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7000. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7001. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7002. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7003. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7004. }
  7005. else
  7006. {
  7007. hideRowsList.Add(Row + startIndex + HideRows);
  7008. }
  7009. HideRows += 2;
  7010. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7011. if (rightBindData != null)
  7012. {
  7013. //公务舱 + 单人间 SGR
  7014. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7015. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7016. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7017. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7018. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7019. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7020. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7021. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7022. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7023. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7024. }
  7025. else
  7026. {
  7027. hideRowsList.Add(Row + startIndex + HideRows);
  7028. }
  7029. HideRows += 2;
  7030. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7031. if (rightBindData != null)
  7032. {
  7033. //公务舱 + 小套房 JSES
  7034. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7035. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7036. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7037. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7038. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7039. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7040. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7041. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7042. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7043. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7044. }
  7045. else
  7046. {
  7047. hideRowsList.Add(Row + startIndex + HideRows);
  7048. }
  7049. HideRows += 2;
  7050. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7051. if (rightBindData != null)
  7052. {
  7053. //公务舱 + 小套房 JSES
  7054. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7055. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7056. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7057. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7058. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7059. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7060. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7061. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7062. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7063. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7064. }
  7065. else
  7066. {
  7067. hideRowsList.Add(Row + startIndex + HideRows);
  7068. }
  7069. HideRows += 2;
  7070. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7071. if (rightBindData != null)
  7072. {
  7073. //经济舱 + 大套房
  7074. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7075. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7076. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7077. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7078. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7079. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7080. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7081. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7082. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7083. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7084. }
  7085. else
  7086. {
  7087. hideRowsList.Add(Row + startIndex + HideRows);
  7088. }
  7089. #endregion
  7090. #region B段标题清空
  7091. designer.SetDataSource("CostBDRCB", "");
  7092. designer.SetDataSource("CostBRS", "");
  7093. designer.SetDataSource("CostBXS", "");
  7094. designer.SetDataSource("CostBZCB", "");
  7095. designer.SetDataSource("CostBDRBJ", "");
  7096. designer.SetDataSource("CostBZBJ", "");
  7097. designer.SetDataSource("CostBDRLR", "");
  7098. designer.SetDataSource("CostBZLR", "");
  7099. designer.SetDataSource("CostBDRCBOM", "");
  7100. designer.SetDataSource("CostBRSOM", "");
  7101. designer.SetDataSource("CostBZCBOM", "");
  7102. designer.SetDataSource("CostBDRBJOM", "");
  7103. designer.SetDataSource("CostBZBJOM", "");
  7104. designer.SetDataSource("CostBDRLROM", "");
  7105. designer.SetDataSource("CostBZLROM", "");
  7106. #endregion
  7107. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7108. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7109. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7110. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7111. designer.SetDataSource("DJName", "地接(CNY)");
  7112. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7113. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7114. designer.SetDataSource("GWName", "公务(CNY)");
  7115. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7116. designer.SetDataSource("LYJName", "零用金(CNY)");
  7117. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7118. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7119. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7120. designer.SetDataSource("BXName", "保险(CNY)");
  7121. designer.SetDataSource("VisaName", "签证(CNY)");
  7122. #region B段基本数据
  7123. if (dto.costType == "B")
  7124. {
  7125. left = dto.leftInfo.Find(x => x.Type == "B");
  7126. if (left == null)
  7127. {
  7128. return Ok(jw);
  7129. }
  7130. #region B段left数据
  7131. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7132. if (leftBindData != null)
  7133. {
  7134. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7135. designer.SetDataSource("BHSRS", leftBindData.rs);
  7136. designer.SetDataSource("BHSXS", leftBindData.xs);
  7137. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7138. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7139. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7140. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7141. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7142. }
  7143. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7144. if (leftBindData != null)
  7145. {
  7146. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7147. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7148. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7149. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7150. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7151. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7152. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7153. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7154. }
  7155. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7156. if (leftBindData != null)
  7157. {
  7158. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7159. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7160. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7161. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7162. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7163. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7164. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7165. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7166. }
  7167. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7168. if (leftBindData != null)
  7169. {
  7170. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7171. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7172. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7173. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7174. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7175. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7176. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7177. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7178. }
  7179. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7180. if (leftBindData != null)
  7181. {
  7182. designer.SetDataSource("BCPCB", leftBindData.cb);
  7183. designer.SetDataSource("BCPRS", leftBindData.rs);
  7184. designer.SetDataSource("BCPXS", leftBindData.xs);
  7185. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7186. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7187. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7188. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7189. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7190. }
  7191. //TBR
  7192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7193. if (leftBindData != null)
  7194. {
  7195. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7196. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7197. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7198. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7199. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7200. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7201. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7202. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7203. }
  7204. //SGR
  7205. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7206. if (leftBindData != null)
  7207. {
  7208. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7209. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7210. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7211. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7212. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7213. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7214. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7215. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7216. }
  7217. //JS/ES
  7218. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7219. if (leftBindData != null)
  7220. {
  7221. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7222. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7223. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7224. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7225. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7226. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7227. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7228. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7229. }
  7230. //SUITE
  7231. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7232. if (leftBindData != null)
  7233. {
  7234. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7235. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7236. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7237. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7238. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7239. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7240. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7241. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7242. }
  7243. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7244. if (leftBindData != null)
  7245. {
  7246. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7247. designer.SetDataSource("BDJRS", leftBindData.rs);
  7248. designer.SetDataSource("BDJXS", leftBindData.xs);
  7249. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7250. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7251. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7252. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7253. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7254. }
  7255. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7256. if (leftBindData != null)
  7257. {
  7258. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7259. designer.SetDataSource("BGWRS", leftBindData.rs);
  7260. designer.SetDataSource("BGWXS", leftBindData.xs);
  7261. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7262. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7263. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7264. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7265. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7266. }
  7267. #region 优化方案
  7268. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7269. //excelBind.Add("零用金", new {
  7270. //cb="",
  7271. //rs="",
  7272. //xs ="",
  7273. //zcb = "",
  7274. //});
  7275. #endregion
  7276. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7277. if (leftBindData != null)
  7278. {
  7279. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7280. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7281. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7282. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7283. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7284. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7285. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7286. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7287. }
  7288. #endregion
  7289. #region B段Right信息
  7290. right = dto.rightInfo.Find(x => x.Type == "B");
  7291. if (right == null)
  7292. {
  7293. return Ok(jw);
  7294. }
  7295. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7296. if (rightBindData != null)
  7297. {
  7298. //经济舱 + 双人间 TBR
  7299. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7300. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7301. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7302. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7303. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7304. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7305. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7306. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7307. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7308. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7309. }
  7310. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7311. if (rightBindData != null)
  7312. {
  7313. //经济舱 + 单人间 SGR
  7314. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7315. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7316. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7317. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7318. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7319. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7320. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7321. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7322. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7323. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7324. }
  7325. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7326. if (rightBindData != null)
  7327. {
  7328. //公务舱 + 单人间 SGR
  7329. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7330. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7331. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7332. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7333. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7334. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7335. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7336. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7337. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7338. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7339. }
  7340. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7341. if (rightBindData != null)
  7342. {
  7343. //公务舱 + 小套房 JSES
  7344. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7345. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7346. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7347. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7348. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7349. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7350. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7351. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7352. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7353. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7354. }
  7355. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7356. if (rightBindData != null)
  7357. {
  7358. //公务舱 + 小套房 JSES
  7359. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7360. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7361. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7362. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7363. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7364. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7365. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7366. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7367. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7368. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7369. }
  7370. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7371. if (rightBindData != null)
  7372. {
  7373. //经济舱 + 大套房
  7374. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7375. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7376. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7377. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7378. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7379. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7380. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7381. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7382. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7383. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7384. }
  7385. #endregion
  7386. #region 标题
  7387. designer.SetDataSource("CostBDRCB", "单人成本");
  7388. designer.SetDataSource("CostBRS", "人数");
  7389. designer.SetDataSource("CostBXS", "系数");
  7390. designer.SetDataSource("CostBZCB", "总成本");
  7391. designer.SetDataSource("CostBDRBJ", "单人报价");
  7392. designer.SetDataSource("CostBZBJ", "总报价");
  7393. designer.SetDataSource("CostBDRLR", "单人利润");
  7394. designer.SetDataSource("CostBZLR", "总利润");
  7395. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7396. designer.SetDataSource("CostBRSOM", "人数");
  7397. designer.SetDataSource("CostBZCBOM", "总成本");
  7398. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7399. designer.SetDataSource("CostBZBJOM", "总报价");
  7400. designer.SetDataSource("CostBDRLROM", "单人利润");
  7401. designer.SetDataSource("CostBZLROM", "总利润");
  7402. #endregion
  7403. }
  7404. #endregion
  7405. designer.SetDataSource("TzZCB2", TzZCB2);
  7406. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7407. designer.SetDataSource("TzZLR2", TzZLR2);
  7408. string[] dataSourceKeys = new string[]
  7409. {
  7410. "VF",
  7411. "TGS",
  7412. "TGOF",
  7413. "TGM",
  7414. "TGA",
  7415. "TGTF",
  7416. "TGEF",
  7417. "CFM",
  7418. "CFOF",
  7419. "B",
  7420. "L",
  7421. "D",
  7422. "TBR",
  7423. "SGR",
  7424. "JSES",
  7425. "Suite",
  7426. "TV",
  7427. "1L",
  7428. "IF",
  7429. "EF",
  7430. "BRF",
  7431. "TE",
  7432. "TGT",
  7433. "DRVT",
  7434. "PC",
  7435. "TLF",
  7436. "ECT"
  7437. };
  7438. foreach (var item in dataSourceKeys)
  7439. {
  7440. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7441. if (find != null)
  7442. {
  7443. designer.SetDataSource(item, find.text);
  7444. }
  7445. else
  7446. {
  7447. designer.SetDataSource(item, 0);
  7448. }
  7449. }
  7450. designer.SetDataSource(dt);
  7451. //根据数据源处理生成报表内容
  7452. designer.Process();
  7453. designer.Workbook.Worksheets[0].Name = "清单";
  7454. Worksheet sheet = designer.Workbook.Worksheets[0];
  7455. foreach (var Rowindex in hideRowsList)
  7456. {
  7457. ws.Cells.HideRows(Rowindex, 2);
  7458. }
  7459. byte[] bytes = null;
  7460. string strFileName = di.TeamName + "-团组-成本.xls";
  7461. using (MemoryStream stream = new MemoryStream())
  7462. {
  7463. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7464. bytes = stream.ToArray();
  7465. }
  7466. return Ok(JsonView(true, "", new
  7467. {
  7468. Data = bytes,
  7469. strFileName,
  7470. }));
  7471. }
  7472. /// <summary>
  7473. /// 导出客户报表
  7474. /// </summary>
  7475. /// <returns></returns>
  7476. [HttpPost]
  7477. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7478. {
  7479. var jw = JsonView(false);
  7480. if (dto.Diid == 0)
  7481. {
  7482. return Ok(JsonView(false, "请传递团组id"));
  7483. }
  7484. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7485. if (deleInfo.Code != 0)
  7486. {
  7487. return Ok(JsonView(false, "团组信息查询失败!"));
  7488. }
  7489. var di = deleInfo.Data as DelegationInfoWebView;
  7490. if (di == null)
  7491. {
  7492. return Ok(JsonView(false, "团组信息查询失败!"));
  7493. }
  7494. //文件名
  7495. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  7496. //获取模板
  7497. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  7498. //载入模板
  7499. Document doc = new Document(tmppath);
  7500. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  7501. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  7502. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  7503. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  7504. var AParameter = ParameterList.Find(x => x.CostType == "A");
  7505. var BParameter = ParameterList.Find(x => x.CostType == "B");
  7506. if (AParameter == null)
  7507. {
  7508. return Ok(JsonView(false, "系数不存在!"));
  7509. }
  7510. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  7511. , TzAirDesc, TzZCost;
  7512. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  7513. = TzAirDesc = TzZCost = string.Empty;
  7514. TzNumber = AParameter.CostTypenumber.ToString();
  7515. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  7516. CarGuides1 = dto.CarGuides1;
  7517. Meal = dto.Meal;
  7518. SubsidizedMeals = dto.SubsidizedMeals;
  7519. NightRepair = dto.NightRepair;
  7520. AttractionsTickets = dto.AttractionsTickets;
  7521. MiscellaneousFees = dto.MiscellaneousFees;
  7522. ATip = dto.ATip;
  7523. TzHotelDesc = "";
  7524. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  7525. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  7526. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  7527. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  7528. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  7529. TzAirDesc = "";
  7530. TzZCost = dto.TzZCost;
  7531. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  7532. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  7533. var index = 1;
  7534. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  7535. foreach (var item in TzHotelDescArr)
  7536. {
  7537. if (AinfoArr != null)
  7538. {
  7539. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7540. if (Ainfo != null)
  7541. {
  7542. if (int.Parse(Ainfo.rs) <= 0)
  7543. {
  7544. continue;
  7545. }
  7546. var hotelText = string.Empty;
  7547. switch (item)
  7548. {
  7549. case "SGR":
  7550. hotelText = "单人间";
  7551. break;
  7552. case "JSES":
  7553. hotelText = "小套房";
  7554. break;
  7555. case "SUITE":
  7556. hotelText = "套房";
  7557. break;
  7558. case "TBR":
  7559. hotelText = "双人间";
  7560. break;
  7561. }
  7562. if (item != "TBR")
  7563. {
  7564. 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";
  7565. }
  7566. else
  7567. {
  7568. 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";
  7569. }
  7570. index++;
  7571. }
  7572. }
  7573. }
  7574. index = 1;
  7575. foreach (var item in TzAirDescArr)
  7576. {
  7577. if (AinfoArr != null)
  7578. {
  7579. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7580. if (Ainfo != null)
  7581. {
  7582. if (int.Parse(Ainfo.rs) <= 0)
  7583. {
  7584. continue;
  7585. }
  7586. 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";
  7587. index++;
  7588. }
  7589. }
  7590. }
  7591. if (dto.costType == "B")
  7592. {
  7593. if (BParameter == null)
  7594. {
  7595. return Ok(JsonView(false, "B段系数不存在!"));
  7596. }
  7597. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  7598. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  7599. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  7600. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  7601. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  7602. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  7603. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  7604. foreach (var item in TzHotelDescArr)
  7605. {
  7606. if (AinfoArr != null)
  7607. {
  7608. TzHotelDesc += "B段信息 \r\n";
  7609. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7610. if (Ainfo != null)
  7611. {
  7612. if (int.Parse(Ainfo.rs) <= 0)
  7613. {
  7614. continue;
  7615. }
  7616. var hotelText = string.Empty;
  7617. switch (item)
  7618. {
  7619. case "SGR":
  7620. hotelText = "单人间";
  7621. break;
  7622. case "JSES":
  7623. hotelText = "小套房";
  7624. break;
  7625. case "SUITE":
  7626. hotelText = "套房";
  7627. break;
  7628. case "TBR":
  7629. hotelText = "双人间";
  7630. break;
  7631. }
  7632. if (item != "TBR")
  7633. {
  7634. 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";
  7635. }
  7636. else
  7637. {
  7638. 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";
  7639. }
  7640. index++;
  7641. }
  7642. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  7643. }
  7644. }
  7645. index = 1;
  7646. foreach (var item in TzAirDescArr)
  7647. {
  7648. if (AinfoArr != null)
  7649. {
  7650. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  7651. if (Ainfo != null)
  7652. {
  7653. if (int.Parse(Ainfo.rs) <= 0)
  7654. {
  7655. continue;
  7656. }
  7657. 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";
  7658. index++;
  7659. }
  7660. }
  7661. }
  7662. }
  7663. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  7664. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  7665. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  7666. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  7667. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  7668. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  7669. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  7670. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  7671. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  7672. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  7673. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  7674. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  7675. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  7676. DickeyValue.Add("Visa", Visa); // 签证单人报价
  7677. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  7678. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  7679. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  7680. DickeyValue.Add("TzZCost", TzZCost);
  7681. foreach (var key in DickeyValue.Keys)
  7682. {
  7683. if (doc.Range.Bookmarks[key] != null)
  7684. {
  7685. Bookmark mark = doc.Range.Bookmarks[key];
  7686. mark.Text = DickeyValue[key];
  7687. }
  7688. }
  7689. byte[] bytes = null;
  7690. string strFileName = di.TeamName + "-客户报价.doc";
  7691. using (MemoryStream stream = new MemoryStream())
  7692. {
  7693. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7694. bytes = stream.ToArray();
  7695. }
  7696. return Ok(JsonView(true, "", new
  7697. {
  7698. Data = bytes,
  7699. strFileName,
  7700. }));
  7701. }
  7702. /// <summary>
  7703. /// 团组成本 各模块(酒店,地接,机票)成本提示
  7704. /// </summary>
  7705. /// <param name="dto"></param>
  7706. /// <returns></returns>
  7707. [HttpPost]
  7708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7709. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  7710. {
  7711. try
  7712. {
  7713. #region 参数验证
  7714. if (dto.DiId < 0)
  7715. {
  7716. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7717. }
  7718. List<int> cTableIds = new List<int>() {
  7719. 76 ,//酒店预订
  7720. 77 ,//行程
  7721. 79 ,//车/导游地接
  7722. 80 ,//签证
  7723. 81 ,//邀请/公务活
  7724. 82 ,//团组客户保险
  7725. 85 ,//机票预订
  7726. 98 ,//其他款项
  7727. 285 ,//收款退还
  7728. 751 ,//酒店早餐
  7729. 1015 // 超支费用
  7730. };
  7731. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  7732. {
  7733. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  7734. }
  7735. #endregion
  7736. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  7737. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7738. if (_GroupCostParameters.Count <= 0)
  7739. {
  7740. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  7741. }
  7742. if (_GroupCostParameters[0].IsShare == 0)
  7743. {
  7744. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  7745. }
  7746. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7747. //处理date为空问题
  7748. if (_GroupCosts.Count > 0)
  7749. {
  7750. for (int i = 0; i < _GroupCosts.Count; i++)
  7751. {
  7752. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  7753. {
  7754. if (i > 0)
  7755. {
  7756. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  7757. }
  7758. }
  7759. }
  7760. }
  7761. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  7762. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  7763. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7764. string currCode = "";
  7765. #region currCode 验证
  7766. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  7767. if (isInt)
  7768. {
  7769. var currData = currDatas.Find(it => it.Id == intCurrency);
  7770. if (currData != null)
  7771. {
  7772. currCode = currData.Name;
  7773. }
  7774. }
  7775. else
  7776. {
  7777. currCode = _GroupCostParameters[0].Currency.Trim();
  7778. }
  7779. #endregion
  7780. //op,酒店单段模式存储
  7781. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  7782. {
  7783. CurrencyCode = currCode,
  7784. Rate = _GroupCostParameters[0].Rate,
  7785. CostType = _GroupCostParameters[0].CostType,
  7786. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  7787. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  7788. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  7789. };
  7790. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  7791. if (_GroupCostParameters.Count == 2)
  7792. {
  7793. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  7794. }
  7795. foreach (var item in _GroupCostParameters)
  7796. {
  7797. decimal _rate = 1;
  7798. decimal _rate1 = item.Rate;
  7799. decimal _scale = 1;
  7800. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  7801. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  7802. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  7803. //if (userInfo != null)
  7804. //{
  7805. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  7806. // {
  7807. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  7808. // {
  7809. // _scale = 1.00M;
  7810. // }
  7811. // }
  7812. //}
  7813. #endregion
  7814. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  7815. {
  7816. CurrencyCode = currCode,
  7817. Rate = _rate1,
  7818. CostType = item.CostType,
  7819. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  7820. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  7821. CostTypeNumber = item.CostTypenumber
  7822. };
  7823. if (_GroupCostParameters.Count > 1)
  7824. {
  7825. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  7826. }
  7827. else
  7828. {
  7829. modulePromptInfo.CostTypeNumber = item.LYJRS;
  7830. }
  7831. if (dto.CTable == 79)//
  7832. {
  7833. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  7834. modulePromptInfo.TotalCost = item.DJCB;
  7835. }
  7836. List<string> costTypes = new List<string>() { "A", "B" };
  7837. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  7838. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  7839. if (_GroupCostsDuplicates.Count() == 1)
  7840. {
  7841. _GroupCostsTypeData = _GroupCosts;
  7842. }
  7843. else
  7844. {
  7845. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  7846. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  7847. }
  7848. /*
  7849. * 76 酒店预订
  7850. * 77 行程
  7851. * 79 车/导游地接
  7852. * 80 签证
  7853. * 81 邀请/公务活动
  7854. * 82 团组客户保险
  7855. * 85 机票预订
  7856. * 98 其他款项
  7857. * 285 收款退还
  7858. * 751 酒店早餐
  7859. * 1015 超支费用
  7860. */
  7861. switch (dto.CTable)
  7862. {
  7863. case 76: // 酒店预订
  7864. _ModuleSubPromptInfo.AddRange(
  7865. _GroupCostsTypeData.Select(it => new
  7866. {
  7867. it.DAY,
  7868. it.Date,
  7869. it.ACCON,
  7870. it.ITIN,
  7871. it.SGR,
  7872. it.TBR,
  7873. it.JS_ES,
  7874. it.Suite
  7875. })
  7876. );
  7877. break;
  7878. case 79: // 车/导游地接
  7879. _ModuleSubPromptInfo.AddRange(
  7880. _GroupCostsTypeData.Select(it => new
  7881. {
  7882. Date = it.Date, //日期
  7883. CarFee = it.CarCost * _rate * _scale, //车费用
  7884. CarType = it.CarType, //车型
  7885. DriverFee = it.CFS * _rate * _scale, //司机工资
  7886. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  7887. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  7888. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  7889. GuideFee = it.TGS * _rate * _scale, //导游费用
  7890. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  7891. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  7892. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  7893. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  7894. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  7895. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  7896. Breakfast = it.B * _rate * _scale, //早餐费
  7897. Lunch = it.L * _rate * _scale, //午餐费
  7898. Dinner = it.D * _rate * _scale, //晚餐费
  7899. TicketFee = it.EF * _rate * _scale, //门票费
  7900. SpentCash = it.PC * _rate * _scale, //零用金
  7901. LeadersFee = it.TLF * _rate * _scale, //领队费
  7902. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  7903. TravelSupplies = it.TE * _rate * _scale, //出行物资
  7904. })
  7905. );
  7906. break;
  7907. case 85: // 机票
  7908. List<dynamic> datas = new List<dynamic>();
  7909. datas.Add(
  7910. new
  7911. {
  7912. AirType = "经济舱",
  7913. AirNum = item.JJCRS,
  7914. AirDRCB = item.JJCCB,
  7915. AirZCB = (item.JJCRS * item.JJCCB)
  7916. }
  7917. );
  7918. datas.Add(
  7919. new
  7920. {
  7921. AirType = "公务舱",
  7922. AirNum = item.GWCRS,
  7923. AirDRCB = item.GWCCB,
  7924. AirZCB = (item.GWCRS * item.GWCCB)
  7925. }
  7926. );
  7927. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  7928. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  7929. modulePromptInfo.Data = new
  7930. {
  7931. airFeeData = datas,
  7932. airInitData = initDatas
  7933. };
  7934. _ModulePromptInfos.Add(modulePromptInfo);
  7935. break;
  7936. default:
  7937. break;
  7938. }
  7939. }
  7940. if (dto.CTable != 85)
  7941. {
  7942. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  7943. _ModulePromptInfos.Add(_ModulePromptInfo);
  7944. }
  7945. _view.ModulePromptInfos = _ModulePromptInfos;
  7946. return Ok(JsonView(true, "操作成功!", _view));
  7947. }
  7948. catch (Exception ex)
  7949. {
  7950. return Ok(JsonView(false, ex.Message));
  7951. }
  7952. }
  7953. /// <summary>
  7954. /// 根据黑屏代码重新生成行程
  7955. /// </summary>
  7956. /// <param name="dto"></param>
  7957. /// <returns></returns>
  7958. [HttpPost]
  7959. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  7960. {
  7961. var jw = JsonView(false);
  7962. var Create = _GroupCostRepository.
  7963. CreateGroupCostByBlackCode(dto.Diid);
  7964. jw.Msg = Create.Msg;
  7965. if (Create.Code == 0)
  7966. {
  7967. jw.Code = 200;
  7968. jw.Data = new
  7969. {
  7970. groupCost = Create.Data,
  7971. blackCodeIsTrue = true
  7972. };
  7973. }
  7974. else
  7975. {
  7976. jw.Code = 400;
  7977. jw.Data = new
  7978. {
  7979. groupCost = Create.Data,
  7980. blackCodeIsTrue = false,
  7981. };
  7982. }
  7983. return Ok(jw);
  7984. }
  7985. /// <summary>
  7986. /// 成本获取OP历史车费用
  7987. /// </summary>
  7988. /// <param name="dto"></param>
  7989. /// <returns></returns>
  7990. [HttpPost]
  7991. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  7992. {
  7993. var jw = JsonView(false);
  7994. try
  7995. {
  7996. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  7997. //获取现有所有车的数据
  7998. if (!dto.Param.IsNullOrWhiteSpace())
  7999. {
  8000. string sql = $@"
  8001. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8002. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8003. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8004. 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
  8005. AND gctggr.ServiceEndTime is not NULL
  8006. ORDER by gctggrc.id DESC
  8007. ";
  8008. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8009. var numeberResult = await Task.Run(() =>
  8010. {
  8011. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8012. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8013. return numberArr;
  8014. });
  8015. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8016. foreach (var item in numeberResult)
  8017. {
  8018. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8019. {
  8020. Country = "数据异常!",
  8021. City = string.Empty,
  8022. };
  8023. item.Area = find.Country + " " + find.City;
  8024. }
  8025. dbResult.AddRange(numeberResult);
  8026. if (dto.Param.Contains("、"))
  8027. {
  8028. var sp = dto.Param.Split("、");
  8029. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8030. .Where(x =>
  8031. {
  8032. return System.Array.Exists(sp, e =>
  8033. {
  8034. bool where = false;
  8035. if (x.Area != null)
  8036. {
  8037. where = x.Area.Contains(e);
  8038. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8039. {
  8040. return false;
  8041. }
  8042. }
  8043. if (x.PriceName != null && !where)
  8044. {
  8045. where = x.PriceName.Contains(e);
  8046. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8047. {
  8048. return false;
  8049. }
  8050. }
  8051. return where;
  8052. });
  8053. }).ToList();
  8054. }
  8055. else
  8056. {
  8057. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8058. .Where(x =>
  8059. {
  8060. bool where = false;
  8061. if (x.Area != null)
  8062. {
  8063. where = x.Area.Contains(dto.Param);
  8064. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8065. {
  8066. return false;
  8067. }
  8068. }
  8069. if (x.PriceName != null && !where)
  8070. {
  8071. where = x.PriceName.Contains(dto.Param);
  8072. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8073. {
  8074. return false;
  8075. }
  8076. }
  8077. return where;
  8078. }
  8079. )
  8080. .ToList();
  8081. }
  8082. }
  8083. var view = dbResult.Select(x =>
  8084. {
  8085. decimal dp = 0.00M;
  8086. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8087. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8088. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8089. {
  8090. if (startB && endB)
  8091. {
  8092. var timesp = endD.Subtract(startD);
  8093. if ((timesp.Days + 1) != 0)
  8094. {
  8095. dp = x.Price / (timesp.Days + 1);
  8096. }
  8097. }
  8098. }
  8099. else
  8100. {
  8101. dp = x.Price;
  8102. }
  8103. return new
  8104. {
  8105. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8106. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8107. x.Area,
  8108. x.id,
  8109. price = x.Price.ToString("F2"),
  8110. x.PriceName,
  8111. x.PriceContent,
  8112. x.TeamName,
  8113. x.DatePrice,
  8114. dayPrice = dp.ToString("F2"),
  8115. };
  8116. }).OrderByDescending(x => x.id).ToList();
  8117. jw = JsonView(true, "获取成功!", view);
  8118. }
  8119. catch (Exception e)
  8120. {
  8121. jw = JsonView(false, e.Message);
  8122. }
  8123. return Ok(jw);
  8124. }
  8125. #endregion
  8126. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8127. /// <summary>
  8128. /// 酒店预订
  8129. /// 酒店费用列表 根据团组Id查询
  8130. /// </summary>
  8131. /// <param name="_dto"></param>
  8132. /// <returns></returns>
  8133. [HttpPost]
  8134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8135. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8136. {
  8137. #region 参数验证
  8138. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8139. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8140. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8141. #region 团组操作权限验证 76 酒店预定模块
  8142. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8143. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8144. #endregion
  8145. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8146. #region 页面操作权限验证
  8147. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8148. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8149. #endregion
  8150. #endregion
  8151. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8152. }
  8153. /// <summary>
  8154. /// 酒店预订
  8155. /// 基础数据
  8156. /// </summary>
  8157. /// <param name="_dto"></param>
  8158. /// <returns></returns>
  8159. [HttpPost]
  8160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8161. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8162. {
  8163. #region 参数验证
  8164. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8165. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8166. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8167. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8168. #region 页面操作权限验证
  8169. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8170. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8171. #endregion
  8172. #region 团组操作权限验证 76 酒店预定模块
  8173. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8174. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8175. #endregion
  8176. #endregion
  8177. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8178. }
  8179. /// <summary>
  8180. /// 酒店预订
  8181. /// 创建 入住卷号码
  8182. /// </summary>
  8183. /// <param name="_dto"></param>
  8184. /// <returns></returns>
  8185. [HttpPost]
  8186. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8187. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8188. {
  8189. try
  8190. {
  8191. #region 参数验证
  8192. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8193. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8194. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8195. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8196. #region 页面操作权限验证
  8197. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8198. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8199. #endregion
  8200. #region 团组操作权限验证 76 酒店预定模块
  8201. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8202. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8203. #endregion
  8204. #endregion
  8205. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8206. if (data.Code != 0)
  8207. {
  8208. return Ok(JsonView(false, data.Msg));
  8209. }
  8210. return Ok(JsonView(true, data.Msg, data.Data));
  8211. }
  8212. catch (Exception ex)
  8213. {
  8214. return Ok(JsonView(false, ex.Message));
  8215. }
  8216. }
  8217. /// <summary>
  8218. /// 酒店预订
  8219. /// 详情
  8220. /// </summary>
  8221. /// <param name="_dto"></param>
  8222. /// <returns></returns>
  8223. [HttpPost]
  8224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8225. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8226. {
  8227. #region 参数验证
  8228. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8229. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8230. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8231. #region 团组操作权限验证 76 酒店预定模块
  8232. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8233. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8234. #endregion
  8235. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8236. #region 页面操作权限验证
  8237. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8238. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8239. #endregion
  8240. #endregion
  8241. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8242. }
  8243. /// <summary>
  8244. /// 酒店预订
  8245. /// Add Or Edit
  8246. /// </summary>
  8247. /// <param name="_dto"></param>
  8248. /// <returns></returns>
  8249. [HttpPost]
  8250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8251. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8252. {
  8253. #region 参数验证
  8254. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8255. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8256. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8257. #region 团组操作权限验证 76 酒店预定模块
  8258. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8259. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8260. #endregion
  8261. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8262. #region 页面操作权限验证
  8263. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8264. if (_dto.Id == 0) // Add
  8265. {
  8266. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8267. }
  8268. else if (_dto.Id > 1) // Edit
  8269. {
  8270. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8271. }
  8272. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8273. #endregion
  8274. #endregion
  8275. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8276. if (_view.Code != 200)
  8277. {
  8278. return Ok(_view);
  8279. }
  8280. #region 应用推送
  8281. try
  8282. {
  8283. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8284. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8285. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  8286. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8287. //自动审核
  8288. await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  8289. }
  8290. catch (Exception ex)
  8291. {
  8292. }
  8293. #endregion
  8294. return Ok(_view);
  8295. }
  8296. /// <summary>
  8297. /// 酒店预订
  8298. /// Del
  8299. /// </summary>
  8300. /// <param name="_dto"></param>
  8301. /// <returns></returns>
  8302. [HttpPost]
  8303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8304. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8305. {
  8306. #region 参数验证
  8307. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8308. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8309. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8310. #region 团组操作权限验证 76 酒店预定模块
  8311. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8312. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8313. #endregion
  8314. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8315. #region 页面操作权限验证
  8316. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8317. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8318. #endregion
  8319. #endregion
  8320. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8321. }
  8322. /// <summary>
  8323. /// 酒店预订
  8324. /// 生成VOUCHER
  8325. /// 2024.05.06 之前版本
  8326. /// </summary>
  8327. /// <param name="_dto"></param>
  8328. /// <returns></returns>
  8329. [HttpPost]
  8330. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8331. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8332. {
  8333. try
  8334. {
  8335. #region 参数验证
  8336. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8337. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8338. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8339. #region 团组操作权限验证 76 酒店预定模块
  8340. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8341. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8342. #endregion
  8343. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8344. #region 页面操作权限验证
  8345. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8346. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8347. #endregion
  8348. #endregion
  8349. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8350. //判断数据是否完整
  8351. if (hr != null)
  8352. {
  8353. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8354. {
  8355. string strFileName = "HotelStatement/";
  8356. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8357. if (dele != null)
  8358. strFileName += dele.TourCode;
  8359. //载入模板
  8360. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8361. Document doc = new Document(sss);
  8362. DocumentBuilder builder = new DocumentBuilder(doc);
  8363. #region 替换Word模板书签内容
  8364. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8365. //入住卷预定号码
  8366. if (doc.Range.Bookmarks["VNO"] != null)
  8367. {
  8368. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8369. mark.Text = hr.CheckNumber;
  8370. }
  8371. //酒店时间
  8372. if (doc.Range.Bookmarks["Date"] != null)
  8373. {
  8374. Bookmark mark = doc.Range.Bookmarks["Date"];
  8375. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8376. }
  8377. //团号
  8378. if (doc.Range.Bookmarks["TNo"] != null)
  8379. {
  8380. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8381. mark.Text = dele.TourCode;
  8382. }
  8383. //预定号码
  8384. if (doc.Range.Bookmarks["BookingId"] != null)
  8385. {
  8386. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8387. mark.Text = hr.ReservationsNo;
  8388. }
  8389. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8390. {
  8391. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8392. mark.Text = hr.DetermineNo;
  8393. }
  8394. //酒店城市
  8395. if (doc.Range.Bookmarks["City"] != null)
  8396. {
  8397. Bookmark mark = doc.Range.Bookmarks["City"];
  8398. mark.Text = hr.City;
  8399. }
  8400. //酒店名称
  8401. if (doc.Range.Bookmarks["HName"] != null)
  8402. {
  8403. Bookmark mark = doc.Range.Bookmarks["HName"];
  8404. mark.Text = hr.HotelName;
  8405. }
  8406. //酒店地址
  8407. if (doc.Range.Bookmarks["Address"] != null)
  8408. {
  8409. Bookmark mark = doc.Range.Bookmarks["Address"];
  8410. mark.Text = hr.HotelAddress;
  8411. }
  8412. //酒店电话
  8413. if (doc.Range.Bookmarks["Tel"] != null)
  8414. {
  8415. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8416. mark.Text = hr.HotelTel;
  8417. }
  8418. //酒店传真
  8419. if (doc.Range.Bookmarks["Fax"] != null)
  8420. {
  8421. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8422. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8423. {
  8424. mark.Text = hr.HotelFax;
  8425. }
  8426. }
  8427. //入住时间
  8428. if (doc.Range.Bookmarks["CIn"] != null)
  8429. {
  8430. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8431. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8432. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8433. }
  8434. //退房时间
  8435. if (doc.Range.Bookmarks["COut"] != null)
  8436. {
  8437. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8438. Bookmark mark = doc.Range.Bookmarks["COut"];
  8439. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8440. }
  8441. //客户名称
  8442. if (doc.Range.Bookmarks["GName"] != null)
  8443. {
  8444. string guestName = "";
  8445. string[] clients = new string[] { };
  8446. if (hr.GuestName.Contains(","))
  8447. {
  8448. clients = hr.GuestName.Split(",");
  8449. }
  8450. else
  8451. {
  8452. clients = new string[] { hr.GuestName };
  8453. }
  8454. List<int> clientIds_int = new List<int>();
  8455. if (clients.Length > 0)
  8456. {
  8457. foreach (var item in clients)
  8458. {
  8459. if (item.IsNumeric())
  8460. {
  8461. clientIds_int.Add(int.Parse(item));
  8462. }
  8463. }
  8464. }
  8465. if (clientIds_int.Count > 0)
  8466. {
  8467. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8468. foreach (var client in _clientDatas)
  8469. {
  8470. //男
  8471. if (client.Sex == 0) guestName += $"Mr.";
  8472. //女
  8473. else if (client.Sex == 1) guestName += $"Ms.";
  8474. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8475. {
  8476. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8477. }
  8478. //guestName += $"{client.Pinyin},";
  8479. }
  8480. if (guestName.Length > 0)
  8481. {
  8482. guestName = guestName.Substring(0, guestName.Length - 1);
  8483. }
  8484. }
  8485. else
  8486. {
  8487. guestName = hr.GuestName;
  8488. }
  8489. Bookmark mark = doc.Range.Bookmarks["GName"];
  8490. mark.Text = guestName;
  8491. }
  8492. //房间介绍
  8493. if (doc.Range.Bookmarks["ROOM"] != null)
  8494. {
  8495. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8496. mark.Text = hr.RoomExplanation;
  8497. }
  8498. //报价描述
  8499. if (doc.Range.Bookmarks["NOTE"] != null)
  8500. {
  8501. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8502. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8503. if (ss != null)
  8504. mark.Text = ss.Name;
  8505. }
  8506. //入住时间
  8507. if (doc.Range.Bookmarks["CheckIn"] != null)
  8508. {
  8509. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8510. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  8511. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  8512. }
  8513. //退房时间
  8514. if (doc.Range.Bookmarks["CheckOut"] != null)
  8515. {
  8516. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8517. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  8518. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8519. }
  8520. //日期
  8521. if (doc.Range.Bookmarks["DT"] != null)
  8522. {
  8523. Bookmark mark = doc.Range.Bookmarks["DT"];
  8524. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8525. }
  8526. //名称
  8527. if (doc.Range.Bookmarks["VName"] != null)
  8528. {
  8529. Bookmark mark = doc.Range.Bookmarks["VName"];
  8530. mark.Text = hr.HotelName;
  8531. }
  8532. //号码
  8533. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  8534. {
  8535. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  8536. mark.Text = hr.CheckNumber;
  8537. }
  8538. #endregion
  8539. strFileName += "VOUCHER.doc";
  8540. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8541. doc.Save(fileDir);
  8542. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8543. return Ok(JsonView(true, "操作成功!", Url));
  8544. }
  8545. else
  8546. {
  8547. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  8548. }
  8549. }
  8550. else
  8551. {
  8552. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  8553. }
  8554. }
  8555. catch (Exception ex)
  8556. {
  8557. return Ok(JsonView(false, ex.Message));
  8558. }
  8559. }
  8560. /// <summary>
  8561. /// 酒店预订
  8562. /// 生成VOUCHER
  8563. /// 2024.05.06 之后版本
  8564. /// </summary>
  8565. /// <param name="_dto"></param>
  8566. /// <returns></returns>
  8567. [HttpPost]
  8568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8569. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  8570. {
  8571. #region 参数验证
  8572. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8573. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8574. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8575. #region 团组操作权限验证 76 酒店预定模块
  8576. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8577. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8578. #endregion
  8579. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8580. #region 页面操作权限验证
  8581. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8582. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8583. #endregion
  8584. #endregion
  8585. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8586. //判断数据是否完整
  8587. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  8588. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8589. string strFileName = "HotelStatement/";
  8590. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8591. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  8592. #region 数据处理
  8593. List<int> guestIds = new List<int>();
  8594. int index = 0;
  8595. foreach (var item in hrDtas)
  8596. {
  8597. if (item.GuestName.Contains(","))
  8598. {
  8599. string[] guestIdArr = item.GuestName.Split(',');
  8600. foreach (var guestIdStr in guestIdArr)
  8601. {
  8602. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  8603. if (guestBool)
  8604. {
  8605. guestIds.Add(guestId);
  8606. }
  8607. }
  8608. }
  8609. else guestNames += item.GuestName;
  8610. var voucherInfo = new HotelVoucherInfoView()
  8611. {
  8612. HotelName = item.HotelName,
  8613. CheckInDate = item.CheckInDate,
  8614. CheckOutDate = item.CheckOutDate,
  8615. ConfirmationNumber = item.DetermineNo.Trim(),
  8616. RoomType = item.RoomExplanation
  8617. };
  8618. vouchers.Add(voucherInfo);
  8619. }
  8620. if (guestIds.Count > 0)
  8621. {
  8622. guestIds = guestIds.Distinct().ToList();
  8623. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  8624. if (guestDatas.Count > 0)
  8625. {
  8626. guestNames = "";
  8627. foreach (var guest in guestDatas)
  8628. {
  8629. string guestName = "";
  8630. if (guest.Sex == 0) guestName += @"MR.";
  8631. else if (guest.Sex == 1) guestName += @"MS.";
  8632. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  8633. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  8634. guestNames += @$"{guestName.Trim()}、";
  8635. }
  8636. if (guestNames.Length > 0)
  8637. {
  8638. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  8639. }
  8640. }
  8641. }
  8642. #endregion
  8643. //载入模板
  8644. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  8645. Document doc = new Document(sss);
  8646. DocumentBuilder builder = new DocumentBuilder(doc);
  8647. if (doc.Range.Bookmarks["GuestName"] != null)
  8648. {
  8649. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  8650. mark.Text = guestNames;
  8651. }
  8652. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8653. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  8654. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  8655. for (int i = 1; i <= vouchers.Count; i++)
  8656. {
  8657. HotelVoucherInfoView hviv = vouchers[i - 1];
  8658. builder.MoveToCell(0, i, 0, 0);
  8659. builder.Write(hviv.HotelName);
  8660. builder.MoveToCell(0, i, 1, 0);
  8661. builder.Write(hviv.CheckInDate);
  8662. builder.MoveToCell(0, i, 2, 0);
  8663. builder.Write(hviv.CheckOutDate);
  8664. builder.MoveToCell(0, i, 3, 0);
  8665. builder.Write(hviv.RoomType);
  8666. builder.MoveToCell(0, i, 4, 0);
  8667. builder.Write(hviv.ConfirmationNumber);
  8668. }
  8669. //删除多余行
  8670. int currRowIndex = vouchers.Count + 1;
  8671. int delRows = 21 - currRowIndex;
  8672. if (delRows > 0)
  8673. {
  8674. for (int i = 0; i < delRows; i++)
  8675. {
  8676. table.Rows.RemoveAt(currRowIndex);
  8677. //cultivateRowIndex++;
  8678. }
  8679. }
  8680. strFileName += "VOUCHER.docx";
  8681. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  8682. doc.Save(fileDir);
  8683. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  8684. return Ok(JsonView(true, "操作成功!", Url));
  8685. }
  8686. /// <summary>
  8687. /// 酒店预订
  8688. /// 生成 预定成本 Excel
  8689. /// </summary>
  8690. /// <param name="_dto"></param>
  8691. /// <returns></returns>
  8692. [HttpPost]
  8693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8694. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  8695. {
  8696. #region 参数验证
  8697. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  8698. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  8699. if (!vadalitorRes.IsValid)
  8700. {
  8701. var errors = new StringBuilder();
  8702. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  8703. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  8704. }
  8705. #region 团组操作权限验证 76 酒店预定模块
  8706. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8707. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8708. #endregion
  8709. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8710. #region 页面操作权限验证
  8711. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8712. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8713. #endregion
  8714. #endregion
  8715. decimal _rate = 1.00M;
  8716. string _currency = "";
  8717. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  8718. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  8719. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  8720. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  8721. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  8722. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  8723. {
  8724. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  8725. }
  8726. _currency = _GroupCostParameter.Currency;
  8727. bool isIntType = int.TryParse(_currency, out int currId);
  8728. if (isIntType)
  8729. {
  8730. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  8731. }
  8732. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  8733. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  8734. if (currInfo == null)
  8735. {
  8736. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  8737. }
  8738. if (!_currency.ToUpper().Equals("CNY"))
  8739. {
  8740. _rate = _GroupCostParameter.Rate;
  8741. }
  8742. _rate = currInfo.Rate;
  8743. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  8744. string strFileName = "HotelStatement/";
  8745. string guestNames = ""; //格式Mr.xxx Ms.xxx
  8746. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  8747. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  8748. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  8749. #region 数据处理
  8750. foreach (var item in hrDtas)
  8751. {
  8752. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  8753. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  8754. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  8755. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  8756. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  8757. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  8758. string singleRoomFeeStr = string.Empty,
  8759. doubleRoomFeeStr = string.Empty,
  8760. suiteRoomFeeStr = string.Empty,
  8761. otherRoomFeeStr = string.Empty,
  8762. payMoneyStr = string.Empty,
  8763. cardPriceStr = string.Empty;
  8764. if (roomCurr.Equals(_currency))
  8765. {
  8766. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  8767. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  8768. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  8769. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  8770. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  8771. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  8772. }
  8773. else
  8774. {
  8775. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  8776. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  8777. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  8778. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  8779. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  8780. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  8781. }
  8782. string breakfastPriceStr = string.Empty,
  8783. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  8784. governmentRentStr = string.Empty,
  8785. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  8786. cityTaxStrStr = string.Empty,
  8787. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  8788. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  8789. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  8790. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  8791. pcfds.Add(new HotelReservations_PCFD_View()
  8792. {
  8793. City = item.City,
  8794. HotelName = item.HotelName,
  8795. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  8796. // SingleRoomCount = item.SingleRoomCount,
  8797. SingleRoomPrice = singleRoomFeeStr,
  8798. // DoubleRoomCount = item.DoubleRoomCount,
  8799. DoubleRoomPrice = doubleRoomFeeStr,
  8800. //SuiteRoomCount = item.SuiteRoomCount,
  8801. SuiteRoomPrice = suiteRoomFeeStr,
  8802. OtherRoomPrice = otherRoomFeeStr,
  8803. //OtherRoomCount = item.OtherRoomCount,
  8804. BreakfastPrice = breakfastPriceStr,
  8805. GovernmentRent = governmentRentStr,
  8806. CityTax = cityTaxStrStr,
  8807. RoomExplanation = item.RoomExplanation,
  8808. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  8809. PayTime = roomInfo.ConsumptionDate,
  8810. BankNo = roomInfo.BankNo,
  8811. PayMoney = payMoneyStr,
  8812. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  8813. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  8814. CardPrice = cardPriceStr,
  8815. Remark = ccpInfo.Remark
  8816. });
  8817. }
  8818. #endregion
  8819. //载入模板
  8820. WorkbookDesigner designer = new WorkbookDesigner();
  8821. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  8822. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  8823. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  8824. designer.SetDataSource("TourNo", groupInfo.TourCode);
  8825. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  8826. designer.SetDataSource("Opertor", userInfo.CnName);
  8827. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  8828. dt.TableName = "ViewMyHotelReservations";
  8829. designer.SetDataSource(dt);
  8830. designer.Process();
  8831. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  8832. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  8833. designer.Workbook.Save(serverPath);
  8834. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  8835. #region 删除指定行
  8836. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  8837. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  8838. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  8839. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  8840. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  8841. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  8842. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  8843. cssIndex = dt.Columns["CityTax"].Ordinal,
  8844. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  8845. remarkIndex = dt.Columns["Remark"].Ordinal;
  8846. //删除指定列
  8847. foreach (DataRow item in dt.Rows)
  8848. {
  8849. string singleStr = item["SingleRoomPrice"].ToString();
  8850. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  8851. if (containsDigitButNotZero1) singleDel = false;
  8852. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  8853. string doubleStr = item["DoubleRoomPrice"].ToString();
  8854. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8855. if (containsDigitButNotZero2) doubleDel = false;
  8856. string suiteStr = item["SuiteRoomPrice"].ToString();
  8857. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  8858. if (containsDigitButNotZero3) suiteDel = false;
  8859. string otherStr = item["OtherRoomPrice"].ToString();
  8860. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  8861. if (containsDigitButNotZero4) otherDel = false;
  8862. string zcStr = item["BreakfastPrice"].ToString();
  8863. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  8864. if (containsDigitButNotZero5) zcDel = false;
  8865. string dsStr = item["GovernmentRent"].ToString();
  8866. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  8867. if (containsDigitButNotZero6) dsDel = false;
  8868. string cssStr = item["CityTax"].ToString();
  8869. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  8870. if (containsDigitButNotZero7) cssDel = false;
  8871. string cpStr = item["ConsumptionPatterns"].ToString();
  8872. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  8873. string remarkStr = item["Remark"].ToString();
  8874. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  8875. }
  8876. DeleteColumn(serverPath, remarkIndex, remarkDel);
  8877. DeleteColumn(serverPath, cpIndex, cpDel);
  8878. DeleteColumn(serverPath, dsIndex, dsDel);
  8879. DeleteColumn(serverPath, cssIndex, cssDel);
  8880. DeleteColumn(serverPath, zcIndex, zcDel);
  8881. DeleteColumn(serverPath, otherIndex, otherDel);
  8882. DeleteColumn(serverPath, suiteIndex, suiteDel);
  8883. DeleteColumn(serverPath, doubleIndex, doubleDel);
  8884. DeleteColumn(serverPath, singleIndex, singleDel);
  8885. #endregion
  8886. //只保留第一个表格
  8887. DeleteSheet(serverPath);
  8888. return Ok(JsonView(true, "操作成功", url = rst));
  8889. }
  8890. /// <summary>
  8891. /// 删除指定列
  8892. /// </summary>
  8893. /// <param name="file"></param>
  8894. /// <param name="columnIndex"></param>
  8895. /// <param name="isDel"></param>
  8896. private void DeleteColumn(string file, int columnIndex, bool isDel)
  8897. {
  8898. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8899. //wb.Save(file);
  8900. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  8901. if (sheet1 != null)
  8902. {
  8903. if (isDel)
  8904. {
  8905. Cells cells = sheet1.Cells;
  8906. cells.DeleteColumn(columnIndex);
  8907. }
  8908. }
  8909. wb.Save(file);
  8910. }
  8911. /// <summary>
  8912. /// 删除sheet
  8913. /// </summary>
  8914. /// <param name="file"></param>
  8915. /// <param name="sheetName"></param>
  8916. private void DeleteSheet(string file, string sheetName = "")
  8917. {
  8918. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  8919. //wb.Save(file);
  8920. List<string> sheets = new List<string>();
  8921. foreach (var item in wb.Worksheets)
  8922. {
  8923. sheets.Add(item.Name);
  8924. }
  8925. if (sheets.Count > 0)
  8926. {
  8927. sheets.RemoveAt(0);//不删除第一个sheet
  8928. foreach (var item in sheets)
  8929. {
  8930. wb.Worksheets.RemoveAt(item);
  8931. }
  8932. }
  8933. wb.Save(file);
  8934. }
  8935. /// <summary>
  8936. /// 酒店预订
  8937. /// 确认单
  8938. /// </summary>
  8939. /// <param name="_dto"></param>
  8940. /// <returns></returns>
  8941. [HttpPost]
  8942. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8943. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  8944. {
  8945. try
  8946. {
  8947. #region 参数验证
  8948. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  8949. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8950. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  8951. #region 团组操作权限验证 76 酒店预定模块
  8952. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8953. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  8954. #endregion
  8955. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8956. #region 页面操作权限验证
  8957. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8958. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8959. #endregion
  8960. #endregion
  8961. //团组信息
  8962. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  8963. //酒店数据
  8964. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  8965. if (listhoteldata.Count < 0)
  8966. {
  8967. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  8968. }
  8969. //利datatable存储
  8970. DataTable dt = new DataTable();
  8971. dt.Columns.Add("CheckInDate", typeof(string));
  8972. dt.Columns.Add("City", typeof(string));
  8973. dt.Columns.Add("Hotel", typeof(string));
  8974. dt.Columns.Add("Room", typeof(string));
  8975. for (int i = 0; i < listhoteldata.Count; i++)
  8976. {
  8977. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  8978. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  8979. while (dayStart < dayEnd)
  8980. {
  8981. string temp = "";
  8982. DataRow row = dt.NewRow();
  8983. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  8984. row["City"] = listhoteldata[i].City;
  8985. row["Hotel"] = listhoteldata[i].HotelName;
  8986. if (listhoteldata[i].SingleRoomCount > 0)
  8987. {
  8988. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  8989. }
  8990. if (listhoteldata[i].DoubleRoomCount > 0)
  8991. {
  8992. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  8993. }
  8994. if (listhoteldata[i].SuiteRoomCount > 0)
  8995. {
  8996. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  8997. }
  8998. if (listhoteldata[i].OtherRoomCount > 0)
  8999. {
  9000. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9001. }
  9002. row["Room"] = temp;
  9003. dt.Rows.Add(row);
  9004. dayStart = dayStart.AddDays(1);
  9005. }
  9006. }
  9007. Dictionary<string, string> dic = new Dictionary<string, string>();
  9008. dic.Add("Dele", di.TeamName);
  9009. dic.Add("City", di.VisitCountry);
  9010. //模板路径
  9011. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9012. //载入模板
  9013. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9014. DocumentBuilder builder = new DocumentBuilder(doc);
  9015. foreach (var key in dic.Keys)
  9016. {
  9017. builder.MoveToBookmark(key);
  9018. builder.Write(dic[key]);
  9019. }
  9020. //获取word里所有表格
  9021. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9022. //获取所填表格的序数
  9023. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9024. var rowStart = tableOne.Rows[0]; //获取第1行
  9025. //循环赋值
  9026. for (int i = 0; i < dt.Rows.Count; i++)
  9027. {
  9028. builder.MoveToCell(0, i + 1, 0, 0);
  9029. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9030. builder.MoveToCell(0, i + 1, 1, 0);
  9031. builder.Write(dt.Rows[i]["City"].ToString());
  9032. builder.MoveToCell(0, i + 1, 2, 0);
  9033. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9034. builder.MoveToCell(0, i + 1, 3, 0);
  9035. builder.Write(dt.Rows[i]["Room"].ToString());
  9036. }
  9037. //删除多余行
  9038. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9039. {
  9040. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9041. }
  9042. string strFileName = di.TeamName + "酒店确认单.doc";
  9043. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9044. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9045. return Ok(JsonView(true, "成功", url));
  9046. }
  9047. catch (Exception ex)
  9048. {
  9049. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9050. }
  9051. }
  9052. #endregion
  9053. #region 团组状态
  9054. /// <summary>
  9055. /// 团组状态列表 Page
  9056. /// </summary>
  9057. /// <param name="dto">团组列表请求dto</param>
  9058. /// <returns></returns>
  9059. [HttpPost]
  9060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9061. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9062. {
  9063. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9064. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9065. {
  9066. string sqlWhere = string.Empty;
  9067. if (dto.IsSure == 0) //未完成
  9068. {
  9069. sqlWhere += string.Format(@" And IsSure = 0");
  9070. }
  9071. else if (dto.IsSure == 1) //已完成
  9072. {
  9073. sqlWhere += string.Format(@" And IsSure = 1");
  9074. }
  9075. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9076. {
  9077. string tj = dto.SearchCriteria;
  9078. 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}%')",
  9079. tj, tj, tj, tj, tj);
  9080. }
  9081. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9082. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9083. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9084. From (
  9085. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9086. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9087. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9088. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9089. From Grp_DelegationInfo gdi
  9090. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9091. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9092. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9093. Where gdi.IsDel = 0 {0}
  9094. ) temp ", sqlWhere);
  9095. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9096. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9097. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9098. }
  9099. else
  9100. {
  9101. return Ok(JsonView(false, "查询失败"));
  9102. }
  9103. }
  9104. /// <summary>
  9105. /// 团组状态
  9106. /// 设置操作完成
  9107. /// </summary>
  9108. /// <param name="dto">团组列表请求dto</param>
  9109. /// <returns></returns>
  9110. [HttpPost]
  9111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9112. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9113. {
  9114. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9115. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9116. {
  9117. Id = dto.Id,
  9118. IsSure = 1
  9119. };
  9120. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9121. .UpdateColumns(it => new { it.IsSure })
  9122. .WhereColumns(it => new { it.Id })
  9123. .ExecuteCommandAsync();
  9124. if (result > 0)
  9125. {
  9126. return Ok(JsonView(true, "操作完成!"));
  9127. }
  9128. return Ok(JsonView(false, "操作失败!"));
  9129. }
  9130. #endregion
  9131. #region 保险费用录入
  9132. /// <summary>
  9133. /// 根据团组Id查询保险费用列表
  9134. /// </summary>
  9135. /// <param name="dto"></param>
  9136. /// <returns></returns>
  9137. [HttpPost]
  9138. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9139. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9140. {
  9141. try
  9142. {
  9143. Result groupData = await _customersRep.CustomersByDiId(dto);
  9144. if (groupData.Code != 0)
  9145. {
  9146. return Ok(JsonView(false, groupData.Msg));
  9147. }
  9148. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9149. }
  9150. catch (Exception ex)
  9151. {
  9152. return Ok(JsonView(false, ex.Message));
  9153. }
  9154. }
  9155. /// <summary>
  9156. /// 根据保险费用Id查询保险费用详细
  9157. /// </summary>
  9158. /// <param name="dto"></param>
  9159. /// <returns></returns>
  9160. [HttpPost]
  9161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9162. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9163. {
  9164. try
  9165. {
  9166. Result groupData = await _customersRep.CustomersById(dto);
  9167. if (groupData.Code != 0)
  9168. {
  9169. return Ok(JsonView(false, groupData.Msg));
  9170. }
  9171. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9172. }
  9173. catch (Exception ex)
  9174. {
  9175. return Ok(JsonView(false, ex.Message));
  9176. }
  9177. }
  9178. /// <summary>
  9179. /// 保险费用录入页面初始化绑定
  9180. /// </summary>
  9181. /// <param name="dto"></param>
  9182. /// <returns></returns>
  9183. [HttpPost]
  9184. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9185. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9186. {
  9187. try
  9188. {
  9189. Result groupData = await _customersRep.CustomersInitialize(dto);
  9190. if (groupData.Code != 0)
  9191. {
  9192. return Ok(JsonView(false, groupData.Msg));
  9193. }
  9194. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9195. }
  9196. catch (Exception ex)
  9197. {
  9198. return Ok(JsonView(false, ex.Message));
  9199. }
  9200. }
  9201. /// <summary>
  9202. /// 保险费用操作(Status:1.新增,2.修改)
  9203. /// </summary>
  9204. /// <param name="dto"></param>
  9205. /// <returns></returns>
  9206. [HttpPost]
  9207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9208. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9209. {
  9210. try
  9211. {
  9212. Result groupData = await _customersRep.OpCustomers(dto);
  9213. if (groupData.Code != 0)
  9214. {
  9215. return Ok(JsonView(false, groupData.Msg));
  9216. }
  9217. #region 应用推送
  9218. try
  9219. {
  9220. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9221. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9222. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9223. }
  9224. catch (Exception ex)
  9225. {
  9226. }
  9227. #endregion
  9228. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9229. }
  9230. catch (Exception ex)
  9231. {
  9232. return Ok(JsonView(false, ex.Message));
  9233. }
  9234. }
  9235. /// <summary>
  9236. /// 保险文件上传
  9237. /// </summary>
  9238. /// <param name="file"></param>
  9239. /// <returns></returns>
  9240. [HttpPost]
  9241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9242. public async Task<IActionResult> UploadCus(IFormFile file)
  9243. {
  9244. try
  9245. {
  9246. if (file != null)
  9247. {
  9248. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9249. //文件名称
  9250. string projectFileName = file.FileName;
  9251. //上传的文件的路径
  9252. string filePath = "";
  9253. if (!Directory.Exists(fileDir))
  9254. {
  9255. Directory.CreateDirectory(fileDir);
  9256. }
  9257. //上传的文件的路径
  9258. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9259. using (FileStream fs = System.IO.File.Create(filePath))
  9260. {
  9261. file.CopyTo(fs);
  9262. fs.Flush();
  9263. }
  9264. return Ok(JsonView(true, "上传成功!", projectFileName));
  9265. }
  9266. else
  9267. {
  9268. return Ok(JsonView(false, "上传失败!"));
  9269. }
  9270. }
  9271. catch (Exception ex)
  9272. {
  9273. return Ok(JsonView(false, "程序错误!"));
  9274. throw;
  9275. }
  9276. }
  9277. /// <summary>
  9278. /// 保险删除指定文件
  9279. /// </summary>
  9280. /// <param name="dto"></param>
  9281. /// <returns></returns>
  9282. [HttpPost]
  9283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9284. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9285. {
  9286. try
  9287. {
  9288. string filePath = "";
  9289. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9290. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9291. //int id = 0;
  9292. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9293. // 删除该文件
  9294. try
  9295. {
  9296. System.IO.File.Delete(filePath);
  9297. 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()
  9298. {
  9299. Attachment = "",
  9300. }).ExecuteCommandAsync();
  9301. if (result != 0)
  9302. {
  9303. return Ok(JsonView(true, "成功!"));
  9304. }
  9305. else
  9306. {
  9307. return Ok(JsonView(false, "失败!"));
  9308. }
  9309. }
  9310. catch (Exception)
  9311. {
  9312. 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()
  9313. {
  9314. Attachment = "",
  9315. }).ExecuteCommandAsync();
  9316. if (result != 0)
  9317. {
  9318. return Ok(JsonView(true, "成功!"));
  9319. }
  9320. else
  9321. {
  9322. return Ok(JsonView(false, "失败!"));
  9323. }
  9324. }
  9325. }
  9326. catch (Exception ex)
  9327. {
  9328. return Ok(JsonView(false, "程序错误!"));
  9329. throw;
  9330. }
  9331. }
  9332. /// <summary>
  9333. /// 保险费用操作(删除)
  9334. /// </summary>
  9335. /// <param name="dto"></param>
  9336. /// <returns></returns>
  9337. [HttpPost]
  9338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9339. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9340. {
  9341. try
  9342. {
  9343. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9344. if (!res)
  9345. {
  9346. return Ok(JsonView(false, "删除失败"));
  9347. }
  9348. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9349. {
  9350. IsDel = 1,
  9351. DeleteUserId = dto.DeleteUserId,
  9352. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9353. }).ExecuteCommandAsync();
  9354. return Ok(JsonView(true, "删除成功!"));
  9355. }
  9356. catch (Exception ex)
  9357. {
  9358. return Ok(JsonView(false, "程序错误!"));
  9359. throw;
  9360. }
  9361. }
  9362. #endregion
  9363. #region 接团客户名单 PageId 104
  9364. /// <summary>
  9365. /// 接团客户名单
  9366. /// 迁移数据(慎用!)
  9367. /// </summary>
  9368. /// <param name="dto"></param>
  9369. /// <returns></returns>
  9370. [HttpPost]
  9371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9372. public async Task<IActionResult> PostTourClientListChange()
  9373. {
  9374. try
  9375. {
  9376. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9377. //var groupClinetData1
  9378. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9379. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9380. int updateCount = 0;
  9381. if (oldOAClientList.Count > 0)
  9382. {
  9383. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9384. _sqlSugar.BeginTran();
  9385. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9386. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9387. foreach (var item in oldOAClientList)
  9388. {
  9389. int comId = 0;
  9390. string format = "yyyy-MM-dd HH:mm:ss";
  9391. string data11 = "1990-01-01 00:00";
  9392. var data1 = IsValidDate(item.OPdate, format);
  9393. if (data1) data11 = item.OPdate;
  9394. //客户公司验证
  9395. if (!string.IsNullOrEmpty(item.Company))
  9396. {
  9397. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9398. if (clientComInfo == null) // add
  9399. {
  9400. var addInfo = new Crm_CustomerCompany()
  9401. {
  9402. CompanyAbbreviation = "",
  9403. CompanyFullName = item.Company,
  9404. Address = "",
  9405. PostCodes = "",
  9406. LastedOpUserId = item.OPer,
  9407. LastedOpDt = Convert.ToDateTime(data11),
  9408. CreateUserId = item.OPer,
  9409. CreateTime = Convert.ToDateTime(data11),
  9410. IsDel = 0
  9411. };
  9412. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9413. if (comId1 > 0) comId = comId1;
  9414. }
  9415. else comId = clientComInfo.Id;
  9416. }
  9417. //客户人员验证
  9418. int clientId = 0;
  9419. string name = item.LastName + item.Name;
  9420. if (!string.IsNullOrEmpty(name))
  9421. {
  9422. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9423. if (clientInfo == null)
  9424. {
  9425. DateTime? dateTime = null;
  9426. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9427. if (isDt) dateTime = birthDayDt;
  9428. var addInfo1 = new Crm_DeleClient()
  9429. {
  9430. CrmCompanyId = comId,
  9431. DiId = -1,
  9432. LastName = item.LastName,
  9433. FirstName = item.Name,
  9434. OldName = "",
  9435. Pinyin = item.Pinyin,
  9436. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9437. Marriage = 0,
  9438. Phone = item.Phone,
  9439. Job = item.Job,
  9440. BirthDay = dateTime
  9441. };
  9442. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9443. if (clientId1 > 0) clientId = clientId1;
  9444. }
  9445. else clientId = clientInfo.Id;
  9446. }
  9447. if (clientId < 1)
  9448. {
  9449. continue;
  9450. }
  9451. int airType = 0;
  9452. if (item.AirType == "超经舱") airType = 459;
  9453. else if (item.AirType == "公务舱") airType = 458;
  9454. else if (item.AirType == "经济舱") airType = 460;
  9455. else if (item.AirType == "其他") airType = 565;
  9456. else if (item.AirType == "头等舱") airType = 457;
  9457. var _TourClientListEntity = new Grp_TourClientList()
  9458. {
  9459. DiId = item.Diid,
  9460. ClientId = clientId,
  9461. CreateUserId = item.OPer,
  9462. CreateTime = Convert.ToDateTime(data11),
  9463. Remark = item.Remark,
  9464. IsDel = item.Isdel,
  9465. ShippingSpaceTypeId = airType,
  9466. ShippingSpaceSpecialNeeds = item.AirRemark,
  9467. HotelSpecialNeeds = item.RoomType
  9468. };
  9469. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9470. if (_TourClientList > 0)
  9471. {
  9472. updateCount++;
  9473. }
  9474. }
  9475. _sqlSugar.CommitTran();
  9476. }
  9477. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9478. }
  9479. catch (Exception ex)
  9480. {
  9481. _sqlSugar.RollbackTran();
  9482. return Ok(JsonView(false, ex.Message));
  9483. }
  9484. return Ok(JsonView(true));
  9485. }
  9486. private bool IsValidDate(string dateString, string format)
  9487. {
  9488. DateTime dateValue;
  9489. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9490. return valid;
  9491. }
  9492. /// <summary>
  9493. /// 接团客户名单
  9494. /// 根据团组Id查询List
  9495. /// </summary>
  9496. /// <param name="dto"></param>
  9497. /// <returns></returns>
  9498. [HttpPost]
  9499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9500. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9501. {
  9502. #region 参数验证
  9503. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9504. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9505. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  9506. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9507. #region 页面操作权限验证
  9508. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9509. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9510. #endregion
  9511. #endregion
  9512. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  9513. if (viewData.Code != 0)
  9514. {
  9515. return Ok(JsonView(false, viewData.Msg));
  9516. }
  9517. return Ok(JsonView(viewData.Data));
  9518. }
  9519. /// <summary>
  9520. /// 接团客户名单
  9521. /// 基础数据 Init
  9522. /// </summary>
  9523. /// <param name="_dto"></param>
  9524. /// <returns></returns>
  9525. [HttpPost]
  9526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9527. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  9528. {
  9529. #region 参数验证
  9530. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9531. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9532. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9533. #region 页面操作权限验证
  9534. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9535. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9536. #endregion
  9537. #endregion
  9538. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  9539. if (viewData.Code != 0)
  9540. {
  9541. return Ok(JsonView(false, viewData.Msg));
  9542. }
  9543. return Ok(JsonView(viewData.Data));
  9544. }
  9545. /// <summary>
  9546. /// 接团客户名单
  9547. /// 根据 Id查询 Details
  9548. /// </summary>
  9549. /// <param name="_dto"></param>
  9550. /// <returns></returns>
  9551. [HttpPost]
  9552. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9553. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  9554. {
  9555. #region 参数验证
  9556. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9557. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9558. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9559. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9560. #region 页面操作权限验证
  9561. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9562. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  9563. #endregion
  9564. #endregion
  9565. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  9566. if (viewData.Code != 0)
  9567. {
  9568. return Ok(JsonView(false, viewData.Msg));
  9569. }
  9570. return Ok(JsonView(viewData.Data));
  9571. }
  9572. /// <summary>
  9573. /// 接团客户名单
  9574. /// Add Or Edit
  9575. /// </summary>
  9576. /// <param name="_dto"></param>
  9577. /// <returns></returns>
  9578. [HttpPost]
  9579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9580. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  9581. {
  9582. #region 参数验证
  9583. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9584. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9585. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  9586. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9587. #region 页面操作权限验证
  9588. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9589. if (_dto.Id == 0) //添加
  9590. {
  9591. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9592. }
  9593. else if (_dto.Id >= 0) //修改
  9594. {
  9595. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  9596. }
  9597. #endregion
  9598. #endregion
  9599. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  9600. if (viewData.Code != 0)
  9601. {
  9602. return Ok(JsonView(false, viewData.Msg));
  9603. }
  9604. return Ok(JsonView(true));
  9605. }
  9606. /// <summary>
  9607. /// 接团客户名单
  9608. /// AddMultiple(添加多个)
  9609. /// </summary>
  9610. /// <param name="_dto"></param>
  9611. /// <returns></returns>
  9612. [HttpPost]
  9613. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9614. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  9615. {
  9616. #region 参数验证
  9617. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9618. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9619. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9620. #region 页面操作权限验证
  9621. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9622. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  9623. #endregion
  9624. #endregion
  9625. var viewData = await _tourClientListRep._AddMultiple(_dto);
  9626. if (viewData.Code != 0)
  9627. {
  9628. return Ok(JsonView(false, viewData.Msg));
  9629. }
  9630. return Ok(JsonView(true));
  9631. }
  9632. /// <summary>
  9633. /// 接团客户名单
  9634. /// Del
  9635. /// </summary>
  9636. /// <param name="_dto"></param>
  9637. /// <returns></returns>
  9638. [HttpPost]
  9639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9640. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  9641. {
  9642. #region 参数验证
  9643. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9644. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9645. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9646. #region 页面操作权限验证
  9647. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9648. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  9649. #endregion
  9650. #endregion
  9651. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  9652. if (viewData.Code != 0)
  9653. {
  9654. return Ok(JsonView(false, viewData.Msg));
  9655. }
  9656. return Ok(JsonView(true));
  9657. }
  9658. /// <summary>
  9659. /// 接团客户名单
  9660. /// 文件下载 客户名单
  9661. /// </summary>
  9662. /// <param name="_dto"></param>
  9663. /// <returns></returns>
  9664. [HttpPost]
  9665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9666. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  9667. {
  9668. #region 参数验证
  9669. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  9670. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  9671. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  9672. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9673. #region 页面操作权限验证
  9674. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9675. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9676. #endregion
  9677. #endregion
  9678. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9679. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9680. From Grp_TourClientList tcl
  9681. Left Join
  9682. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9683. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9684. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9685. From Crm_DeleClient dc
  9686. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9687. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9688. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9689. Where dc.IsDel = 0) temp
  9690. On temp.DcId =tcl.ClientId
  9691. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  9692. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  9693. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  9694. //载入模板
  9695. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  9696. if (_dto.Language == 1)
  9697. {
  9698. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  9699. }
  9700. //载入模板
  9701. var doc = new Document(tempPath);
  9702. DocumentBuilder builder = new DocumentBuilder(doc);
  9703. //获取word里所有表格
  9704. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9705. //获取所填表格的序数
  9706. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9707. var rowStart = tableOne.Rows[0]; //获取第1行
  9708. if (_dto.Language == 0)
  9709. {
  9710. //循环赋值
  9711. for (int i = 0; i < DcList.Count; i++)
  9712. {
  9713. builder.MoveToCell(0, i + 1, 0, 0);
  9714. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  9715. builder.MoveToCell(0, i + 1, 1, 0);
  9716. int sex = DcList[i].Sex;
  9717. string sexStr = string.Empty;
  9718. if (sex == 0) sexStr = "男";
  9719. else if (sex == 1) sexStr = "女";
  9720. else sexStr = "未设置";
  9721. builder.Write(sexStr);
  9722. builder.MoveToCell(0, i + 1, 2, 0);
  9723. string birthDay = DcList[i].BirthDay;
  9724. string birthDayStr = string.Empty;
  9725. if (!string.IsNullOrEmpty(birthDay))
  9726. {
  9727. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  9728. }
  9729. builder.Write(birthDayStr);
  9730. builder.MoveToCell(0, i + 1, 3, 0);
  9731. string company = "";
  9732. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9733. {
  9734. company = DcList[i].CompanyFullName.ToString();
  9735. }
  9736. builder.Write(company);
  9737. builder.MoveToCell(0, i + 1, 4, 0);
  9738. builder.Write(DcList[i].Job);
  9739. }
  9740. }
  9741. else if (_dto.Language == 1)
  9742. {
  9743. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  9744. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  9745. //循环赋值
  9746. for (int i = 0; i < DcList.Count; i++)
  9747. {
  9748. string PYName = "";
  9749. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  9750. {
  9751. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  9752. string PY_First = DcList[i].Pinyin.Split('/')[1];
  9753. PYName = PY_First + " " + PY_Last;
  9754. }
  9755. else
  9756. {
  9757. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  9758. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  9759. PYName = PY_First + " " + PY_Last;
  9760. }
  9761. builder.MoveToCell(0, i + 1, 0, 0);
  9762. builder.Write(PYName);
  9763. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  9764. builder.MoveToCell(0, i + 1, 1, 0);
  9765. builder.Write(sex);
  9766. DateTime birthDt;
  9767. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  9768. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  9769. builder.MoveToCell(0, i + 1, 2, 0);
  9770. builder.Write(birthday);
  9771. string company = "";
  9772. try
  9773. {
  9774. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  9775. {
  9776. //查询对照表
  9777. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  9778. if (tempCec != null)
  9779. {
  9780. company = tempCec.enName;
  9781. }
  9782. //翻译
  9783. else
  9784. {
  9785. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  9786. }
  9787. }
  9788. }
  9789. catch (Exception)
  9790. {
  9791. }
  9792. builder.MoveToCell(0, i + 1, 3, 0);
  9793. builder.Write(company);
  9794. string job = "";
  9795. try
  9796. {
  9797. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  9798. {
  9799. //查询对照表
  9800. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  9801. if (tempPec != null)
  9802. {
  9803. job = tempPec.enName;
  9804. }
  9805. //翻译
  9806. else
  9807. {
  9808. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  9809. }
  9810. }
  9811. }
  9812. catch (Exception ex)
  9813. {
  9814. }
  9815. builder.MoveToCell(0, i + 1, 4, 0);
  9816. builder.Write(job);
  9817. }
  9818. }
  9819. //删除多余行
  9820. while (tableOne.Rows.Count > DcList.Count + 1)
  9821. {
  9822. tableOne.Rows.RemoveAt(DcList.Count + 1);
  9823. }
  9824. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  9825. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  9826. doc.Save(fileDir);
  9827. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  9828. return Ok(JsonView(true, "操作成功!", Url));
  9829. }
  9830. #endregion
  9831. #region 团组倒推表
  9832. /// <summary>
  9833. /// 倒推表基础数据
  9834. /// Init
  9835. /// </summary>
  9836. /// <param name="dto"></param>
  9837. /// <returns></returns>
  9838. [HttpPost]
  9839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9840. public async Task<IActionResult> PostInvertedListInit()
  9841. {
  9842. var viewData = await _invertedListRep._Init();
  9843. if (viewData.Code != 0)
  9844. {
  9845. return Ok(JsonView(false, viewData.Msg));
  9846. }
  9847. return Ok(JsonView(viewData.Data));
  9848. }
  9849. /// <summary>
  9850. /// 倒推表
  9851. /// Info
  9852. /// </summary>
  9853. /// <param name="dto"></param>
  9854. /// <returns></returns>
  9855. [HttpPost]
  9856. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9857. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  9858. {
  9859. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  9860. if (viewData.Code != 0)
  9861. {
  9862. return Ok(JsonView(false, viewData.Msg));
  9863. }
  9864. return Ok(JsonView(viewData.Data));
  9865. }
  9866. /// <summary>
  9867. /// 倒推表
  9868. /// Create
  9869. /// </summary>
  9870. /// <param name="dto"></param>
  9871. /// <returns></returns>
  9872. [HttpPost]
  9873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9874. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  9875. {
  9876. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  9877. if (viewData.Code != 0)
  9878. {
  9879. return Ok(JsonView(false, viewData.Msg));
  9880. }
  9881. return Ok(JsonView(viewData.Data));
  9882. }
  9883. /// <summary>
  9884. /// 倒推表
  9885. /// Update
  9886. /// </summary>
  9887. /// <param name="dto"></param>
  9888. /// <returns></returns>
  9889. [HttpPost]
  9890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9891. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  9892. {
  9893. var viewData = await _invertedListRep._Update(dto);
  9894. if (viewData.Code != 0)
  9895. {
  9896. return Ok(JsonView(false, viewData.Msg));
  9897. }
  9898. return Ok(JsonView(viewData.Data));
  9899. }
  9900. /// <summary>
  9901. /// 倒推表
  9902. /// File Download
  9903. /// </summary>
  9904. /// <param name="dto"></param>
  9905. /// <returns></returns>
  9906. [HttpPost]
  9907. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9908. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  9909. {
  9910. var info2 = await _invertedListRep._Info(1, dto.DiId);
  9911. if (info2.Code != 0)
  9912. {
  9913. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  9914. }
  9915. var info1 = info2.Data as InvertedListInfoView;
  9916. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  9917. string teamName = "";
  9918. if (info != null) teamName = info.TeamName;
  9919. //载入模板
  9920. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  9921. DocumentBuilder builder = new DocumentBuilder(doc);
  9922. //利用键值对存放数据
  9923. Dictionary<string, string> dic = new Dictionary<string, string>();
  9924. dic.Add("TeamName", teamName);
  9925. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  9926. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  9927. dic.Add("BPRemark", info1.ApprovalDataRemark);
  9928. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  9929. dic.Add("SQRemark", info1.ApprovalRemark);
  9930. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  9931. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  9932. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  9933. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  9934. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  9935. dic.Add("QZRemark", info1.VisaInformationRemark);
  9936. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  9937. dic.Add("SQQZRemark", info1.SendVisaRemark);
  9938. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  9939. dic.Add("CQRemark", info1.IssueVisaRemark);
  9940. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  9941. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  9942. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  9943. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  9944. #region 填充word模板书签内容
  9945. foreach (var key in dic.Keys)
  9946. {
  9947. builder.MoveToBookmark(key);
  9948. builder.Write(dic[key]);
  9949. }
  9950. #endregion
  9951. var fileDir = AppSettingsHelper.Get("WordBasePath");
  9952. string fileName = $"{teamName}团出行准备流程表.doc";
  9953. string filePath = fileDir + $@"InvertedList/{fileName}";
  9954. doc.Save(filePath);
  9955. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  9956. return Ok(JsonView(true, "操作成功!", Url));
  9957. }
  9958. #endregion
  9959. #region 三公签证费用(签证费、代办费)
  9960. /// <summary>
  9961. /// 三公签证费用(签证费、代办费)
  9962. /// List
  9963. /// </summary>
  9964. /// <returns></returns>
  9965. [HttpPost]
  9966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9967. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  9968. {
  9969. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  9970. if (_view.Code != 0)
  9971. {
  9972. return Ok(JsonView(false, _view.Msg));
  9973. }
  9974. return Ok(JsonView(true, "操作成功!", _view.Data));
  9975. }
  9976. /// <summary>
  9977. /// 三公签证费用(签证费、代办费)
  9978. /// Add Or Update
  9979. /// </summary>
  9980. /// <returns></returns>
  9981. [HttpPost]
  9982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9983. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  9984. {
  9985. var _view = await _visaFeeInfoRep._Update(_dto);
  9986. if (_view.Code != 0)
  9987. {
  9988. return Ok(JsonView(false, _view.Msg));
  9989. }
  9990. return Ok(JsonView(true, _view.Msg));
  9991. }
  9992. #endregion
  9993. #region 酒店询价
  9994. /// <summary>
  9995. /// 酒店询价
  9996. /// Init
  9997. /// </summary>
  9998. /// <param name="dto"></param>
  9999. /// <returns></returns>
  10000. [HttpPost]
  10001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10002. public async Task<IActionResult> PostHotelInquiryInit()
  10003. {
  10004. var res = await _hotelInquiryRep._Init();
  10005. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10006. return Ok(JsonView(true, res.Msg, res.Data));
  10007. }
  10008. /// <summary>
  10009. /// 酒店询价
  10010. /// page Item
  10011. /// </summary>
  10012. /// <param name="_dto"></param>
  10013. /// <returns></returns>
  10014. [HttpPost]
  10015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10016. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10017. {
  10018. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10019. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10020. var view = res.Data as PageDataViewBase;
  10021. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10022. }
  10023. /// <summary>
  10024. /// 酒店询价
  10025. /// info
  10026. /// </summary>
  10027. /// <param name="_dto"></param>
  10028. /// <returns></returns>
  10029. [HttpPost]
  10030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10031. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10032. {
  10033. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10034. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10035. return Ok(JsonView(true, res.Msg, res.Data));
  10036. }
  10037. /// <summary>
  10038. /// 酒店询价
  10039. /// Add Or Edit
  10040. /// </summary>
  10041. /// <param name="_dto"></param>
  10042. /// <returns></returns>
  10043. [HttpPost]
  10044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10045. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10046. {
  10047. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10048. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10049. return Ok(JsonView(true, res.Msg, res.Data));
  10050. }
  10051. /// <summary>
  10052. /// 酒店询价
  10053. /// Del
  10054. /// </summary>
  10055. /// <param name="_dto"></param>
  10056. /// <returns></returns>
  10057. [HttpPost]
  10058. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10059. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10060. {
  10061. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10062. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10063. return Ok(JsonView(true, res.Msg, res.Data));
  10064. }
  10065. #endregion
  10066. #region 下载匹配op行程单
  10067. /// <summary>
  10068. /// 匹配op行程单
  10069. /// Init
  10070. /// </summary>
  10071. /// <param name="dto">团组列表请求dto</param>
  10072. /// <returns></returns>
  10073. [HttpPost]
  10074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10075. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10076. {
  10077. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10078. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10079. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10080. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10081. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  10082. .Where(it => it.IsDel == 0)
  10083. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  10084. .OrderByDescending(it => it.CreateUserId)
  10085. .ToList();
  10086. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  10087. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10088. var diids = groupInfos.Select(it => it.Id).ToList();
  10089. List<string> countrys = new List<string>();
  10090. foreach (var item in country)
  10091. {
  10092. var data = _groupRepository.FormartTeamName(item);
  10093. var dataArray = _groupRepository.GroupSplitCountry(data);
  10094. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10095. }
  10096. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  10097. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10098. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  10099. foreach (var item in areaItem)
  10100. {
  10101. string areaStr = item.Value;
  10102. if (!string.IsNullOrEmpty(areaStr))
  10103. {
  10104. string[] str1 = areaStr.Split("-");
  10105. if (str1.Length > 0)
  10106. {
  10107. areaArray.AddRange(str1);
  10108. }
  10109. }
  10110. }
  10111. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10112. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  10113. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  10114. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  10115. .ToList();
  10116. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  10117. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  10118. .Where(it => countriesIds.Contains(it.Id))
  10119. .Select(it => new { it.Id, Name = it.Name_CN })
  10120. .ToList();
  10121. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  10122. .Select(it => it.TeamName).ToList();
  10123. stopwatch.Stop();
  10124. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  10125. }
  10126. ///// <summary>
  10127. ///// 匹配op行程单
  10128. ///// Init 查询区域数据
  10129. ///// </summary>
  10130. ///// <param name="dto">团组列表请求dto</param>
  10131. ///// <returns></returns>
  10132. //[HttpPost]
  10133. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10134. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10135. //{
  10136. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10137. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10138. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10139. // if (string.IsNullOrEmpty(countriesDataStr))
  10140. // {
  10141. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10142. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10143. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10144. // }
  10145. // else
  10146. // {
  10147. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10148. // }
  10149. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10150. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10151. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10152. // List<dynamic> childList = new List<dynamic>();
  10153. // int parentId = dto.CountriesId;
  10154. // if (provinceData.Count > 1)
  10155. // {
  10156. // foreach (var item1 in provinceData)
  10157. // {
  10158. // List<dynamic> childList1 = new List<dynamic>();
  10159. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10160. // foreach (var item2 in citiesData1)
  10161. // {
  10162. // List<dynamic> childList2 = new List<dynamic>();
  10163. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10164. // foreach (var item3 in countiesData1)
  10165. // {
  10166. // childList2.Add(new
  10167. // {
  10168. // id = item3.Id,
  10169. // parentId = item2.Id,
  10170. // level = "district",
  10171. // name = item3.Name_CN,
  10172. // });
  10173. // }
  10174. // childList1.Add(new
  10175. // {
  10176. // id = item2.Id,
  10177. // parentId = item1.Id,
  10178. // level = "city",
  10179. // name = item2.Name_CN,
  10180. // childList = childList2
  10181. // });
  10182. // }
  10183. // childList.Add(new
  10184. // {
  10185. // id = item1.Id,
  10186. // parentId = parentId,
  10187. // level = "province",
  10188. // name = item1.Name_CN,
  10189. // childList = childList1
  10190. // });
  10191. // }
  10192. // //城市
  10193. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10194. // foreach (var item2 in citiesData2)
  10195. // {
  10196. // List<dynamic> childList22 = new List<dynamic>();
  10197. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10198. // foreach (var item3 in countiesData1)
  10199. // {
  10200. // childList22.Add(new
  10201. // {
  10202. // id = item3.Id,
  10203. // parentId = item2.Id,
  10204. // level = "district",
  10205. // name = item3.Name_CN,
  10206. // });
  10207. // }
  10208. // childList.Add(new
  10209. // {
  10210. // id = item2.Id,
  10211. // parentId = parentId,
  10212. // level = "city",
  10213. // name = item2.Name_CN,
  10214. // childList = childList22
  10215. // });
  10216. // }
  10217. // }
  10218. // else
  10219. // {
  10220. // foreach (var item2 in citiesData)
  10221. // {
  10222. // string cname = item2.Name_CN;
  10223. // List<dynamic> childList1 = new List<dynamic>();
  10224. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10225. // foreach (var item3 in countiesData1)
  10226. // {
  10227. // childList1.Add(new
  10228. // {
  10229. // Id = item3.Id,
  10230. // parentId = item2.Id,
  10231. // level = "district",
  10232. // name = item3.Name_CN
  10233. // });
  10234. // }
  10235. // childList.Add(new
  10236. // {
  10237. // id = item2.Id,
  10238. // parentId = parentId,
  10239. // level = "city",
  10240. // name = item2.Name_CN,
  10241. // childList = childList1
  10242. // });
  10243. // }
  10244. // }
  10245. // stopwatch.Stop();
  10246. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10247. //}
  10248. /// <summary>
  10249. /// 匹配op行程单
  10250. /// 接团信息列表 Page
  10251. /// </summary>
  10252. /// <param name="dto">团组列表请求dto</param>
  10253. /// <returns></returns>
  10254. [HttpPost]
  10255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10256. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10257. {
  10258. var swatch = new Stopwatch();
  10259. swatch.Start();
  10260. #region 参数验证
  10261. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10262. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10263. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10264. #region 页面操作权限验证
  10265. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10266. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10267. #endregion
  10268. #endregion
  10269. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10270. {
  10271. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10272. string sqlWhere = "";
  10273. if (!string.IsNullOrEmpty(dto.Country))
  10274. {
  10275. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  10276. }
  10277. if (!string.IsNullOrEmpty(dto.Area))
  10278. {
  10279. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  10280. }
  10281. if (!string.IsNullOrEmpty(dto.TeamName))
  10282. {
  10283. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  10284. }
  10285. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  10286. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  10287. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  10288. swatch.Stop();
  10289. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  10290. }
  10291. else
  10292. {
  10293. return Ok(JsonView(false, "查询失败"));
  10294. }
  10295. }
  10296. /// <summary>
  10297. /// 匹配op行程单
  10298. /// 行程单下载
  10299. /// </summary>
  10300. /// <param name="dto">团组列表请求dto</param>
  10301. /// <returns></returns>
  10302. [HttpPost]
  10303. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10304. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10305. {
  10306. #region 参数验证
  10307. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10308. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10309. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10310. #region 页面操作权限验证
  10311. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10312. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10313. #endregion
  10314. #endregion
  10315. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10316. {
  10317. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  10318. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10319. }
  10320. else
  10321. {
  10322. return Ok(JsonView(false, "下载失败!"));
  10323. }
  10324. }
  10325. #endregion
  10326. #region 国家信息 数据 注释
  10327. //[HttpPost]
  10328. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10329. //{
  10330. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10331. // foreach (var item in dto)
  10332. // {
  10333. // infos.Add(new Grp_GroupsTaskAssignment()
  10334. // {
  10335. // DIId = item,
  10336. // CTId = 82,
  10337. // UId = 248,
  10338. // IsEnable = 1,
  10339. // CreateUserId = 233,
  10340. // CreateTime = DateTime.Now,
  10341. // IsDel = 0
  10342. // });
  10343. // infos.Add(new Grp_GroupsTaskAssignment()
  10344. // {
  10345. // DIId = item,
  10346. // CTId = 82,
  10347. // UId = 286,
  10348. // IsEnable = 1,
  10349. // CreateUserId = 233,
  10350. // CreateTime = DateTime.Now,
  10351. // IsDel = 0
  10352. // });
  10353. // }
  10354. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10355. // return Ok("操作成功");
  10356. //}
  10357. //public class paramJsonDto
  10358. //{
  10359. // public List<CountriesInfo> str { get; set; }
  10360. //}
  10361. //[HttpPost]
  10362. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10363. //{
  10364. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10365. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10366. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10367. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10368. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10369. // _sqlSugar.BeginTran();
  10370. // int countitiesIndex = 0;
  10371. // foreach (var item in dto.str)
  10372. // {
  10373. // dynamic data = item.c;
  10374. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10375. // if (data != null)
  10376. // {
  10377. // countitiesIndex++;
  10378. // foreach (var item1 in data)
  10379. // {
  10380. // string cnname = item1.cn;
  10381. // string enname = item1.en;
  10382. // Sys_Cities provinceInfo = new Sys_Cities()
  10383. // {
  10384. // CountriesId = countriesId,
  10385. // Name_CN = cnname,
  10386. // Name_EN = enname,
  10387. // ParentId = 0,
  10388. // IsCapital = 1,
  10389. // CreateUserId = 208,
  10390. // CreateTime = DateTime.Now,
  10391. // IsDel = 0
  10392. // };
  10393. // if (item1.lv == "province") //省份
  10394. // {
  10395. // provinceInfo.Level = 1;
  10396. // int provinceId = 0;
  10397. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10398. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10399. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10400. // var data1 = item1.c;
  10401. // foreach (var item2 in data1)
  10402. // {
  10403. // if (item2.lv == "city")
  10404. // {
  10405. // string citycnname = item2.cn;
  10406. // string cityenname = item2.en;
  10407. // Sys_Cities cityInfo = new Sys_Cities()
  10408. // {
  10409. // CountriesId = countriesId,
  10410. // ParentId = provinceId,
  10411. // Level = 2,
  10412. // Name_CN = citycnname,
  10413. // Name_EN = cityenname,
  10414. // IsCapital = 1,
  10415. // CreateUserId = 208,
  10416. // CreateTime = DateTime.Now,
  10417. // IsDel = 0
  10418. // };
  10419. // if (item2.c != null)
  10420. // {
  10421. // int cityId = 0;
  10422. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10423. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10424. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10425. // foreach (var item3 in item2.c)
  10426. // {
  10427. // if (item3.lv == "district")
  10428. // {
  10429. // var districtInfo = new Sys_Cities()
  10430. // {
  10431. // CountriesId = countriesId,
  10432. // Name_CN = item3.cn,
  10433. // Name_EN = item3.en,
  10434. // Level = 3,
  10435. // ParentId = cityId,
  10436. // IsCapital = 1,
  10437. // CreateUserId = 208,
  10438. // CreateTime = DateTime.Now,
  10439. // IsDel = 0
  10440. // };
  10441. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10442. // //{
  10443. // districts.Add(districtInfo);
  10444. // //}
  10445. // }
  10446. // }
  10447. // }
  10448. // else
  10449. // {
  10450. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10451. // //{
  10452. // cities.Add(cityInfo);
  10453. // //}
  10454. // }
  10455. // }
  10456. // }
  10457. // }
  10458. // else if (item1.lv == "city")//城市
  10459. // {
  10460. // provinceInfo.Level = 2;
  10461. // if (item1.c != null)
  10462. // {
  10463. // int cityId = 0;
  10464. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10465. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10466. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10467. // foreach (var item3 in item1.c)
  10468. // {
  10469. // if (item3.lv == "district")
  10470. // {
  10471. // var districtInfo = new Sys_Cities()
  10472. // {
  10473. // CountriesId = countriesId,
  10474. // Name_CN = item3.cn,
  10475. // Name_EN = item3.en,
  10476. // Level = 3,
  10477. // ParentId = cityId,
  10478. // IsCapital = 1,
  10479. // CreateUserId = 208,
  10480. // CreateTime = DateTime.Now,
  10481. // IsDel = 0
  10482. // };
  10483. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10484. // //{
  10485. // districts.Add(districtInfo);
  10486. // //}
  10487. // }
  10488. // }
  10489. // }
  10490. // else
  10491. // {
  10492. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  10493. // //{
  10494. // cities.Add(provinceInfo);
  10495. // //}
  10496. // }
  10497. // }
  10498. // }
  10499. // }
  10500. // }
  10501. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  10502. // cities = cities.Distinct().ToList();
  10503. // districts = districts.Distinct().ToList();
  10504. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  10505. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  10506. // cities.AddRange(districts);
  10507. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  10508. // //_sqlSugar.RollbackTran();
  10509. // _sqlSugar.CommitTran();
  10510. // return Ok(JsonView(false, "操作成功!"));
  10511. //}
  10512. //[HttpPost]
  10513. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  10514. //{
  10515. // List<CountitiesInfo> infos = dto.MyProperty;
  10516. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  10517. // _sqlSugar.BeginTran();
  10518. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10519. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  10520. // foreach (var item in infos)
  10521. // {
  10522. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  10523. // if (countryInfo != null)
  10524. // {
  10525. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  10526. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  10527. // if (cityInfo1 != null)
  10528. // {
  10529. // cityInfo1.IsCapital = 0;
  10530. // cityInfos.Add(cityInfo1);
  10531. // }
  10532. // }
  10533. // }
  10534. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  10535. // .UpdateColumns(it => it.IsCapital)
  10536. // .WhereColumns(it => it.Id)
  10537. // .ExecuteCommand();
  10538. // //_sqlSugar.RollbackTran();
  10539. // _sqlSugar.CommitTran();
  10540. // return Ok(JsonView(false, "操作成功!"));
  10541. //}
  10542. //public class CounrtiesDto
  10543. //{
  10544. // public List<CountitiesInfo> MyProperty { get; set; }
  10545. //}
  10546. //public class CountitiesInfo
  10547. //{
  10548. // /// <summary>
  10549. // /// 圣约翰
  10550. // /// </summary>
  10551. // public string capital_name_chinese { get; set; }
  10552. // /// <summary>
  10553. // ///
  10554. // /// </summary>
  10555. // public string capital_name { get; set; }
  10556. // /// <summary>
  10557. // ///
  10558. // /// </summary>
  10559. // public string country_type { get; set; }
  10560. // /// <summary>
  10561. // /// 安提瓜和巴布达
  10562. // /// </summary>
  10563. // public string country_name_chinese { get; set; }
  10564. // /// <summary>
  10565. // /// 安提瓜和巴布达
  10566. // /// </summary>
  10567. // public string country_name_chinese_short { get; set; }
  10568. // /// <summary>
  10569. // /// 安提瓜和巴布达
  10570. // /// </summary>
  10571. // public string country_name_chinese_UN { get; set; }
  10572. // /// <summary>
  10573. // ///
  10574. // /// </summary>
  10575. // public string country_name_english_abbreviation { get; set; }
  10576. // /// <summary>
  10577. // ///
  10578. // /// </summary>
  10579. // public string country_name_english_formal { get; set; }
  10580. // /// <summary>
  10581. // ///
  10582. // /// </summary>
  10583. // public string country_name_english_UN { get; set; }
  10584. // /// <summary>
  10585. // ///
  10586. // /// </summary>
  10587. // public string continent_name { get; set; }
  10588. // /// <summary>
  10589. // ///
  10590. // /// </summary>
  10591. // public string subregion_name { get; set; }
  10592. // /// <summary>
  10593. // ///
  10594. // /// </summary>
  10595. // public string country_code2 { get; set; }
  10596. // /// <summary>
  10597. // ///
  10598. // /// </summary>
  10599. // public string country_code3 { get; set; }
  10600. // /// <summary>
  10601. // ///
  10602. // /// </summary>
  10603. // public string phone_code { get; set; }
  10604. //}
  10605. //public class CountriesInfo : BasicInfo
  10606. //{
  10607. // public List<CitiesInfo> c { get; set; }
  10608. //}
  10609. //public class CitiesInfo : BasicInfo
  10610. //{
  10611. // public List<AreaInfo> c { get; set; }
  10612. //}
  10613. //public class AreaInfo : BasicInfo
  10614. //{
  10615. // public List<AreaInfo> c { get; set; }
  10616. //}
  10617. //public class BasicInfo
  10618. //{
  10619. // public string code { get; set; }
  10620. // public string cn { get; set; }
  10621. // public string lv { get; set; }
  10622. // public string en { get; set; }
  10623. //}
  10624. #endregion
  10625. #region 查看邀请方
  10626. /// <summary>
  10627. /// 查看邀请方
  10628. /// 邀请方信息 Init
  10629. /// </summary>
  10630. /// <param name="dto"></param>
  10631. /// <returns></returns>
  10632. [HttpPost]
  10633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10634. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  10635. {
  10636. string sqlWhere = string.Empty;
  10637. if (!string.IsNullOrEmpty(dto.Search))
  10638. {
  10639. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  10640. }
  10641. string sql = string.Format($@"Select
  10642. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  10643. Id,
  10644. UnitName
  10645. From Res_InvitationOfficialActivityData
  10646. Where IsDel = 0
  10647. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  10648. RefAsync<int> total = 0;
  10649. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10650. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  10651. }
  10652. /// <summary>
  10653. /// 查看邀请方
  10654. /// 国家信息 Init
  10655. /// </summary>
  10656. /// <param name="dto"></param>
  10657. /// <returns></returns>
  10658. [HttpPost]
  10659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10660. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  10661. {
  10662. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10663. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10664. var diids = groupInfos.Select(it => it.Id).ToList();
  10665. List<string> countrys = new List<string>();
  10666. foreach (var item in country)
  10667. {
  10668. var data = _groupRepository.FormartTeamName(item);
  10669. var dataArray = _groupRepository.GroupSplitCountry(data);
  10670. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10671. }
  10672. countrys = countrys.Distinct().ToList();
  10673. for (int i = 0; i < countrys.Count; i++)
  10674. {
  10675. string item = countrys[i];
  10676. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10677. {
  10678. countrys.Remove(item);
  10679. i--;
  10680. }
  10681. }
  10682. RefAsync<int> total = 0;
  10683. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10684. .Where(it => countrys.Contains(it.Name_CN))
  10685. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10686. .Select(it => new { id = it.Id, name = it.Name_CN })
  10687. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10688. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10689. }
  10690. /// <summary>
  10691. /// 查看邀请方
  10692. /// 城市信息 Init
  10693. /// </summary>
  10694. /// <param name="dto"></param>
  10695. /// <returns></returns>
  10696. [HttpPost]
  10697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10698. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  10699. {
  10700. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  10701. RefAsync<int> total = 0;
  10702. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  10703. .Where(it => it.CountriesId == dto.CountiesId)
  10704. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  10705. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  10706. .Select(it => new { id = it.Id, name = it.Name_CN })
  10707. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10708. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  10709. }
  10710. /// <summary>
  10711. /// 查看邀请方
  10712. /// 团组名称 Init
  10713. /// </summary>
  10714. /// <param name="dto"></param>
  10715. /// <returns></returns>
  10716. [HttpPost]
  10717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10718. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  10719. {
  10720. var watch = new Stopwatch();
  10721. watch.Start();
  10722. RefAsync<int> total = 0;
  10723. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  10724. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  10725. .Where((oa, di) => oa.IsDel == 0)
  10726. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  10727. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  10728. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  10729. .Distinct()
  10730. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10731. watch.Stop();
  10732. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  10733. }
  10734. /// <summary>
  10735. /// 查看邀请方
  10736. /// 团组 & 邀请方信息
  10737. /// </summary>
  10738. /// <param name="dto"></param>
  10739. /// <returns></returns>
  10740. [HttpPost]
  10741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10742. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  10743. {
  10744. var watch = new Stopwatch();
  10745. watch.Start();
  10746. RefAsync<int> total = 0;
  10747. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  10748. .AS("Grp_DelegationInfo")
  10749. .Includes(x => x.InvitingInfos)
  10750. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  10751. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  10752. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  10753. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  10754. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  10755. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  10756. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10757. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  10758. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  10759. infos.ForEach(x =>
  10760. {
  10761. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  10762. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  10763. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  10764. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  10765. });
  10766. watch.Stop();
  10767. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  10768. }
  10769. #endregion
  10770. #region 报批行程
  10771. /// <summary>
  10772. /// 报批行程初始化
  10773. /// </summary>
  10774. /// <param name="dto"></param>
  10775. /// <returns></returns>
  10776. [HttpPost]
  10777. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  10778. {
  10779. const int chiNumber = 5;
  10780. var jw = JsonView(false);
  10781. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10782. var group = groupList.First();
  10783. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10784. group = groupList.First(x => x.Id == diid);
  10785. if (group == null)
  10786. {
  10787. jw.Msg = "暂无团组!";
  10788. return Ok(jw);
  10789. }
  10790. var data = new
  10791. {
  10792. groupList = groupList.Select(x => new
  10793. {
  10794. x.TeamName,
  10795. x.Id
  10796. }),
  10797. content = new ArrayList(),
  10798. groupInfo = new
  10799. {
  10800. group.VisitDays,
  10801. group.TourCode,
  10802. group.VisitPNumber,
  10803. group.TeamName,
  10804. group.Id,
  10805. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  10806. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  10807. },
  10808. };
  10809. var resultArr = new ArrayList();
  10810. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  10811. if (content.Count == 0)
  10812. {
  10813. var stay = "-";
  10814. var cityPath = "-";
  10815. //添加城市路径以及住宿地
  10816. //黑屏代码数据
  10817. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  10818. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  10819. {
  10820. jw = JsonView(true, "黑屏代码有误!", data);
  10821. return Ok(jw);
  10822. }
  10823. foreach (DataRow row in dtBlack.Rows)
  10824. {
  10825. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  10826. {
  10827. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  10828. return Ok(jw);
  10829. }
  10830. }
  10831. //黑屏代码获取时间区间
  10832. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  10833. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  10834. _sqlSugar.BeginTran();
  10835. for (int i = 0; i < timeArr.Count; i++)
  10836. {
  10837. stay = "-";
  10838. cityPath = "-";
  10839. DateTime NewData = DateTime.Parse(timeArr[i]);
  10840. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  10841. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  10842. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  10843. if (tbSelect.Length > 0)
  10844. {
  10845. List<string> threeCodeStr = new List<string>();
  10846. foreach (var item in tbSelect)
  10847. {
  10848. var threeCode = item["Three"].ToString() ?? "";
  10849. if (threeCode.Length == 6)
  10850. {
  10851. var start = threeCode.Substring(0, 3);
  10852. var end = threeCode.Substring(3, 3);
  10853. if (threeCodeStr.Count == 0)
  10854. {
  10855. threeCodeStr.Add(start);
  10856. threeCodeStr.Add(end);
  10857. }
  10858. else
  10859. {
  10860. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  10861. {
  10862. threeCodeStr.Add(end);
  10863. }
  10864. else
  10865. {
  10866. threeCodeStr.Add(start);
  10867. threeCodeStr.Add(end);
  10868. }
  10869. }
  10870. }
  10871. }
  10872. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  10873. var last = threeCodeStr.Last();
  10874. foreach (var item in threeCodeStr)
  10875. {
  10876. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  10877. if (item.Equals(last))
  10878. {
  10879. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  10880. }
  10881. }
  10882. cityPath = cityPath.Trim('-');
  10883. }
  10884. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  10885. appro.Diid = diid ?? -1;
  10886. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  10887. appro.Id = thisId;
  10888. appro.CreateUserId = dto.UserId;
  10889. appro.CreateTime = DateTime.Now;
  10890. content.Add(appro);
  10891. }
  10892. _sqlSugar.CommitTran();
  10893. }
  10894. foreach (var x in content)
  10895. {
  10896. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  10897. if (chiList.Count < chiNumber)
  10898. {
  10899. for (int i = chiList.Count; i < chiNumber; i++)
  10900. {
  10901. chiList.Add(new Grp_ApprovalTravelDetails());
  10902. }
  10903. }
  10904. resultArr.Add(new
  10905. {
  10906. x.Id,
  10907. x.Date,
  10908. x.Diid,
  10909. chiList = chiList.Select(x1 => new
  10910. {
  10911. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  10912. x1.Details,
  10913. x1.ParentId,
  10914. x1.Id
  10915. })
  10916. });
  10917. }
  10918. data = data with
  10919. {
  10920. content = resultArr,
  10921. };
  10922. jw = JsonView(true, "获取成功!", data);
  10923. return Ok(jw);
  10924. }
  10925. /// <summary>
  10926. /// 报批行程删除
  10927. /// </summary>
  10928. /// <param name="dto"></param>
  10929. /// <returns></returns>
  10930. [HttpPost]
  10931. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  10932. {
  10933. var jw = JsonView(false);
  10934. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10935. if (group == null)
  10936. {
  10937. jw.Msg = "团组参数有误!";
  10938. return Ok(jw);
  10939. }
  10940. try
  10941. {
  10942. _sqlSugar.BeginTran();
  10943. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  10944. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  10945. {
  10946. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10947. DeleteUserId = dto.uesrId,
  10948. IsDel = 1
  10949. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  10950. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  10951. {
  10952. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10953. DeleteUserId = dto.uesrId,
  10954. IsDel = 1
  10955. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  10956. _sqlSugar.CommitTran();
  10957. jw = JsonView(true, "删除成功");
  10958. }
  10959. catch (Exception ex)
  10960. {
  10961. jw = JsonView(false, ex.Message);
  10962. }
  10963. return Ok(jw);
  10964. }
  10965. /// <summary>
  10966. /// 报批行程保存
  10967. /// </summary>
  10968. /// <param name="dto"></param>
  10969. /// <returns></returns>
  10970. [HttpPost]
  10971. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  10972. {
  10973. var jw = JsonView(false);
  10974. var Find = dto.Arr.Find(x => x.id == 0);
  10975. if (Find != null)
  10976. {
  10977. jw.Msg = "生成的ID为0!";
  10978. return Ok(jw);
  10979. }
  10980. foreach (var item in dto.Arr)
  10981. {
  10982. foreach (var chi in item.chiList)
  10983. {
  10984. if (chi.parentId == 0)
  10985. {
  10986. chi.parentId = item.id;
  10987. }
  10988. }
  10989. }
  10990. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  10991. _sqlSugar.BeginTran();
  10992. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  10993. {
  10994. var parentIds = dto.Arr.Select(x => x.id).ToList();
  10995. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  10996. {
  10997. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  10998. DeleteUserId = dto.UserId,
  10999. IsDel = 1
  11000. }).ExecuteCommand();
  11001. }
  11002. try
  11003. {
  11004. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11005. {
  11006. CreateTime = DateTime.Now,
  11007. CreateUserId = dto.UserId,
  11008. Details = x.details,
  11009. ParentId = x.parentId,
  11010. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11011. Remark = "",
  11012. IsDel = 0
  11013. }).ToList()).ExecuteCommand();
  11014. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11015. {
  11016. Id = x.id,
  11017. Details = x.details,
  11018. ParentId = x.parentId,
  11019. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11020. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  11021. {
  11022. Details = x.Details,
  11023. ParentId = x.ParentId,
  11024. Time = x.Time
  11025. }).ExecuteCommand();
  11026. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11027. {
  11028. Id = x.id,
  11029. Date = x.date,
  11030. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11031. {
  11032. Date = x.Date
  11033. }).ExecuteCommand();
  11034. _sqlSugar.CommitTran();
  11035. jw = JsonView(true, "保存成功!");
  11036. }
  11037. catch (Exception ex)
  11038. {
  11039. _sqlSugar.RollbackTran();
  11040. jw = JsonView(false, "保存失败!" + ex.Message);
  11041. }
  11042. return Ok(jw);
  11043. }
  11044. /// <summary>
  11045. /// 报批行程生成
  11046. /// </summary>
  11047. /// <param name="dto"></param>
  11048. /// <returns></returns>
  11049. [HttpPost]
  11050. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11051. {
  11052. var jw = JsonView(false);
  11053. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11054. if (group == null)
  11055. {
  11056. jw.Msg = "暂无该团组!";
  11057. return Ok(jw);
  11058. }
  11059. //黑屏代码数据
  11060. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  11061. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  11062. {
  11063. jw.Msg = "黑屏代码有误!";
  11064. return Ok(jw);
  11065. }
  11066. foreach (DataRow row in dtBlack.Rows)
  11067. {
  11068. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11069. {
  11070. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  11071. return Ok(jw);
  11072. }
  11073. }
  11074. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11075. var resultArr = new ArrayList();
  11076. if (officialActivitiesArr.Count == 0)
  11077. {
  11078. jw.Msg = "暂无公务出访信息!";
  11079. return Ok(jw);
  11080. }
  11081. try
  11082. {
  11083. _sqlSugar.BeginTran();
  11084. DeleteApprovalJourney(new
  11085. Domain.Dtos.Groups.DeleteApprovalJourney
  11086. {
  11087. Diid = dto.Diid,
  11088. uesrId = dto.Userid
  11089. });
  11090. var stay = "-";
  11091. var cityPath = "-";
  11092. //添加城市路径以及住宿地
  11093. //黑屏代码获取时间区间
  11094. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  11095. var empty = "【未收入该三字码!请机票同事录入】";
  11096. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11097. for (int i = 0; i < timeArr.Count; i++)
  11098. {
  11099. stay = "-";
  11100. cityPath = "-";
  11101. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11102. DateTime NewData = DateTime.Parse(timeArr[i]);
  11103. 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();
  11104. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  11105. if (tbSelect.Length > 0)
  11106. {
  11107. List<string> threeCodeStr = new List<string>();
  11108. bool isTrade = false;
  11109. string trip = string.Empty;
  11110. var rowLast = tbSelect.Last();
  11111. var rowFirst = tbSelect.First();
  11112. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  11113. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  11114. var takeOffTime = DateTime.Parse(timeArr[i]);
  11115. var fallToTime = DateTime.Parse(timeArr[i]);
  11116. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  11117. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  11118. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  11119. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  11120. foreach (var item in tbSelect)
  11121. {
  11122. var start = string.Empty;
  11123. var end = string.Empty;
  11124. var threeCode = item["Three"].ToString() ?? "";
  11125. if (threeCode.Length == 6)
  11126. {
  11127. start = threeCode.Substring(0, 3);
  11128. end = threeCode.Substring(3, 3);
  11129. if (threeCodeStr.Count == 0)
  11130. {
  11131. threeCodeStr.Add(start);
  11132. threeCodeStr.Add(end);
  11133. }
  11134. else
  11135. {
  11136. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  11137. {
  11138. threeCodeStr.Add(end);
  11139. }
  11140. else
  11141. {
  11142. threeCodeStr.Add(start);
  11143. threeCodeStr.Add(end);
  11144. }
  11145. }
  11146. }
  11147. //处理机票信息
  11148. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  11149. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  11150. if (start_Object == null)
  11151. {
  11152. start_Object = new Res_ThreeCode()
  11153. {
  11154. AirPort = empty,
  11155. AirPort_En = empty,
  11156. City = empty,
  11157. Country = empty,
  11158. Four = empty,
  11159. Three = empty,
  11160. };
  11161. }
  11162. if (end_Object == null)
  11163. {
  11164. end_Object = new Res_ThreeCode()
  11165. {
  11166. AirPort = empty,
  11167. AirPort_En = empty,
  11168. City = empty,
  11169. Country = empty,
  11170. Four = empty,
  11171. Three = empty,
  11172. };
  11173. }
  11174. //机型判断
  11175. string airModel = item["AirModel"].ToString();
  11176. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  11177. string flightTime = item["FlightTime"].ToString();
  11178. if (flightTime!.Contains(":"))
  11179. {
  11180. flightTime = flightTime.Replace(":", "小时");
  11181. flightTime += "分钟";
  11182. }
  11183. if (flightTime.Contains("H"))
  11184. {
  11185. flightTime = flightTime.Replace("H", "小时");
  11186. }
  11187. if (flightTime.Contains("M"))
  11188. {
  11189. flightTime = flightTime.Replace("M", "分钟");
  11190. }
  11191. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  11192. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  11193. {
  11194. flightTime = flightDataTime.Hour > 0
  11195. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  11196. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  11197. ? flightDataTime.Minute.ToString() + "分钟" : "";
  11198. }
  11199. //航班号
  11200. string flightcode = item["Fliagtcode"].ToString();
  11201. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  11202. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  11203. if (aircompany == null)
  11204. {
  11205. aircompany = new Res_AirCompany
  11206. {
  11207. CnName = hsEmpty,
  11208. EnName = hsEmpty,
  11209. ShortCode = hsEmpty,
  11210. };
  11211. }
  11212. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  11213. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  11214. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  11215. if (isTrade)
  11216. {
  11217. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  11218. }
  11219. else
  11220. {
  11221. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  11222. }
  11223. }
  11224. chiarr.Add(new Grp_ApprovalTravelDetails
  11225. {
  11226. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  11227. CreateTime = DateTime.Now,
  11228. CreateUserId = dto.Userid,
  11229. ParentId = 0,
  11230. Details = trip
  11231. });
  11232. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  11233. var last = threeCodeStr.Last();
  11234. foreach (var item in threeCodeStr)
  11235. {
  11236. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  11237. if (item.Equals(last))
  11238. {
  11239. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  11240. }
  11241. }
  11242. cityPath = cityPath.Trim('-');
  11243. }
  11244. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11245. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11246. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  11247. appro.Diid = dto.Diid;
  11248. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11249. appro.Id = thisId;
  11250. appro.CreateUserId = dto.Userid;
  11251. appro.CreateTime = DateTime.Now;
  11252. foreach (var item in gwinfo)
  11253. {
  11254. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11255. chi.Details = "拜访" + item.Client;
  11256. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  11257. {
  11258. chi.Details += "," + item.ReqSample;
  11259. }
  11260. chi.ParentId = thisId;
  11261. chi.Time = item.Time;
  11262. chiarr.Add(chi);
  11263. }
  11264. if (chiarr.Count < 5)
  11265. {
  11266. for (int j = chiarr.Count; j < 5; j++)
  11267. {
  11268. chiarr.Add(new
  11269. Grp_ApprovalTravelDetails());
  11270. }
  11271. }
  11272. resultArr.Add(new
  11273. {
  11274. appro.Id,
  11275. appro.Date,
  11276. appro.Diid,
  11277. chiList = chiarr.Select(x1 => new
  11278. {
  11279. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11280. x1.Details,
  11281. x1.ParentId,
  11282. x1.Id
  11283. })
  11284. });
  11285. }
  11286. _sqlSugar.CommitTran();
  11287. jw = JsonView(true, "生成成功!", resultArr);
  11288. }
  11289. catch (Exception ex)
  11290. {
  11291. jw.Code = 400;
  11292. jw.Msg = "生成失败!" + ex.Message;
  11293. }
  11294. return Ok(jw);
  11295. }
  11296. /// <summary>
  11297. /// 报批行程word导出
  11298. /// </summary>
  11299. /// <param name="dto"></param>
  11300. /// <returns></returns>
  11301. [HttpPost]
  11302. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11303. {
  11304. var jw = JsonView(false);
  11305. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11306. if (group == null)
  11307. {
  11308. jw.Msg = "暂无该团组!";
  11309. return Ok(jw);
  11310. }
  11311. //模板路径
  11312. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  11313. //载入模板
  11314. Document doc = new Document(tempPath);
  11315. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11316. //获取所填表格的序数
  11317. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11318. Aspose.Words.Tables.Row titleRowClone = null;
  11319. Aspose.Words.Tables.Row CenterRowClone = null;
  11320. int index = 0;
  11321. int indexChi = 0;
  11322. int SetIndex = 0;
  11323. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11324. //获取数据,放到datatable
  11325. foreach (var item in ApprovalTravelArr)
  11326. {
  11327. if (index > 0)
  11328. {
  11329. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11330. tableOne.AppendChild(titleRowClone);
  11331. }
  11332. var textTime = item.Date;
  11333. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11334. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11335. SetIndex++;
  11336. if (ChiRep.Count > 0)
  11337. {
  11338. foreach (var itemChi in ChiRep)
  11339. {
  11340. var txtTime = itemChi.Time;
  11341. var txtDetail = itemChi.Details;
  11342. if (indexChi > 0)
  11343. {
  11344. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11345. tableOne.AppendChild(CenterRowClone);
  11346. }
  11347. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11348. {
  11349. SetCells(tableOne, doc, SetIndex, 0, "");
  11350. SetCells(tableOne, doc, SetIndex, 1, "");
  11351. indexChi++;
  11352. SetIndex++;
  11353. break;
  11354. }
  11355. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11356. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11357. indexChi++;
  11358. SetIndex++;
  11359. }
  11360. }
  11361. else
  11362. {
  11363. if (indexChi > 0)
  11364. {
  11365. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11366. tableOne.AppendChild(CenterRowClone);
  11367. }
  11368. SetCells(tableOne, doc, SetIndex, 0, "");
  11369. SetCells(tableOne, doc, SetIndex, 1, "");
  11370. indexChi++;
  11371. SetIndex++;
  11372. }
  11373. index++;
  11374. }
  11375. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11376. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11377. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  11378. jw.Code = 200;
  11379. jw.Msg = "";
  11380. return Ok(jw);
  11381. }
  11382. private string intToString(int numberVal)
  11383. {
  11384. string numberval = numberVal.ToString();
  11385. Dictionary<char, string> Number = new Dictionary<char, string>();
  11386. Number.Add('1', "一");
  11387. Number.Add('2', "二");
  11388. Number.Add('3', "三");
  11389. Number.Add('4', "四");
  11390. Number.Add('5', "五");
  11391. Number.Add('6', "六");
  11392. Number.Add('7', "七");
  11393. Number.Add('8', "八");
  11394. Number.Add('9', "九");
  11395. string stringNumberVal = string.Empty;
  11396. for (int i = 0; i < numberval.Length; i++)
  11397. {
  11398. if (i == 0)
  11399. {
  11400. stringNumberVal += Number[numberval[i]];
  11401. }
  11402. else if (i >= 1)
  11403. {
  11404. if (numberval[i] == '0')
  11405. {
  11406. stringNumberVal = "十";
  11407. }
  11408. else
  11409. {
  11410. stringNumberVal += "十" + Number[numberval[i]];
  11411. }
  11412. }
  11413. }
  11414. return stringNumberVal;
  11415. }
  11416. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11417. {
  11418. //获取table中的某个单元格,从0开始
  11419. Cell lshCell = table.Rows[rows].Cells[cells];
  11420. //将单元格中段落移除
  11421. foreach (Node item in lshCell.Paragraphs)
  11422. {
  11423. lshCell.Paragraphs.Remove(item);
  11424. }
  11425. if (val.Contains("\r\n"))
  11426. {
  11427. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  11428. foreach (var item in spArr)
  11429. {
  11430. //新建一个段落
  11431. Paragraph p = new Paragraph(doc);
  11432. var r = new Run(doc, item);
  11433. //把设置的值赋给之前新建的段落
  11434. p.AppendChild(r);
  11435. //将此段落加到单元格内
  11436. lshCell.AppendChild(p);
  11437. }
  11438. }
  11439. else
  11440. {
  11441. //新建一个段落
  11442. Paragraph p = new Paragraph(doc);
  11443. var r = new Run(doc, val);
  11444. //把设置的值赋给之前新建的段落
  11445. p.AppendChild(r);
  11446. //将此段落加到单元格内
  11447. lshCell.AppendChild(p);
  11448. }
  11449. }
  11450. [HttpPost]
  11451. public async Task<IActionResult> ServerHttp(string paramStr)
  11452. {
  11453. paramStr = paramStr.TrimEnd('\'');
  11454. paramStr = paramStr.TrimStart('\'');
  11455. JsonView jw = JsonView(false);
  11456. JObject param = JObject.Parse(paramStr);
  11457. if (!param.ContainsKey("url"))
  11458. {
  11459. jw.Msg = "url null";
  11460. return Ok(jw);
  11461. }
  11462. string url = param["url"]!.ToString();
  11463. var methon = "get";
  11464. Dictionary<string, string> bodyValues = null;
  11465. Dictionary<string, string> headValues = null;
  11466. if (param.ContainsKey("methon"))
  11467. {
  11468. methon = param["methon"]!.ToString();
  11469. }
  11470. if (param.ContainsKey("header"))
  11471. {
  11472. var header = param["header"]!.ToString();
  11473. JObject headerJobject = JObject.Parse(header);
  11474. headValues = new Dictionary<string, string>();
  11475. foreach (JProperty item in headerJobject.Properties())
  11476. {
  11477. var value = item.Value.ToString();
  11478. var head = item.Path;
  11479. headValues.Add(head, value);
  11480. }
  11481. }
  11482. if (param.ContainsKey("body"))
  11483. {
  11484. var body = param["body"]!.ToString();
  11485. bodyValues = new Dictionary<string, string>();
  11486. JObject bodyJobject = JObject.Parse(body);
  11487. foreach (JProperty item in bodyJobject.Properties())
  11488. {
  11489. var value = item.Value.ToString();
  11490. var head = item.Path;
  11491. bodyValues.Add(head, value);
  11492. }
  11493. }
  11494. HttpClient client = new HttpClient();
  11495. string responseString = string.Empty;
  11496. if (param.ContainsKey("isJson"))
  11497. {
  11498. }
  11499. if (headValues != null)
  11500. {
  11501. foreach (var item in headValues.Keys)
  11502. {
  11503. client.DefaultRequestHeaders.Add(item, headValues[item]);
  11504. }
  11505. }
  11506. try
  11507. {
  11508. if (methon == "get")
  11509. {
  11510. responseString = await client.GetStringAsync(url);
  11511. }
  11512. else if (methon == "post")
  11513. {
  11514. if (bodyValues == null)
  11515. {
  11516. jw.Msg = "methon post body null";
  11517. return Ok(jw);
  11518. }
  11519. // 数据转化为 key=val 格式
  11520. var content = new FormUrlEncodedContent(bodyValues);
  11521. var response = await client.PostAsync(url, content);
  11522. // 获取数据
  11523. responseString = await response.Content.ReadAsStringAsync();
  11524. }
  11525. else
  11526. {
  11527. jw.Msg = "methon error";
  11528. }
  11529. jw = JsonView(true, "success", responseString);
  11530. }
  11531. catch (Exception ex)
  11532. {
  11533. jw.Msg = "error " + ex.Message;
  11534. jw.Data = ex.StackTrace;
  11535. }
  11536. finally
  11537. {
  11538. client.Dispose();
  11539. }
  11540. return Ok(jw);
  11541. }
  11542. #endregion
  11543. // /// <summary>
  11544. // ///
  11545. // /// </summary>
  11546. // /// <param name="_dto"></param>
  11547. // /// <returns></returns>
  11548. // [HttpPost]
  11549. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11550. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11551. // {
  11552. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11553. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11554. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11555. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11556. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11557. // dic_psg.Add("客人", 974);
  11558. // dic_psg.Add("司机", 975);
  11559. // dic_psg.Add("导游", 976);
  11560. // dic_psg.Add("公司内部人员", 977);
  11561. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11562. // foreach (var item in list_visa)
  11563. // {
  11564. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11565. // temp.Id = item.Id;
  11566. // temp.DIId = item.DIId;
  11567. // temp.VisaClient = item.VisaClient;
  11568. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11569. // temp.VisaCurrency = item.VisaCurrency;
  11570. // temp.IsThird = item.IsThird;
  11571. // if (dic_psg.ContainsKey(item.PassengerType))
  11572. // {
  11573. // temp.PassengerType = dic_psg[item.PassengerType];
  11574. // }
  11575. // else {
  11576. // temp.PassengerType = -1;
  11577. // }
  11578. // temp.VisaNumber = item.VisaNumber;
  11579. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11580. // temp.CreateUserId = item.Operators;
  11581. // DateTime dt_ct;
  11582. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11583. // if (b_ct)
  11584. // {
  11585. // temp.CreateTime = dt_ct;
  11586. // }
  11587. // else
  11588. // {
  11589. // temp.CreateTime = DateTime.Now;
  11590. // }
  11591. // temp.DeleteTime = "";
  11592. // temp.DeleteUserId = 0;
  11593. // temp.Remark = item.Remark;
  11594. // if (string.IsNullOrEmpty(temp.Remark)) {
  11595. // temp.Remark = "";
  11596. // }
  11597. // temp.IsDel = item.IsDel;
  11598. // temp.VisaDescription = item.VisaAttachment;
  11599. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11600. //([Id]
  11601. // ,[DIId]
  11602. // ,[VisaClient]
  11603. // ,[VisaPrice]
  11604. // ,[VisaCurrency]
  11605. // ,[IsThird]
  11606. // ,[PassengerType]
  11607. // ,[VisaNumber]
  11608. // ,[VisaFreeNumber]
  11609. // ,[CreateUserId]
  11610. // ,[CreateTime]
  11611. // ,[DeleteTime]
  11612. // ,[DeleteUserId]
  11613. // ,[Remark]
  11614. // ,[IsDel]
  11615. // ,[visaDescription])
  11616. // VALUES
  11617. // ({0},{1},'{2}',{3},{4}
  11618. //,{5},{6},{7},{8},{9}
  11619. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11620. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11621. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11622. //);
  11623. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11624. // }
  11625. // return Ok(JsonView(true, "操作成功!"));
  11626. // }
  11627. /// <summary>
  11628. /// 123132123
  11629. /// </summary>
  11630. /// <param name="_dto"></param>
  11631. /// <returns></returns>
  11632. [HttpPost]
  11633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11634. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11635. {
  11636. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11637. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11638. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11639. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11640. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11641. dicDetail.Add(789, 1034);
  11642. dicDetail.Add(790, 1035);
  11643. dicDetail.Add(791, 1036);
  11644. dicDetail.Add(792, 1037);
  11645. dicDetail.Add(793, 1038);
  11646. dicDetail.Add(794, 1039);
  11647. dicDetail.Add(795, 1040);
  11648. dicDetail.Add(796, 1041);
  11649. dicDetail.Add(797, 1042);
  11650. dicDetail.Add(798, 1043);
  11651. dicDetail.Add(801, 1044);
  11652. dicDetail.Add(802, 1045);
  11653. dicDetail.Add(803, 1046);
  11654. Dictionary<int, int> dic = new Dictionary<int, int>();
  11655. dic.Add(806, 1027);
  11656. dic.Add(807, 1028);
  11657. dic.Add(808, 1029);
  11658. dic.Add(809, 1030);
  11659. dic.Add(810, 1031);
  11660. dic.Add(811, 1032);
  11661. dic.Add(812, 1033);
  11662. foreach (var item in list_visa)
  11663. {
  11664. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11665. temp.Coefficient = item.coefficient;
  11666. DateTime dtCrt;
  11667. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11668. if (b1)
  11669. {
  11670. temp.CreateTime = dtCrt;
  11671. }
  11672. else
  11673. {
  11674. temp.CreateTime = DateTime.Now;
  11675. }
  11676. temp.CreateUserId = item.Operators;
  11677. temp.DeleteTime = "";
  11678. temp.DeleteUserId = 0;
  11679. temp.DiId = int.Parse(item.DIID);
  11680. temp.FilePath = item.FilePath;
  11681. temp.IsDel = item.IsDel;
  11682. temp.Price = item.Price;
  11683. temp.PriceCount = 1;
  11684. temp.PriceCurrency = item.Currency;
  11685. int detailId = 0;
  11686. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11687. {
  11688. detailId = dicDetail[item.PriceTypeDetail];
  11689. }
  11690. temp.PriceDetailType = detailId;
  11691. temp.PriceDt = DateTime.Now;
  11692. temp.PriceName = item.PriceName;
  11693. temp.PriceSum = item.Price;
  11694. int tid = 0;
  11695. if (dic.ContainsKey(item.PriceType))
  11696. {
  11697. tid = dic[item.PriceType];
  11698. }
  11699. temp.PriceType = tid;
  11700. temp.Remark = item.Remark;
  11701. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11702. }
  11703. return Ok(JsonView(true, "操作成功!"));
  11704. }
  11705. }
  11706. }