GroupsController.cs 607 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498
  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. namespace OASystem.API.Controllers
  92. {
  93. /// <summary>
  94. /// 团组相关
  95. /// </summary>
  96. //[Authorize]
  97. [Route("api/[controller]/[action]")]
  98. public class GroupsController : ControllerBase
  99. {
  100. private readonly GrpScheduleRepository _grpScheduleRep;
  101. private readonly IMapper _mapper;
  102. private readonly DelegationInfoRepository _groupRepository;
  103. private readonly TaskAssignmentRepository _taskAssignmentRep;
  104. private readonly AirTicketResRepository _airTicketResRep;
  105. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  106. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  107. private readonly DelegationEnDataRepository _delegationEnDataRep;
  108. private readonly DelegationVisaRepository _delegationVisaRep;
  109. private readonly VisaPriceRepository _visaPriceRep;
  110. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  111. private readonly HotelPriceRepository _hotelPriceRep;
  112. private readonly CustomersRepository _customersRep;
  113. private readonly MessageRepository _message;
  114. private readonly SqlSugarClient _sqlSugar;
  115. private readonly TourClientListRepository _tourClientListRep;
  116. private readonly TeamRateRepository _teamRateRep;
  117. #region 成本相关
  118. private readonly CheckBoxsRepository _checkBoxs;
  119. private readonly GroupCostRepository _GroupCostRepository;
  120. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  121. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  122. #endregion
  123. private readonly SetDataRepository _setDataRep;
  124. private string url;
  125. private string path;
  126. private readonly EnterExitCostRepository _enterExitCostRep;
  127. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  128. private readonly UsersRepository _usersRep;
  129. private readonly IJuHeApiService _juHeApi;
  130. private readonly InvertedListRepository _invertedListRep;
  131. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  132. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  133. private readonly HotelInquiryRepository _hotelInquiryRep;
  134. public GroupsController(IMapper mapper, SqlSugarClient sqlSugar, GrpScheduleRepository grpScheduleRep, DelegationInfoRepository groupRepository,
  135. TaskAssignmentRepository taskAssignmentRep, AirTicketResRepository airTicketResRep, DecreasePaymentsRepository decreasePaymentsRep,
  136. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep, DelegationEnDataRepository delegationEnDataRep, EnterExitCostRepository enterExitCostRep
  137. , DelegationVisaRepository delegationVisaRep, MessageRepository message, VisaPriceRepository visaPriceRep, CarTouristGuideGroundRepository carTouristGuideGroundRep,
  138. CheckBoxsRepository checkBoxs, GroupCostRepository GroupCostRepository, CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  139. GroupCostParameterRepository GroupCostParameterRepository, HotelPriceRepository hotelPriceRep, CustomersRepository customersRep, SetDataRepository setDataRep,
  140. TourClientListRepository tourClientListRep, TeamRateRepository teamRateRep, IHubContext<ChatHub, IChatClient> hubContext, UsersRepository usersRep, IJuHeApiService juHeApi,
  141. InvertedListRepository invertedListRep, VisaFeeInfoRepository visaFeeInfoRep, TicketBlackCodeRepository ticketBlackCodeRep, HotelInquiryRepository hotelInquiryRep)
  142. {
  143. _mapper = mapper;
  144. _grpScheduleRep = grpScheduleRep;
  145. _groupRepository = groupRepository;
  146. _taskAssignmentRep = taskAssignmentRep;
  147. _airTicketResRep = airTicketResRep;
  148. _sqlSugar = sqlSugar;
  149. url = AppSettingsHelper.Get("ExcelBaseUrl");
  150. path = AppSettingsHelper.Get("ExcelBasePath");
  151. if (!System.IO.Directory.Exists(path))
  152. {
  153. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  154. }
  155. _decreasePaymentsRep = decreasePaymentsRep;
  156. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  157. _delegationEnDataRep = delegationEnDataRep;
  158. _enterExitCostRep = enterExitCostRep;
  159. _delegationVisaRep = delegationVisaRep;
  160. _message = message;
  161. _visaPriceRep = visaPriceRep;
  162. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  163. _checkBoxs = checkBoxs;
  164. _GroupCostRepository = GroupCostRepository;
  165. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  166. _GroupCostParameterRepository = GroupCostParameterRepository;
  167. _hotelPriceRep = hotelPriceRep;
  168. _customersRep = customersRep;
  169. _setDataRep = setDataRep;
  170. _tourClientListRep = tourClientListRep;
  171. _teamRateRep = teamRateRep;
  172. _hubContext = hubContext;
  173. _usersRep = usersRep;
  174. _juHeApi = juHeApi;
  175. _invertedListRep = invertedListRep;
  176. _visaFeeInfoRep = visaFeeInfoRep;
  177. _ticketBlackCodeRep = ticketBlackCodeRep;
  178. _hotelInquiryRep = hotelInquiryRep;
  179. }
  180. #region 流程管控
  181. /// <summary>
  182. /// 获取团组流程管控信息
  183. /// </summary>
  184. /// <param name="paras">参数Json字符串</param>
  185. /// <returns></returns>
  186. [HttpPost]
  187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  188. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  189. {
  190. if (string.IsNullOrEmpty(_jsonDto.Paras))
  191. {
  192. return Ok(JsonView(false, "参数为空"));
  193. }
  194. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  195. if (_ScheduleDto != null)
  196. {
  197. if (_ScheduleDto.SearchType == 2)//获取列表
  198. {
  199. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  200. return Ok(JsonView(_grpScheduleViewList));
  201. }
  202. else//获取对象
  203. {
  204. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  205. if (_grpScheduleView != null)
  206. {
  207. return Ok(JsonView(_grpScheduleView));
  208. }
  209. }
  210. }
  211. else
  212. {
  213. return Ok(JsonView(false, "参数反序列化失败"));
  214. }
  215. return Ok(JsonView(false, "暂无数据!"));
  216. }
  217. /// <summary>
  218. /// 修改团组流程管控详细表数据
  219. /// </summary>
  220. /// <param name="paras"></param>
  221. /// <returns></returns>
  222. [HttpPost]
  223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  224. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  225. {
  226. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  227. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  228. .SetColumns(it => it.Duty == _detail.Duty)
  229. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  230. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  231. .SetColumns(it => it.JobContent == _detail.JobContent)
  232. .SetColumns(it => it.Remark == _detail.Remark)
  233. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  234. .Where(s => s.Id == dto.Id)
  235. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  236. .ExecuteCommandAsync();
  237. if (result > 0)
  238. {
  239. return Ok(JsonView(true, "保存成功!"));
  240. }
  241. return Ok(JsonView(false, "保存失败!"));
  242. }
  243. /// <summary>
  244. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  245. /// </summary>
  246. /// <param name="dto"></param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  251. {
  252. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  253. _detail.IsDel = 1;
  254. _detail.DeleteUserId = dto.Duty;
  255. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  256. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  257. .SetColumns(it => it.IsDel == _detail.IsDel)
  258. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  259. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  260. .Where(it => it.Id == dto.Id)
  261. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  262. //.WhereColumns(s => s.Id == dto.Id)
  263. .ExecuteCommandAsync();
  264. if (result > 0)
  265. {
  266. return Ok(JsonView(true, "删除成功!"));
  267. }
  268. return Ok(JsonView(false, "删除失败!"));
  269. }
  270. /// <summary>
  271. /// 增加团组流程管控详细表数据
  272. /// </summary>
  273. /// <param name="dto"></param>
  274. /// <returns></returns>
  275. [HttpPost]
  276. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  277. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  278. {
  279. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  280. if (DateTime.Now < _detail.ExpectBeginDt)
  281. {
  282. _detail.StepStatus = 0;
  283. }
  284. else
  285. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  286. _detail.StepStatus = 1;
  287. }
  288. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  289. if (result > 0)
  290. {
  291. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  292. return Ok(JsonView(true, "添加成功!", _result));
  293. }
  294. return Ok(JsonView(false, "添加失败!"));
  295. }
  296. #endregion
  297. #region 团组基本信息
  298. /// <summary>
  299. /// 接团信息列表
  300. /// </summary>
  301. /// <param name="dto">团组列表请求dto</param>
  302. /// <returns></returns>
  303. [HttpPost]
  304. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  305. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  306. {
  307. var groupData = await _groupRepository.GetGroupList(dto);
  308. if (groupData.Code != 0)
  309. {
  310. return Ok(JsonView(false, groupData.Msg));
  311. }
  312. return Ok(JsonView(groupData.Data));
  313. }
  314. /// <summary>
  315. /// 接团信息列表 Page
  316. /// </summary>
  317. /// <param name="dto">团组列表请求dto</param>
  318. /// <returns></returns>
  319. [HttpPost]
  320. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  321. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  322. {
  323. #region 参数验证
  324. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  325. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  326. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  327. #region 页面操作权限验证
  328. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  329. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  330. #endregion
  331. #endregion
  332. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  333. {
  334. string sqlWhere = string.Empty;
  335. if (dto.IsSure == 0) //未完成
  336. {
  337. sqlWhere += string.Format(@" And IsSure = 0");
  338. }
  339. else if (dto.IsSure == 1) //已完成
  340. {
  341. sqlWhere += string.Format(@" And IsSure = 1");
  342. }
  343. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  344. {
  345. string tj = dto.SearchCriteria;
  346. 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}%')",
  347. tj, tj, tj, tj, tj);
  348. }
  349. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  350. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  351. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  352. JietuanOperator,IsSure,CreateTime
  353. From (
  354. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  355. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  356. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  357. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  358. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  359. From Grp_DelegationInfo gdi
  360. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  361. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  362. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  363. Where gdi.IsDel = 0 {0}
  364. ) temp", sqlWhere);
  365. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  366. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  367. #region 处理所属部门
  368. /*
  369. * 1.sq 和 gyy 等显示 市场部
  370. * 2.王鸽和主管及张总还有管理员号统一国交部
  371. * 2-1. 4 管理员 ,21 张海麟
  372. */
  373. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  374. List<int> userIds1 = new List<int>() { 4, 21 };
  375. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  376. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  377. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  378. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  379. .ToList();
  380. foreach (var item in _DelegationList)
  381. {
  382. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  383. }
  384. #endregion
  385. var _view = new
  386. {
  387. PageFuncAuth = pageFunAuthView,
  388. Data = _DelegationList
  389. };
  390. return Ok(JsonView(true, "查询成功!", _view, total));
  391. }
  392. else
  393. {
  394. return Ok(JsonView(false, "查询失败"));
  395. }
  396. }
  397. /// <summary>
  398. /// 团组列表
  399. /// </summary>
  400. /// <returns></returns>
  401. [HttpPost]
  402. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  403. {
  404. #region 参数验证
  405. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  406. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  407. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  408. #region 页面操作权限验证
  409. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  410. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  411. #endregion
  412. #endregion
  413. if (dto.PortType != 1 && dto.PortType != 2)
  414. {
  415. return Ok(JsonView(false, "查询失败!"));
  416. }
  417. string orderbyStr = "order by gdi.CreateTime Desc";
  418. string sqlWhere = string.Empty;
  419. if (dto.IsSure == 0) //未完成
  420. {
  421. sqlWhere += string.Format(@" And IsSure = 0");
  422. }
  423. else if (dto.IsSure == 1) //已完成
  424. {
  425. sqlWhere += string.Format(@" And IsSure = 1");
  426. }
  427. //团组类型
  428. if (dto.TeamDid > 0)
  429. {
  430. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  431. }
  432. //团组名称
  433. if (!string.IsNullOrEmpty(dto.TeamName))
  434. {
  435. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  436. }
  437. //客户名称
  438. if (!string.IsNullOrEmpty(dto.ClientName))
  439. {
  440. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  441. }
  442. //客户单位
  443. if (!string.IsNullOrEmpty(dto.ClientUnit))
  444. {
  445. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  446. }
  447. //出访时间
  448. if (!string.IsNullOrEmpty(dto.visitDataTime))
  449. {
  450. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  451. orderbyStr = "order by gdi.VisitDate";
  452. }
  453. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  454. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  455. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  456. JietuanOperator,IsSure,CreateTime
  457. From (
  458. Select row_number() over({0}) as Row_Number,
  459. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  460. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  461. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  462. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  463. From Grp_DelegationInfo gdi
  464. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  465. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  466. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  467. Where gdi.IsDel = 0 {1}
  468. ) temp ", orderbyStr, sqlWhere);
  469. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  470. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  471. #region 处理所属部门
  472. /*
  473. * 1.sq 和 gyy 等显示 市场部
  474. * 2.王鸽和主管及张总还有管理员号统一国交部
  475. * 2-1. 4 管理员 ,21 张海麟
  476. */
  477. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  478. List<int> userIds1 = new List<int>() { 4, 21 };
  479. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  480. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  481. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  482. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  483. .ToList();
  484. foreach (var item in _DelegationList)
  485. {
  486. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  487. }
  488. #endregion
  489. var _view = new
  490. {
  491. PageFuncAuth = pageFunAuthView,
  492. Data = _DelegationList
  493. };
  494. return Ok(JsonView(true, "查询成功!", _view, total));
  495. }
  496. /// <summary>
  497. /// 接团信息详情
  498. /// </summary>
  499. /// <param name="dto">团组info请求dto</param>
  500. /// <returns></returns>
  501. [HttpPost]
  502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  503. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  504. {
  505. var groupData = await _groupRepository.GetGroupInfo(dto);
  506. if (groupData.Code != 0)
  507. {
  508. return Ok(JsonView(false, groupData.Msg));
  509. }
  510. return Ok(JsonView(groupData.Data));
  511. }
  512. /// <summary>
  513. /// 接团信息 编辑添加
  514. /// 基础信息数据源
  515. /// </summary>
  516. /// <param name="dto"></param>
  517. /// <returns></returns>
  518. [HttpPost]
  519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  520. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  521. {
  522. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  523. if (groupData.Code != 0)
  524. {
  525. return Ok(JsonView(false, groupData.Msg));
  526. }
  527. return Ok(JsonView(groupData.Data));
  528. }
  529. /// <summary>
  530. /// 接团信息 操作(增改)
  531. /// </summary>
  532. /// <param name="dto"></param>
  533. /// <returns></returns>
  534. [HttpPost]
  535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  536. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  537. {
  538. try
  539. {
  540. var groupData = await _groupRepository.GroupOperation(dto);
  541. if (groupData.Code != 0)
  542. {
  543. return Ok(JsonView(false, groupData.Msg));
  544. }
  545. int diId = 0;
  546. //添加时 默认加入团组汇率
  547. if (dto.Status == 1) //添加
  548. {
  549. diId = groupData.Data;
  550. //添加默认币种
  551. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  552. //默认分配权限
  553. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  554. //消息提示 王鸽 主管号
  555. List<int> _managerIds = new List<int>() { 22, 32 };
  556. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  557. if (userIds.Count > 0)
  558. {
  559. userIds.Add(208);
  560. //创建团组管控
  561. GroupStepForDelegation.CreateWorkStep(diId);
  562. //发送消息
  563. string groupName = dto.TeamName;
  564. string createGroupUser = string.Empty;
  565. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  566. if (userInfo != null) createGroupUser = userInfo.CnName;
  567. string title = $"系统通知";
  568. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  569. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  570. }
  571. //默认创建倒推表
  572. await _invertedListRep._Create(dto.UserId, diId);
  573. }
  574. else if (dto.Status == 2)
  575. {
  576. diId = dto.Id;
  577. }
  578. return Ok(JsonView(true, "操作成功!", diId));
  579. }
  580. catch (Exception ex)
  581. {
  582. Logs("[response]" + JsonConvert.SerializeObject(dto));
  583. Logs(ex.Message);
  584. return Ok(JsonView(false, ex.Message));
  585. }
  586. }
  587. /// <summary>
  588. /// 接团流程操作(增改)
  589. /// 安卓端使用 建团时添加客户名单
  590. /// </summary>
  591. /// <param name="dto"></param>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  596. {
  597. try
  598. {
  599. #region 参数验证
  600. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  601. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  602. #region 页面操作权限验证
  603. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  604. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  605. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  606. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  607. #endregion
  608. #endregion
  609. _sqlSugar.BeginTran();
  610. var _dto = new GroupOperationDto();
  611. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  612. var groupData = await _groupRepository.GroupOperation(_dto);
  613. if (groupData.Code != 0)
  614. {
  615. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  616. }
  617. int diId = 0;
  618. //添加时 默认加入团组汇率
  619. if (dto.Status == 1) //添加
  620. {
  621. diId = groupData.Data;
  622. //添加默认币种
  623. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  624. //默认分配权限
  625. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  626. //消息提示 王鸽 主管号
  627. List<int> _managerIds = new List<int>() { 22, 32 };
  628. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  629. if (userIds.Count > 0)
  630. {
  631. userIds.Add(208);
  632. //创建团组管控
  633. GroupStepForDelegation.CreateWorkStep(diId);
  634. //发送消息
  635. string groupName = dto.TeamName;
  636. string createGroupUser = string.Empty;
  637. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  638. if (userInfo != null) createGroupUser = userInfo.CnName;
  639. string title = $"系统通知";
  640. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  641. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  642. }
  643. }
  644. if (dto.Status == 2)
  645. {
  646. diId = dto.Id;
  647. if (diId == 0)
  648. {
  649. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  650. }
  651. }
  652. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  653. if (viewData.Code != 0)
  654. {
  655. _sqlSugar.RollbackTran();
  656. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  657. }
  658. _sqlSugar.CommitTran();
  659. return Ok(JsonView(true, "添加成功"));
  660. }
  661. catch (Exception ex)
  662. {
  663. _sqlSugar.RollbackTran();
  664. return Ok(JsonView(false, ex.Message));
  665. }
  666. }
  667. /// <summary>
  668. /// 接团信息 操作(删除)
  669. /// </summary>
  670. /// <param name="dto"></param>
  671. /// <returns></returns>
  672. [HttpPost]
  673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  674. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  675. {
  676. try
  677. {
  678. var groupData = await _groupRepository.GroupDel(dto);
  679. if (groupData.Code != 0)
  680. {
  681. return Ok(JsonView(false, groupData.Msg));
  682. }
  683. return Ok(JsonView(true));
  684. }
  685. catch (Exception ex)
  686. {
  687. Logs("[response]" + JsonConvert.SerializeObject(dto));
  688. Logs(ex.Message);
  689. return Ok(JsonView(false, ex.Message));
  690. }
  691. }
  692. /// <summary>
  693. /// 获取团组销售报价号
  694. /// 团组添加时 使用
  695. /// </summary>
  696. /// <returns></returns>
  697. [HttpPost]
  698. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  699. public async Task<IActionResult> GetGroupSalesQuoteNo()
  700. {
  701. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  702. if (groupData.Code != 0)
  703. {
  704. return Ok(JsonView(false, groupData.Msg));
  705. }
  706. object salesQuoteNo = new
  707. {
  708. SalesQuoteNo = groupData.Data
  709. };
  710. return Ok(JsonView(salesQuoteNo));
  711. }
  712. /// <summary>
  713. /// 设置确认出团
  714. /// </summary>
  715. /// <param name="dto"></param>
  716. /// <returns></returns>
  717. [HttpPost]
  718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  719. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  720. {
  721. var groupData = await _groupRepository.ConfirmationGroup(dto);
  722. if (groupData.Code != 0)
  723. {
  724. return Ok(JsonView(false, groupData.Msg));
  725. }
  726. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  727. #region OA消息推送
  728. try
  729. {
  730. string groupName = groupInfo.TeamName;
  731. List<Sys_Users> listUser = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).ToList();
  732. List<int> userIds = new List<int>();
  733. listUser.ForEach(s => userIds.Add(s.Id));
  734. string title = $"系统通知";
  735. string content = $"团组[{groupName}]已确认出团!";
  736. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  737. }
  738. catch (Exception ex)
  739. {
  740. }
  741. #endregion
  742. #region 应用推送
  743. try
  744. {
  745. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  746. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  747. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  748. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  749. {
  750. List<string> userList = new List<string>() { users.QiyeChatUserId };
  751. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  752. }
  753. }
  754. catch (Exception ex)
  755. {
  756. }
  757. #endregion
  758. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  759. return Ok(JsonView(true, "操作成功!", groupData.Data));
  760. }
  761. /// <summary>
  762. /// 获取团组名称data And 签证国别Data
  763. /// </summary>
  764. /// <param name="dto"></param>
  765. /// <returns></returns>
  766. [HttpPost]
  767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  768. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  769. {
  770. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  771. if (groupData.Code != 0)
  772. {
  773. return Ok(JsonView(false, groupData.Msg));
  774. }
  775. return Ok(JsonView(groupData.Data));
  776. }
  777. /// <summary>
  778. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  779. /// </summary>
  780. /// <returns></returns>
  781. [HttpPost]
  782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  783. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  784. {
  785. try
  786. {
  787. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  788. if (groupData.Code != 0)
  789. {
  790. return Ok(JsonView(false, groupData.Msg));
  791. }
  792. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  793. }
  794. catch (Exception ex)
  795. {
  796. return Ok(JsonView(false, "程序错误!"));
  797. throw;
  798. }
  799. }
  800. #endregion
  801. #region 团组&签证
  802. /// <summary>
  803. /// 根据团组Id获取签证客户信息List
  804. /// </summary>
  805. /// <param name="dto">请求dto</param>
  806. /// <returns></returns>
  807. [HttpPost]
  808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  809. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  810. {
  811. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  812. if (groupData.Code != 0)
  813. {
  814. return Ok(JsonView(false, groupData.Msg));
  815. }
  816. return Ok(JsonView(groupData.Data));
  817. }
  818. /// <summary>
  819. /// IOS获取团组签证拍照上传进度01(团组列表)
  820. /// </summary>
  821. /// <param name="dto">请求dto</param>
  822. /// <returns></returns>
  823. [HttpPost]
  824. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  825. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  826. {
  827. if (dto == null)
  828. {
  829. return Ok(JsonView(false, "参数为空"));
  830. }
  831. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  832. return Ok(JsonView(visaList));
  833. }
  834. /// <summary>
  835. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  836. /// </summary>
  837. /// <returns></returns>
  838. [HttpPost]
  839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  840. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  841. {
  842. if (dto == null)
  843. {
  844. return Ok(JsonView(false, "请求错误:"));
  845. }
  846. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  847. return Ok(JsonView(list));
  848. }
  849. /// <summary>
  850. /// IOS获取团组签证拍照上传进度03(相册)
  851. /// </summary>
  852. /// <returns></returns>
  853. [HttpPost]
  854. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  855. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  856. {
  857. if (dto == null)
  858. {
  859. return Ok(JsonView(false, "请求错误:"));
  860. }
  861. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  862. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  863. list.ForEach(s => s.url = url);
  864. return Ok(JsonView(list));
  865. }
  866. /// <summary>
  867. /// IOS获取团组签证拍照上传进度04(图片上传)
  868. /// </summary>
  869. /// <param name="dto"></param>
  870. /// <returns></returns>
  871. [HttpPost]
  872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  873. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  874. {
  875. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  876. //if (!string.IsNullOrEmpty(result))
  877. //{
  878. //}
  879. //else {
  880. // return Ok(JsonView(false, "上传失败"));
  881. //}
  882. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  883. int sucNum = 0;
  884. try
  885. {
  886. foreach (var item in dto.base64DataList)
  887. {
  888. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  889. string result = decodeBase64ToImage(item, imageName);
  890. if (!string.IsNullOrEmpty(result))
  891. {
  892. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  893. pic.CreateUserId = dto.CreateUserId;
  894. pic.PicName = imageName;
  895. pic.PicPath = result;
  896. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  897. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  898. if (insertResult > 0)
  899. {
  900. sucNum++;
  901. }
  902. }
  903. }
  904. }
  905. catch (Exception ex)
  906. {
  907. return Ok(JsonView(false, ex.Message));
  908. }
  909. string msg = string.Format(@"成功上传{0}张", sucNum);
  910. return Ok(JsonView(true, msg));
  911. }
  912. private string decodeBase64ToImage(string base64DataURL, string imgName)
  913. {
  914. string filename = "";//声明一个string类型的相对路径
  915. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  916. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  917. try//会有异常抛出,try,catch一下
  918. {
  919. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  920. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  921. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  922. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  923. //文件名称
  924. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  925. //上传的文件的路径
  926. string filePath = "";
  927. if (!Directory.Exists(fileDir))
  928. {
  929. Directory.CreateDirectory(fileDir);
  930. }
  931. //上传的文件的路径
  932. filePath = fileDir + filename;
  933. //string url = HttpRuntime.AppDomainAppPath.ToString();
  934. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  935. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  936. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  937. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  938. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  939. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  940. ms.Close();//关闭当前流,并释放所有与之关联的资源
  941. bitmap.Dispose();
  942. }
  943. catch (Exception e)
  944. {
  945. string massage = e.Message;
  946. Logs("IOS图片上传Error:" + massage);
  947. //filename = e.Message;
  948. }
  949. return filename;//返回相对路径
  950. }
  951. /// <summary>
  952. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  953. /// </summary>
  954. /// <param name="dto"></param>
  955. /// <returns></returns>
  956. [HttpPost]
  957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  958. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  959. {
  960. if (dto == null)
  961. {
  962. return Ok(JsonView(false, "请求错误:"));
  963. }
  964. string msg = "参数错误";
  965. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  966. {
  967. try
  968. {
  969. //_delegationVisaRep.BeginTran();
  970. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  971. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  972. .Where(s => s.Id == dto.visaProgressCustomerId)
  973. .ExecuteCommandAsync();
  974. if (updCount > 0 && dto.publishCode == 1)
  975. {
  976. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  977. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  978. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  979. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  980. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  981. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  982. if (groupData == null)
  983. {
  984. _delegationVisaRep.RollbackTran();
  985. }
  986. string title = string.Format(@"[签证进度更新]");
  987. string content = string.Format(@"测试文本");
  988. bool rst = await _message.AddMsg(new MessageDto()
  989. {
  990. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  991. IssuerId = dto.publisher,
  992. Title = title,
  993. Content = content,
  994. ReleaseTime = DateTime.Now,
  995. UIdList = new List<int> {
  996. 234
  997. }
  998. });
  999. if (rst)
  1000. {
  1001. return Ok(JsonView(true, "发送通知成功"));
  1002. }
  1003. }
  1004. //_delegationVisaRep.CommitTran();
  1005. }
  1006. catch (Exception)
  1007. {
  1008. //_delegationVisaRep.RollbackTran();
  1009. }
  1010. }
  1011. return Ok(JsonView(true, msg));
  1012. }
  1013. #endregion
  1014. #region 团组任务分配
  1015. /// <summary>
  1016. /// 团组任务分配初始化
  1017. /// </summary>
  1018. /// <param name="dto"></param>
  1019. /// <returns></returns>
  1020. [HttpPost]
  1021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1022. public async Task<IActionResult> GetTaskAssignmen()
  1023. {
  1024. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1025. if (groupData.Code != 0)
  1026. {
  1027. return Ok(JsonView(false, groupData.Msg));
  1028. }
  1029. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1030. }
  1031. /// <summary>
  1032. /// 团组任务分配查询
  1033. /// </summary>
  1034. /// <param name="dto"></param>
  1035. /// <returns></returns>
  1036. [HttpPost]
  1037. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1038. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1039. {
  1040. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1041. if (groupData.Code != 0)
  1042. {
  1043. return Ok(JsonView(false, groupData.Msg));
  1044. }
  1045. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1046. }
  1047. /// <summary>
  1048. /// 团组任务分配操作
  1049. /// </summary>
  1050. /// <param name="dto"></param>
  1051. /// <returns></returns>
  1052. [HttpPost]
  1053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1054. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1055. {
  1056. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1057. if (groupData.Code != 0)
  1058. {
  1059. return Ok(JsonView(false, groupData.Msg));
  1060. }
  1061. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1062. }
  1063. #endregion
  1064. #region 团组费用审核
  1065. /// <summary>
  1066. /// 费用审核
  1067. /// 团组列表 Page
  1068. /// </summary>
  1069. /// <param name="_dto">团组列表请求dto</param>
  1070. /// <returns></returns>
  1071. [HttpPost]
  1072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1073. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1074. {
  1075. #region 参数验证
  1076. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1077. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1078. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1079. #region 页面操作权限验证
  1080. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1081. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1082. #endregion
  1083. #endregion
  1084. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1085. {
  1086. string sqlWhere = string.Empty;
  1087. if (_dto.IsSure == 0) //未完成
  1088. {
  1089. sqlWhere += string.Format(@" And IsSure = 0");
  1090. }
  1091. else if (_dto.IsSure == 1) //已完成
  1092. {
  1093. sqlWhere += string.Format(@" And IsSure = 1");
  1094. }
  1095. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1096. {
  1097. string tj = _dto.SearchCriteria;
  1098. 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}%')",
  1099. tj, tj, tj, tj, tj);
  1100. }
  1101. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1102. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1103. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1104. From (
  1105. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1106. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1107. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1108. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1109. From Grp_DelegationInfo gdi
  1110. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1111. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1112. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1113. Where gdi.IsDel = 0 {0}
  1114. ) temp ", sqlWhere);
  1115. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1116. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1117. var _view = new
  1118. {
  1119. PageFuncAuth = pageFunAuthView,
  1120. Data = _DelegationList
  1121. };
  1122. return Ok(JsonView(true, "查询成功!", _view, total));
  1123. }
  1124. else
  1125. {
  1126. return Ok(JsonView(false, "查询失败"));
  1127. }
  1128. }
  1129. /// <summary>
  1130. /// 获取团组费用审核
  1131. /// </summary>
  1132. /// <param name="paras">参数Json字符串</param>
  1133. /// <returns></returns>
  1134. [HttpPost]
  1135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1136. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1137. {
  1138. try
  1139. {
  1140. #region 参数验证
  1141. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1142. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1143. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1144. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1145. #region 页面操作权限验证
  1146. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1147. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1148. #endregion
  1149. #endregion
  1150. Grp_CreditCardPaymentView _view = new Grp_CreditCardPaymentView();
  1151. List<SimplClientInfo> clientNameList = getSimplClientList(_dto.DiId);
  1152. #region 费用清单
  1153. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1154. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1155. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1156. List<Grp_CreditCardPayment> entityList = _groupRepository
  1157. .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0)
  1158. .Where(exp.ToExpression())
  1159. .ToList();
  1160. List<Grp_CreditCardPaymentDetailView> detailList = new List<Grp_CreditCardPaymentDetailView>();
  1161. List<CreditCardPaymentCurrencyPriceItem> ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1162. /*
  1163. * 76://酒店预订
  1164. */
  1165. List<Grp_HotelReservations> _HotelReservations = await _groupRepository
  1166. .Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1167. .ToListAsync();
  1168. List<Grp_HotelReservationsContent> _HotelReservationsContents = await _groupRepository
  1169. .Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1170. .ToListAsync();
  1171. /*
  1172. * 79://车/导游地接
  1173. */
  1174. List<Grp_CarTouristGuideGroundReservations> _CarTouristGuideGroundReservations = await _groupRepository
  1175. .Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1176. .ToListAsync();
  1177. List<Grp_CarTouristGuideGroundReservationsContent> _CarTouristGuideGroundReservationsContent = await _groupRepository
  1178. .Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1179. .ToListAsync();
  1180. /*
  1181. * 80: //签证
  1182. */
  1183. List<Grp_VisaInfo> _VisaInfos = await _groupRepository
  1184. .Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1185. .ToListAsync();
  1186. /*
  1187. *81: //邀请/公务活动
  1188. */
  1189. List<Grp_InvitationOfficialActivities> _InvitationOfficialActivities = await _groupRepository
  1190. .Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1191. .ToListAsync();
  1192. /*
  1193. * 82: //团组客户保险
  1194. */
  1195. List<Grp_Customers> _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1196. /*
  1197. * Lable = 85 机票预订
  1198. */
  1199. List<Grp_AirTicketReservations> p_AirTicketReservations = await _groupRepository
  1200. .Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0)
  1201. .ToListAsync();
  1202. /*
  1203. * 85 机票预定
  1204. */
  1205. List<Grp_AirTicketReservations> _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1206. /*
  1207. * 98 其他款项
  1208. */
  1209. List<Grp_DecreasePayments> _DecreasePayments = await _groupRepository
  1210. .Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1211. .ToListAsync();
  1212. /*
  1213. * 285:收款退还
  1214. */
  1215. List<Fin_PaymentRefundAndOtherMoney> _PaymentRefundAndOtherMoneys = await _groupRepository
  1216. .Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0)
  1217. .ToListAsync();
  1218. /*
  1219. * 1015: //超支费用
  1220. */
  1221. List<Fin_GroupExtraCost> _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1222. /*
  1223. * 币种信息
  1224. */
  1225. var currencyItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 66 && s.IsDel == 0).ToListAsync();
  1226. /*
  1227. * 车/导游地接 费用类型
  1228. */
  1229. var carFeeTypeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 17 && s.IsDel == 0).ToListAsync();
  1230. /*
  1231. * 车/导游地接 费用类型
  1232. */
  1233. var carFeeItems = await _groupRepository.Query<Sys_SetData>(s => s.STid == 83 && s.IsDel == 0).ToListAsync();
  1234. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1235. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1236. /*
  1237. * 用户信息
  1238. */
  1239. var userItems = await _groupRepository.Query<Sys_Users>(s => s.IsDel == 0).ToListAsync();
  1240. /*
  1241. * 费用模块
  1242. */
  1243. Sys_SetData sdPriceName = _groupRepository.Query<Sys_SetData>(s => s.Id == _dto.Label).First();
  1244. string priceModule = string.Empty;
  1245. if (sdPriceName != null)
  1246. {
  1247. priceModule = sdPriceName.Name;
  1248. }
  1249. /*
  1250. * 处理详情数据
  1251. */
  1252. foreach (var entity in entityList)
  1253. {
  1254. Grp_CreditCardPaymentDetailView _detail = new Grp_CreditCardPaymentDetailView();
  1255. _detail.Id = entity.Id;
  1256. _detail.PriceName = priceModule;
  1257. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1258. _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1259. /*
  1260. * 应付款金额
  1261. */
  1262. Sys_SetData sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1263. string PaymentCurrency_WaitPay = "Unknown";
  1264. string hotelCurrncyCode = "Unknown";
  1265. string hotelCurrncyName = "Unknown";
  1266. if (sdPaymentCurrency_WaitPay != null)
  1267. {
  1268. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1269. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1270. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1271. if (hotelCurrncyCode.Equals("CNY"))
  1272. {
  1273. entity.DayRate = 1.0000M;
  1274. }
  1275. }
  1276. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1277. /*
  1278. * 此次付款金额
  1279. */
  1280. decimal CurrPayStr = 0;
  1281. if (entity.PayPercentage == 0)
  1282. {
  1283. if (entity.PayThenMoney != 0)
  1284. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1285. }
  1286. else
  1287. {
  1288. if (entity.PayMoney != 0)
  1289. {
  1290. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1291. }
  1292. }
  1293. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1294. /*
  1295. * 剩余尾款
  1296. */
  1297. decimal BalanceStr = 0;
  1298. if (CurrPayStr != 0)
  1299. {
  1300. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1301. BalanceStr = 0;
  1302. else
  1303. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1304. }
  1305. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1306. /*
  1307. * Bus名称
  1308. */
  1309. _detail.BusName = "待增加";
  1310. /*
  1311. *费用所属
  1312. */
  1313. switch (entity.CTable)
  1314. {
  1315. case 76://酒店预订
  1316. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1317. if (hotelReservations != null)
  1318. {
  1319. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1320. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1321. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1322. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  1323. /*
  1324. * 费用类型
  1325. * 1:房费
  1326. * 2:早餐
  1327. * 3:地税
  1328. * 4:城市税
  1329. * </summary>
  1330. */
  1331. //地税
  1332. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  1333. if (governmentRentData != null)
  1334. {
  1335. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  1336. governmentRentFee = governmentRentData.Price;
  1337. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  1338. if (governmentRentCurrData != null)
  1339. {
  1340. governmentRentCode = governmentRentCurrData.Name;
  1341. governmentRentName = $"({governmentRentCurrData.Remark})";
  1342. }
  1343. }
  1344. //城市税
  1345. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  1346. if (cityTaxData != null)
  1347. {
  1348. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  1349. cityTaxFee = cityTaxData.Price;
  1350. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  1351. if (cityTaxCurrData != null)
  1352. {
  1353. cityTaxCode = cityTaxCurrData.Name;
  1354. cityTaxName = $"({cityTaxCurrData.Remark})";
  1355. }
  1356. }
  1357. //酒店早餐
  1358. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  1359. if (breakfastData != null)
  1360. {
  1361. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  1362. breakfastFee = breakfastData.Price;
  1363. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  1364. if (breakfastCurrData != null)
  1365. {
  1366. breakfastCode = breakfastCurrData.Name;
  1367. breakfastName = $"({breakfastCurrData.Remark})";
  1368. }
  1369. }
  1370. //房间费用
  1371. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  1372. if (roomData != null)
  1373. {
  1374. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  1375. _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  1376. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  1377. roomFee = roomData.Price;
  1378. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  1379. if (roomCurrData != null)
  1380. {
  1381. roomCode = roomCurrData.Name;
  1382. roomName = $"({roomCurrData.Remark})";
  1383. }
  1384. }
  1385. _detail.PriceMsgContent = $"信用卡金额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  1386. $"房间说明: {hotelReservations.Remark} <br/>" +
  1387. $"房间费用: {roomFee.ToString("#0.00")} {roomCode} {roomName} 当时汇率{roomData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{roomBool}<br/>" +
  1388. $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率{breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{breakfastBool}<br/>" +
  1389. $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率{governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{governmentRentBool}<br/>" +
  1390. $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率{cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接代付:{cityTaxBool}<br/>";
  1391. _detail.PriceNameContent = hotelReservations.HotelName;
  1392. }
  1393. break;
  1394. case 79://车/导游地接
  1395. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1396. if (touristGuideGroundReservations != null)
  1397. {
  1398. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  1399. {
  1400. _detail.BusName = touristGuideGroundReservations.BusName;
  1401. }
  1402. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  1403. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  1404. //if (isInt)
  1405. //{
  1406. // var cityInfo = cityData.Find(it => it.Id == cityId);
  1407. // if (cityInfo != null)
  1408. // {
  1409. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  1410. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  1411. // if (carFeeItem != null)
  1412. // {
  1413. // nameContent += $@"({carFeeItem.Name})";
  1414. // }
  1415. // _detail.PriceNameContent = nameContent;
  1416. // }
  1417. //}
  1418. //else
  1419. //{
  1420. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  1421. //}
  1422. List<Grp_CarTouristGuideGroundReservationsContent> touristGuideGroundReservationsContents = _CarTouristGuideGroundReservationsContent
  1423. .Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  1424. string priceMsg = string.Empty;
  1425. foreach (var item in touristGuideGroundReservationsContents)
  1426. {
  1427. string typeName = "Unknown";
  1428. string carCurrencyCode = "Unknown";
  1429. string carCurrencyName = "Unknown";
  1430. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  1431. if (carTypeData != null) typeName = carTypeData.Name;
  1432. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  1433. if (currencyData != null)
  1434. {
  1435. carCurrencyCode = currencyData.Name;
  1436. carCurrencyName = currencyData.Remark;
  1437. }
  1438. priceMsg += typeName + ":" + item.Price.ToString("#0.00") + " " + carCurrencyCode + "(" + carCurrencyName + ")<br/>" +
  1439. "明细:" + item.PriceContent + "<br/>" +
  1440. "备注:" + item.Remark + "<br/><br/>";
  1441. }
  1442. _detail.PriceMsgContent = priceMsg;
  1443. }
  1444. break;
  1445. case 80: //签证
  1446. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  1447. if (visaInfo != null)
  1448. {
  1449. _detail.PriceNameContent = getClientNameStr(clientNameList, visaInfo.VisaClient);
  1450. _detail.PriceMsgContent = $"签证描述:{visaInfo.VisaDescription}<br/> 备注:{visaInfo.Remark}";
  1451. }
  1452. break;
  1453. case 81: //邀请/公务活动
  1454. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  1455. if (_ioa != null)
  1456. {
  1457. string inviteCurrName = "Unknown", //邀请费用币种 Name
  1458. inviteCurrCode = "Unknown", //邀请费用币种 Code
  1459. sendCurrName = "Unknown", //快递费用币种 Name
  1460. sendCurrCode = "Unknown", //快递费用币种 Code
  1461. eventsCurrName = "Unknown", //公务活动费币种 Name
  1462. eventsCurrCode = "Unknown", //公务活动费币种 Code
  1463. translateCurrName = "Unknown", //公务翻译费 Name
  1464. translateCurrCode = "Unknown"; //公务翻译费 Code
  1465. #region 处理费用币种
  1466. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  1467. if (inviteCurrData != null)
  1468. {
  1469. inviteCurrName = inviteCurrData.Remark;
  1470. inviteCurrCode = inviteCurrData.Name;
  1471. }
  1472. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  1473. if (sendCurrData != null)
  1474. {
  1475. sendCurrName = sendCurrData.Remark;
  1476. sendCurrCode = sendCurrData.Name;
  1477. }
  1478. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  1479. if (eventsCurrData != null)
  1480. {
  1481. eventsCurrName = eventsCurrData.Remark;
  1482. eventsCurrCode = eventsCurrData.Name;
  1483. }
  1484. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  1485. if (translateCurrData != null)
  1486. {
  1487. translateCurrName = translateCurrData.Remark;
  1488. translateCurrCode = translateCurrData.Name;
  1489. }
  1490. #endregion
  1491. _detail.PriceNameContent = _ioa.InviterArea;
  1492. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  1493. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  1494. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  1495. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  1496. $@"备注:" + _ioa.Remark + "<br/>";
  1497. }
  1498. break;
  1499. case 82: //团组客户保险
  1500. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  1501. if (customers != null)
  1502. {
  1503. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  1504. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  1505. }
  1506. break;
  1507. case 85: //机票预订
  1508. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1509. if (jpRes != null)
  1510. {
  1511. string FlightsDescription = jpRes.FlightsDescription;
  1512. string PriceDescription = jpRes.PriceDescription;
  1513. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  1514. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  1515. }
  1516. break;
  1517. case 98://其他款项
  1518. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  1519. if (gdpRes != null)
  1520. {
  1521. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  1522. _detail.PriceNameContent = gdpRes.PriceName;
  1523. }
  1524. break;
  1525. case 285://收款退还
  1526. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  1527. if (refundAndOtherMoney != null)
  1528. {
  1529. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  1530. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  1531. }
  1532. break;
  1533. case 751://酒店早餐
  1534. break;
  1535. case 1015://超支费用
  1536. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  1537. if (groupExtraCost != null)
  1538. {
  1539. _detail.PriceNameContent = groupExtraCost.PriceName;
  1540. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  1541. }
  1542. break;
  1543. default:
  1544. break;
  1545. }
  1546. /*
  1547. * 申请人
  1548. */
  1549. string operatorName = " - ";
  1550. Sys_Users _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  1551. if (_opUser != null)
  1552. {
  1553. operatorName = _opUser.CnName;
  1554. }
  1555. _detail.OperatorName = operatorName;
  1556. /*
  1557. * 审核人
  1558. */
  1559. string auditOperatorName = "Unknown";
  1560. if (entity.AuditGMOperate == 0)
  1561. auditOperatorName = " - ";
  1562. else if (entity.AuditGMOperate == 4)
  1563. auditOperatorName = "自动审核";
  1564. else
  1565. {
  1566. Sys_Users _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  1567. if (_adUser != null)
  1568. {
  1569. auditOperatorName = _adUser.CnName;
  1570. }
  1571. }
  1572. _detail.AuditOperatorName = auditOperatorName;
  1573. /*
  1574. * 超预算比例
  1575. */
  1576. string overBudgetStr = "";
  1577. if (entity.ExceedBudget == -1)
  1578. overBudgetStr = sdPriceName.Name + "尚无预算";
  1579. else if (entity.ExceedBudget == 0)
  1580. overBudgetStr = "未超预算";
  1581. else
  1582. overBudgetStr = entity.ExceedBudget.ToString("P");
  1583. _detail.OverBudget = overBudgetStr;
  1584. /*
  1585. * 费用总计
  1586. */
  1587. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  1588. {
  1589. CurrencyId = entity.PaymentCurrency,
  1590. CurrencyName = PaymentCurrency_WaitPay,
  1591. AmountPayable = entity.PayMoney,
  1592. ThisPayment = CurrPayStr,
  1593. BalancePayment = BalanceStr,
  1594. AuditedFunds = CurrPayStr
  1595. });
  1596. _detail.IsAuditGM = entity.IsAuditGM;
  1597. detailList.Add(_detail);
  1598. }
  1599. #endregion
  1600. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  1601. /*
  1602. * 下方描述处理
  1603. */
  1604. List<CreditCardPaymentCurrencyPriceItem> nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  1605. CreditCardPaymentCurrencyPriceItem ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  1606. if (ccpCurrencyPrice != null)
  1607. {
  1608. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  1609. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  1610. }
  1611. else
  1612. {
  1613. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  1614. }
  1615. string amountPayableStr = string.Format(@"应付款总金额: ");
  1616. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  1617. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  1618. string auditedFundsStr = string.Format(@"已审费用总额: ");
  1619. foreach (var item in nonDuplicat)
  1620. {
  1621. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  1622. if (strs.Count > 0)
  1623. {
  1624. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  1625. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  1626. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), item.CurrencyName);
  1627. //单独处理此次付款金额
  1628. if (item.CurrencyId == 836) //人民币
  1629. {
  1630. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  1631. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", thisPayment.ToString("#0.00"), item.CurrencyName);
  1632. }
  1633. else
  1634. {
  1635. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1636. }
  1637. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), item.CurrencyName);
  1638. //单独处理已审核费用
  1639. if (item.CurrencyId == 836) //人民币
  1640. {
  1641. decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  1642. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), item.CurrencyName);
  1643. }
  1644. else
  1645. {
  1646. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", "0.00", item.CurrencyName);
  1647. }
  1648. }
  1649. }
  1650. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  1651. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  1652. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  1653. _view.TotalStr4 = auditedFundsStr.Substring(0, auditedFundsStr.Length - 1);
  1654. var _view1 = new
  1655. {
  1656. PageFuncAuth = pageFunAuthView,
  1657. Data = _view
  1658. };
  1659. return Ok(JsonView(_view1));
  1660. }
  1661. catch (Exception ex)
  1662. {
  1663. return Ok(JsonView(false, ex.Message));
  1664. }
  1665. }
  1666. /// <summary>
  1667. /// 费用审核
  1668. /// 修改团组费用审核状态
  1669. /// </summary>
  1670. /// <param name="_dto">参数Json字符串</param>
  1671. /// <returns></returns>
  1672. [HttpPost]
  1673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1674. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  1675. {
  1676. #region 参数验证
  1677. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1678. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1679. #endregion
  1680. #region 页面操作权限验证
  1681. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1682. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1683. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  1684. #endregion
  1685. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  1686. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  1687. DateTime dtNow = DateTime.Now;
  1688. _groupRepository.BeginTran();
  1689. int rst = 0;
  1690. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  1691. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  1692. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  1693. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  1694. List<dynamic> msgDatas = new List<dynamic>();
  1695. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  1696. foreach (var item in idList)
  1697. {
  1698. int CreditId = int.Parse(item);
  1699. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  1700. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  1701. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  1702. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  1703. .Where(s => s.Id == CreditId)
  1704. .ExecuteCommandAsync();
  1705. if (result < 1)
  1706. {
  1707. rst = -1;
  1708. _groupRepository.RollbackTran();
  1709. return Ok(JsonView(false, "操作失败并回滚!"));
  1710. }
  1711. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  1712. if (creditData != null)
  1713. {
  1714. #region 应用通知配置
  1715. try
  1716. {
  1717. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  1718. }
  1719. catch (Exception ex)
  1720. {
  1721. }
  1722. #endregion
  1723. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  1724. string groupNameStr = string.Empty;
  1725. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  1726. if (groupData != null) groupNameStr = groupData.TeamName;
  1727. string creditTypeStr = string.Empty;
  1728. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  1729. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  1730. string creditCurrency = string.Empty;
  1731. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  1732. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  1733. if (creditCurrency.Equals("CNY"))
  1734. {
  1735. creditData.DayRate = 1.0000M;
  1736. }
  1737. if (creditData.PayPercentage == 0.00M)
  1738. {
  1739. creditData.PayPercentage = 100M;
  1740. }
  1741. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  1742. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  1743. string msgContent = "";
  1744. if (creditCurrency.Equals("CNY"))
  1745. {
  1746. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  1747. }
  1748. else
  1749. {
  1750. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  1751. }
  1752. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  1753. }
  1754. }
  1755. if (rst == 0)
  1756. {
  1757. _groupRepository.CommitTran();
  1758. foreach (var item in msgDatas)
  1759. {
  1760. //发送消息
  1761. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  1762. }
  1763. #region 应用推送
  1764. try
  1765. {
  1766. foreach (var ccpId in dic_ccp_user.Keys)
  1767. {
  1768. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  1769. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  1770. }
  1771. }
  1772. catch (Exception)
  1773. {
  1774. }
  1775. #endregion
  1776. return Ok(JsonView(true, "操作成功!"));
  1777. }
  1778. return Ok(JsonView(false, "操作失败!"));
  1779. }
  1780. #endregion
  1781. #region 机票费用录入
  1782. /// <summary>
  1783. /// 机票录入当前登录人可操作团组
  1784. /// </summary>
  1785. /// <param name="dto"></param>
  1786. /// <returns></returns>
  1787. [HttpPost]
  1788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1789. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  1790. {
  1791. try
  1792. {
  1793. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  1794. if (groupData.Code != 0)
  1795. {
  1796. return Ok(JsonView(false, groupData.Msg));
  1797. }
  1798. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1799. }
  1800. catch (Exception ex)
  1801. {
  1802. return Ok(JsonView(false, "程序错误!"));
  1803. throw;
  1804. }
  1805. }
  1806. /// <summary>
  1807. /// 机票费用录入列表
  1808. /// </summary>
  1809. /// <param name="dto"></param>
  1810. /// <returns></returns>
  1811. [HttpPost]
  1812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1813. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  1814. {
  1815. try
  1816. {
  1817. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  1818. if (groupData.Code != 0)
  1819. {
  1820. return Ok(JsonView(false, groupData.Msg));
  1821. }
  1822. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1823. }
  1824. catch (Exception ex)
  1825. {
  1826. return Ok(JsonView(false, ex.Message));
  1827. throw;
  1828. }
  1829. }
  1830. /// <summary>
  1831. /// 根据id查询费用录入信息
  1832. /// </summary>
  1833. /// <param name="dto"></param>
  1834. /// <returns></returns>
  1835. [HttpPost]
  1836. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1837. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  1838. {
  1839. try
  1840. {
  1841. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  1842. if (groupData.Code != 0)
  1843. {
  1844. return Ok(JsonView(false, groupData.Msg));
  1845. }
  1846. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1847. }
  1848. catch (Exception ex)
  1849. {
  1850. return Ok(JsonView(false, "程序错误!"));
  1851. throw;
  1852. }
  1853. }
  1854. /// <summary>
  1855. /// 机票费用录入操作(Status:1.新增,2.修改)
  1856. /// </summary>
  1857. /// <param name="dto"></param>
  1858. /// <returns></returns>
  1859. [HttpPost]
  1860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1861. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  1862. {
  1863. try
  1864. {
  1865. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  1866. if (groupData.Code != 0)
  1867. {
  1868. return Ok(JsonView(false, groupData.Msg));
  1869. }
  1870. #region 应用推送
  1871. try
  1872. {
  1873. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  1874. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  1875. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  1876. }
  1877. catch (Exception ex)
  1878. {
  1879. }
  1880. #endregion
  1881. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1882. }
  1883. catch (Exception ex)
  1884. {
  1885. return Ok(JsonView(false, "程序错误!"));
  1886. throw;
  1887. }
  1888. }
  1889. /// <summary>
  1890. /// 根据舱位类型查询接团客户名单信息
  1891. /// </summary>
  1892. /// <param name="dto"></param>
  1893. /// <returns></returns>
  1894. [HttpPost]
  1895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1896. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  1897. {
  1898. try
  1899. {
  1900. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  1901. if (crm_Groups.Count != 0)
  1902. {
  1903. List<dynamic> Customer = new List<dynamic>();
  1904. foreach (var item in crm_Groups)
  1905. {
  1906. var data = new
  1907. {
  1908. Id = item.Id,
  1909. Pinyin = item.Pinyin,
  1910. Name = item.LastName + item.FirstName
  1911. };
  1912. Customer.Add(data);
  1913. }
  1914. return Ok(JsonView(true, "查询成功!", Customer));
  1915. }
  1916. return Ok(JsonView(true, "暂无数据", crm_Groups));
  1917. }
  1918. catch (Exception ex)
  1919. {
  1920. return Ok(JsonView(false, "程序错误!"));
  1921. throw;
  1922. }
  1923. }
  1924. /// <summary>
  1925. /// 根据团号获取客户信息
  1926. /// </summary>
  1927. /// <param name="dto"></param>
  1928. /// <returns></returns>
  1929. [HttpPost]
  1930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1931. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  1932. {
  1933. var jw = JsonView(false);
  1934. if (dto.DIID < 1)
  1935. {
  1936. jw.Msg += "请输入正确的diid";
  1937. return Ok(jw);
  1938. }
  1939. var arr = getSimplClientList(dto.DIID);
  1940. jw = JsonView(true, "获取成功!", arr);
  1941. return Ok(jw);
  1942. }
  1943. private List<SimplClientInfo> getSimplClientList(int diId)
  1944. {
  1945. 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);
  1946. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  1947. return arr;
  1948. }
  1949. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  1950. {
  1951. string result = origin;
  1952. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  1953. {
  1954. string[] temparr = origin.Split(',');
  1955. string fistrStr = temparr[0];
  1956. int count = temparr.Count();
  1957. int tempId;
  1958. bool success = int.TryParse(fistrStr, out tempId);
  1959. if (success)
  1960. {
  1961. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  1962. if (tempInfo != null)
  1963. {
  1964. if (count > 1)
  1965. {
  1966. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  1967. }
  1968. else
  1969. {
  1970. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  1971. }
  1972. }
  1973. }
  1974. }
  1975. return result;
  1976. }
  1977. /// <summary>
  1978. /// 机票费用录入,删除
  1979. /// </summary>
  1980. /// <param name="dto"></param>
  1981. /// <returns></returns>
  1982. [HttpPost]
  1983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1984. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  1985. {
  1986. try
  1987. {
  1988. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  1989. if (res)
  1990. {
  1991. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  1992. {
  1993. IsDel = 1,
  1994. DeleteUserId = dto.DeleteUserId,
  1995. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  1996. }).ExecuteCommandAsync();
  1997. return Ok(JsonView(true, "删除成功!"));
  1998. }
  1999. return Ok(JsonView(false, "删除失败!"));
  2000. }
  2001. catch (Exception ex)
  2002. {
  2003. return Ok(JsonView(false, "程序错误!"));
  2004. throw;
  2005. }
  2006. }
  2007. /// <summary>
  2008. /// 导出机票录入报表
  2009. /// </summary>
  2010. /// <param name="dto"></param>
  2011. /// <returns></returns>
  2012. [HttpPost]
  2013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2014. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2015. {
  2016. try
  2017. {
  2018. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2019. if (groupData.Code != 0)
  2020. {
  2021. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2022. }
  2023. else
  2024. {
  2025. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2026. if (AirTicketReservations.Count != 0)
  2027. {
  2028. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2029. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2030. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2031. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2032. WorkbookDesigner designer = new WorkbookDesigner();
  2033. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2034. decimal countCost = 0;
  2035. foreach (var item in AirTicketReservations)
  2036. {
  2037. #region 处理客人姓名
  2038. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2039. item.ClientName = clientNames;
  2040. #endregion
  2041. if (item.BankType == "其他")
  2042. {
  2043. item.BankNo = "--";
  2044. }
  2045. else
  2046. {
  2047. if (!string.IsNullOrEmpty(item.BankType))
  2048. {
  2049. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2050. }
  2051. }
  2052. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2053. item.Price = System.Decimal.Round(item.Price, 2);
  2054. countCost += Convert.ToDecimal(item.Price);
  2055. }
  2056. designer.SetDataSource("Export", AirTicketReservations);
  2057. designer.SetDataSource("ExportDiCode", diCode);
  2058. designer.SetDataSource("ExportDiName", diName);
  2059. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2060. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2061. designer.Process();
  2062. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2063. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2064. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2065. return Ok(JsonView(true, "成功", url = rst));
  2066. }
  2067. else
  2068. {
  2069. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2070. }
  2071. }
  2072. }
  2073. catch (Exception ex)
  2074. {
  2075. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2076. throw;
  2077. }
  2078. }
  2079. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2080. /// <summary>
  2081. /// 行程单导出
  2082. /// </summary>
  2083. /// <param name="dto"></param>
  2084. /// <returns></returns>
  2085. [HttpPost]
  2086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2087. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2088. {
  2089. try
  2090. {
  2091. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2092. if (groupData.Code != 0)
  2093. {
  2094. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2095. }
  2096. else
  2097. {
  2098. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2099. if (dto.Language == "CN")
  2100. {
  2101. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2102. DocumentBuilder builder = new DocumentBuilder(doc);
  2103. int tableIndex = 0;//表格索引
  2104. //得到文档中的第一个表格
  2105. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2106. foreach (var item in _AirTicketReservations)
  2107. {
  2108. #region 处理固定数据
  2109. string[] FlightsCode = item.FlightsCode.Split('/');
  2110. if (FlightsCode.Length != 0)
  2111. {
  2112. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2113. if (_AirCompany != null)
  2114. {
  2115. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2116. }
  2117. else
  2118. {
  2119. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2120. }
  2121. }
  2122. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2123. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2124. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2125. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2126. string name = "";
  2127. foreach (string clientName in nameArray)
  2128. {
  2129. if (!name.Contains(clientName))
  2130. {
  2131. name += clientName + ",";
  2132. }
  2133. }
  2134. if (!string.IsNullOrWhiteSpace(name))
  2135. {
  2136. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2137. }
  2138. else
  2139. {
  2140. table.Range.Bookmarks["ClientName"].Text = "--";
  2141. }
  2142. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2143. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2144. table.Range.Bookmarks["JointTicket"].Text = "--";
  2145. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2146. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2147. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2148. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2149. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2150. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2151. #endregion
  2152. #region 循环数据处理
  2153. List<AirInfo> airs = new List<AirInfo>();
  2154. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2155. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2156. for (int i = 0; i < FlightsCode.Length; i++)
  2157. {
  2158. AirInfo air = new AirInfo();
  2159. string[] tempstr = DayArray[i]
  2160. .Replace("\r\n", string.Empty)
  2161. .Replace("\\r\\n", string.Empty)
  2162. .TrimStart().TrimEnd()
  2163. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2164. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2165. string starCity = "";
  2166. if (star_Three != null)
  2167. {
  2168. starCity = star_Three.AirPort;
  2169. }
  2170. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2171. string EndCity = "";
  2172. if (End_Three != null)
  2173. {
  2174. EndCity = End_Three.AirPort;
  2175. }
  2176. air.Destination = starCity + "/" + EndCity;
  2177. air.Flight = FlightsCode[i];
  2178. air.SeatingClass = item.CTypeName;
  2179. string dateTime = tempstr[2];
  2180. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2181. air.FlightDate = DateTemp;
  2182. air.DepartureTime = tempstr[5];
  2183. air.LandingTime = tempstr[6];
  2184. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2185. air.TicketStatus = "--";
  2186. air.Luggage = "--";
  2187. air.DepartureTerminal = "--";
  2188. air.LandingTerminal = "--";
  2189. airs.Add(air);
  2190. }
  2191. int row = 13;
  2192. for (int i = 0; i < airs.Count; i++)
  2193. {
  2194. if (airs.Count > 2)
  2195. {
  2196. for (int j = 0; j < airs.Count - 2; j++)
  2197. {
  2198. var CopyRow = table.Rows[12].Clone(true);
  2199. table.Rows.Add(CopyRow);
  2200. }
  2201. }
  2202. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2203. int index = 0;
  2204. foreach (PropertyInfo property in properties)
  2205. {
  2206. string value = property.GetValue(airs[i]).ToString();
  2207. Cell ishcel0 = table.Rows[row].Cells[index];
  2208. Paragraph p = new Paragraph(doc);
  2209. string s = value;
  2210. p.AppendChild(new Run(doc, s));
  2211. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2212. ishcel0.AppendChild(p);
  2213. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2214. index++;
  2215. }
  2216. row++;
  2217. }
  2218. #endregion
  2219. Paragraph lastParagraph = new Paragraph(doc);
  2220. //第一个表格末尾加段落
  2221. table.ParentNode.InsertAfter(lastParagraph, table);
  2222. //复制第一个表格
  2223. Table cloneTable = (Table)table.Clone(true);
  2224. //在文档末尾段落后面加入复制的表格
  2225. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2226. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2227. {
  2228. int rownewsIndex = 13;
  2229. for (int i = 0; i < 2; i++)
  2230. {
  2231. var CopyRow = table.Rows[12].Clone(true);
  2232. table.Rows.RemoveAt(13);
  2233. table.Rows.Add(CopyRow);
  2234. rownewsIndex++;
  2235. }
  2236. }
  2237. else
  2238. {
  2239. table.Rows.RemoveAt(12);
  2240. }
  2241. cloneTable.Rows.RemoveAt(12);
  2242. }
  2243. if (_AirTicketReservations.Count != 0)
  2244. {
  2245. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2246. if (FlightsCode.Length != 0)
  2247. {
  2248. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2249. if (_AirCompany != null)
  2250. {
  2251. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2252. }
  2253. else
  2254. {
  2255. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2256. }
  2257. }
  2258. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2259. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2260. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2261. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2262. string name = "";
  2263. foreach (string clientName in nameArray)
  2264. {
  2265. if (!name.Contains(clientName))
  2266. {
  2267. name += clientName + ",";
  2268. }
  2269. }
  2270. if (!string.IsNullOrWhiteSpace(name))
  2271. {
  2272. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2273. }
  2274. else
  2275. {
  2276. table.Range.Bookmarks["ClientName"].Text = "--";
  2277. }
  2278. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2279. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2280. table.Range.Bookmarks["JointTicket"].Text = "--";
  2281. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2282. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2283. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2284. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2285. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2286. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2287. }
  2288. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2289. //保存合并后的文档
  2290. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  2291. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2292. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2293. return Ok(JsonView(true, "成功!", rst));
  2294. }
  2295. else
  2296. {
  2297. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  2298. DocumentBuilder builder = new DocumentBuilder(doc);
  2299. int tableIndex = 0;//表格索引
  2300. //得到文档中的第一个表格
  2301. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2302. List<string> texts = new List<string>();
  2303. foreach (var item in _AirTicketReservations)
  2304. {
  2305. string[] FlightsCode = item.FlightsCode.Split('/');
  2306. if (FlightsCode.Length != 0)
  2307. {
  2308. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2309. if (_AirCompany != null)
  2310. {
  2311. if (!transDic.ContainsKey(_AirCompany.CnName))
  2312. {
  2313. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  2314. }
  2315. }
  2316. else
  2317. {
  2318. if (!transDic.ContainsKey("--"))
  2319. {
  2320. transDic.Add("--", "--");
  2321. }
  2322. }
  2323. }
  2324. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2325. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2326. string name = "";
  2327. foreach (string clientName in nameArray)
  2328. {
  2329. name += clientName + ",";
  2330. }
  2331. if (!texts.Contains(name))
  2332. {
  2333. texts.Add(name);
  2334. }
  2335. List<AirInfo> airs = new List<AirInfo>();
  2336. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2337. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2338. for (int i = 0; i < FlightsCode.Length; i++)
  2339. {
  2340. AirInfo air = new AirInfo();
  2341. string[] tempstr = DayArray[i]
  2342. .Replace("\r\n", string.Empty)
  2343. .Replace("\\r\\n", string.Empty)
  2344. .TrimStart().TrimEnd()
  2345. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2346. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2347. if (star_Three != null)
  2348. {
  2349. if (!transDic.ContainsKey(star_Three.AirPort))
  2350. {
  2351. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  2352. }
  2353. }
  2354. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2355. if (End_Three != null)
  2356. {
  2357. if (!transDic.ContainsKey(End_Three.AirPort))
  2358. {
  2359. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  2360. }
  2361. }
  2362. if (!texts.Contains(item.CTypeName))
  2363. {
  2364. texts.Add(item.CTypeName);
  2365. }
  2366. }
  2367. }
  2368. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  2369. if (transData.Count > 0)
  2370. {
  2371. foreach (TranslateResult item in transData)
  2372. {
  2373. if (!transDic.ContainsKey(item.Query))
  2374. {
  2375. transDic.Add(item.Query, item.Translation);
  2376. }
  2377. }
  2378. }
  2379. foreach (var item in _AirTicketReservations)
  2380. {
  2381. #region 处理固定数据
  2382. string[] FlightsCode = item.FlightsCode.Split('/');
  2383. if (FlightsCode.Length != 0)
  2384. {
  2385. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2386. if (_AirCompany != null)
  2387. {
  2388. string str = "--";
  2389. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2390. if (!string.IsNullOrEmpty(translateResult))
  2391. {
  2392. str = translateResult;
  2393. str = _airTicketResRep.Processing(str);
  2394. }
  2395. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2396. }
  2397. else
  2398. {
  2399. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2400. }
  2401. }
  2402. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2403. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2404. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2405. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2406. string names = "";
  2407. foreach (string clientName in nameArray)
  2408. {
  2409. names += clientName + ",";
  2410. }
  2411. if (!string.IsNullOrWhiteSpace(names))
  2412. {
  2413. string str = "--";
  2414. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2415. if (!string.IsNullOrEmpty(translateResult))
  2416. {
  2417. str = translateResult;
  2418. str = _airTicketResRep.Processing(str);
  2419. }
  2420. table.Range.Bookmarks["ClientName"].Text = str;
  2421. }
  2422. else
  2423. {
  2424. table.Range.Bookmarks["ClientName"].Text = "--";
  2425. }
  2426. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2427. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2428. table.Range.Bookmarks["JointTicket"].Text = "--";
  2429. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2430. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2431. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2432. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2433. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2434. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2435. #endregion
  2436. #region 循环数据处理
  2437. List<AirInfo> airs = new List<AirInfo>();
  2438. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2439. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2440. for (int i = 0; i < FlightsCode.Length; i++)
  2441. {
  2442. AirInfo air = new AirInfo();
  2443. string[] tempstr = DayArray[i]
  2444. .Replace("\r\n", string.Empty)
  2445. .Replace("\\r\\n", string.Empty)
  2446. .TrimStart().TrimEnd()
  2447. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2448. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2449. string starCity = "";
  2450. if (star_Three != null)
  2451. {
  2452. string str2 = "--";
  2453. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  2454. if (!string.IsNullOrEmpty(translateResult2))
  2455. {
  2456. str2 = translateResult2;
  2457. str2 = _airTicketResRep.Processing(str2);
  2458. }
  2459. starCity = str2;
  2460. }
  2461. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2462. string EndCity = "";
  2463. if (End_Three != null)
  2464. {
  2465. string str1 = "--";
  2466. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  2467. if (!string.IsNullOrEmpty(translateResult1))
  2468. {
  2469. str1 = translateResult1;
  2470. str1 = _airTicketResRep.Processing(str1);
  2471. }
  2472. EndCity = str1;
  2473. }
  2474. air.Destination = starCity + "/" + EndCity;
  2475. air.Flight = FlightsCode[i];
  2476. string str = "--";
  2477. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  2478. if (!string.IsNullOrEmpty(translateResult))
  2479. {
  2480. str = translateResult;
  2481. str = _airTicketResRep.Processing(str);
  2482. }
  2483. air.SeatingClass = str;
  2484. string dateTime = tempstr[2];
  2485. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2486. air.FlightDate = DateTemp;
  2487. air.DepartureTime = tempstr[5];
  2488. air.LandingTime = tempstr[6];
  2489. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  2490. air.TicketStatus = "--";
  2491. air.Luggage = "--";
  2492. air.DepartureTerminal = "--";
  2493. air.LandingTerminal = "--";
  2494. airs.Add(air);
  2495. }
  2496. int row = 13;
  2497. for (int i = 0; i < airs.Count; i++)
  2498. {
  2499. if (airs.Count > 2)
  2500. {
  2501. for (int j = 0; j < airs.Count - 2; j++)
  2502. {
  2503. var CopyRow = table.Rows[12].Clone(true);
  2504. table.Rows.Add(CopyRow);
  2505. }
  2506. }
  2507. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  2508. int index = 0;
  2509. foreach (PropertyInfo property in properties)
  2510. {
  2511. string value = property.GetValue(airs[i]).ToString();
  2512. Cell ishcel0 = table.Rows[row].Cells[index];
  2513. Paragraph p = new Paragraph(doc);
  2514. string s = value;
  2515. p.AppendChild(new Run(doc, s));
  2516. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  2517. ishcel0.AppendChild(p);
  2518. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  2519. //ishcel0.CellFormat.VerticalAlignment=
  2520. index++;
  2521. }
  2522. row++;
  2523. }
  2524. #endregion
  2525. Paragraph lastParagraph = new Paragraph(doc);
  2526. //第一个表格末尾加段落
  2527. table.ParentNode.InsertAfter(lastParagraph, table);
  2528. //复制第一个表格
  2529. Table cloneTable = (Table)table.Clone(true);
  2530. //在文档末尾段落后面加入复制的表格
  2531. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  2532. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  2533. {
  2534. int rownewsIndex = 13;
  2535. for (int i = 0; i < 2; i++)
  2536. {
  2537. var CopyRow = table.Rows[12].Clone(true);
  2538. table.Rows.RemoveAt(13);
  2539. table.Rows.Add(CopyRow);
  2540. rownewsIndex++;
  2541. }
  2542. }
  2543. else
  2544. {
  2545. table.Rows.RemoveAt(12);
  2546. }
  2547. cloneTable.Rows.RemoveAt(12);
  2548. }
  2549. if (_AirTicketReservations.Count != 0)
  2550. {
  2551. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  2552. if (FlightsCode.Length != 0)
  2553. {
  2554. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2555. if (_AirCompany != null)
  2556. {
  2557. string str = "--";
  2558. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  2559. if (!string.IsNullOrEmpty(translateResult))
  2560. {
  2561. str = translateResult;
  2562. str = _airTicketResRep.Processing(str);
  2563. }
  2564. table.Range.Bookmarks["AirlineCompany"].Text = str;
  2565. }
  2566. else
  2567. {
  2568. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2569. }
  2570. }
  2571. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2572. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2573. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2574. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2575. string names = "";
  2576. foreach (string clientName in nameArray)
  2577. {
  2578. names += clientName + ",";
  2579. }
  2580. if (!string.IsNullOrWhiteSpace(names))
  2581. {
  2582. string str = "--";
  2583. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  2584. if (!string.IsNullOrEmpty(translateResult))
  2585. {
  2586. str = translateResult;
  2587. str = _airTicketResRep.Processing(str);
  2588. }
  2589. table.Range.Bookmarks["ClientName"].Text = str;
  2590. }
  2591. else
  2592. {
  2593. table.Range.Bookmarks["ClientName"].Text = "--";
  2594. }
  2595. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2596. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2597. table.Range.Bookmarks["JointTicket"].Text = "--";
  2598. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2599. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2600. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2601. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2602. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2603. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2604. }
  2605. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  2606. //保存合并后的文档
  2607. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  2608. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  2609. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  2610. return Ok(JsonView(true, "成功!", rst));
  2611. }
  2612. }
  2613. }
  2614. catch (Exception ex)
  2615. {
  2616. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  2617. throw;
  2618. }
  2619. }
  2620. #endregion
  2621. #region 团组增减款项 --> 其他款项
  2622. /// <summary>
  2623. /// 团组增减款项下拉框绑定
  2624. /// </summary>
  2625. /// <param name="dto"></param>
  2626. /// <returns></returns>
  2627. [HttpPost]
  2628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2629. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  2630. {
  2631. #region 参数验证
  2632. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2633. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  2634. #endregion
  2635. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  2636. }
  2637. /// <summary>
  2638. /// 根据团组Id查询团组增减款项
  2639. /// </summary>
  2640. /// <param name="dto"></param>
  2641. /// <returns></returns>
  2642. [HttpPost]
  2643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2644. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  2645. {
  2646. #region 参数验证
  2647. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  2648. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  2649. #endregion
  2650. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  2651. }
  2652. /// <summary>
  2653. /// 团组增减款项操作(Status:1.新增,2.修改)
  2654. /// </summary>
  2655. /// <param name="dto"></param>
  2656. /// <returns></returns>
  2657. [HttpPost]
  2658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2659. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  2660. {
  2661. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  2662. if (groupData.Code != 200)
  2663. {
  2664. return Ok(JsonView(false, groupData.Msg));
  2665. }
  2666. #region 应用推送
  2667. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2668. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2669. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2670. #endregion
  2671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2672. }
  2673. /// <summary>
  2674. /// 团组增减款项操作 删除
  2675. /// </summary>
  2676. /// <param name="dto"></param>
  2677. /// <returns></returns>
  2678. [HttpPost]
  2679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2680. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  2681. {
  2682. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  2683. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  2684. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  2685. if (res.Code == 0)
  2686. {
  2687. return Ok(JsonView(true, "删除成功!"));
  2688. }
  2689. return Ok(JsonView(false, "删除失败!"));
  2690. }
  2691. /// <summary>
  2692. /// 根据团组增减款项Id查询
  2693. /// </summary>
  2694. /// <param name="dto"></param>
  2695. /// <returns></returns>
  2696. [HttpPost]
  2697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2698. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  2699. {
  2700. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  2701. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  2702. }
  2703. /// <summary>
  2704. /// 查询供应商名称
  2705. /// </summary>
  2706. /// <param name="dto"></param>
  2707. /// <returns></returns>
  2708. [HttpPost]
  2709. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  2710. {
  2711. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  2712. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  2713. ?? new List<Grp_DecreasePayments>();
  2714. dbResult = dbResult.Distinct(new
  2715. ProductComparer()).ToList();
  2716. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  2717. {
  2718. x.Id,
  2719. x.SupplierAddress,
  2720. x.SupplierArea,
  2721. x.SupplierContact,
  2722. x.SupplierContactNumber,
  2723. x.SupplierEmail,
  2724. x.SupplierName,
  2725. x.SupplierSocialAccount,
  2726. x.SupplierTypeId,
  2727. }).ToList());
  2728. return Ok(jw);
  2729. }
  2730. #endregion
  2731. #region 文件上传、删除
  2732. /// <summary>
  2733. /// region 文件上传 可以带参数
  2734. /// </summary>
  2735. /// <param name="file"></param>
  2736. /// <returns></returns>
  2737. [HttpPost]
  2738. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2739. public async Task<IActionResult> UploadProject(IFormFile file)
  2740. {
  2741. try
  2742. {
  2743. var TypeName = Request.Headers["TypeName"].ToString();
  2744. if (file != null)
  2745. {
  2746. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2747. //文件名称
  2748. string projectFileName = file.FileName;
  2749. //上传的文件的路径
  2750. string filePath = "";
  2751. if (TypeName == "A")//A代表团组增减款项
  2752. {
  2753. if (!Directory.Exists(fileDir))
  2754. {
  2755. Directory.CreateDirectory(fileDir);
  2756. }
  2757. //上传的文件的路径
  2758. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  2759. }
  2760. else if (TypeName == "B")//B代表商邀相关文件
  2761. {
  2762. if (!Directory.Exists(fileDir))
  2763. {
  2764. Directory.CreateDirectory(fileDir);
  2765. }
  2766. //上传的文件的路径
  2767. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  2768. }
  2769. using (FileStream fs = System.IO.File.Create(filePath))
  2770. {
  2771. file.CopyTo(fs);
  2772. fs.Flush();
  2773. }
  2774. return Ok(JsonView(true, "上传成功!", projectFileName));
  2775. }
  2776. else
  2777. {
  2778. return Ok(JsonView(false, "上传失败!"));
  2779. }
  2780. }
  2781. catch (Exception ex)
  2782. {
  2783. return Ok(JsonView(false, "程序错误!"));
  2784. throw;
  2785. }
  2786. }
  2787. /// <summary>
  2788. /// 删除指定文件
  2789. /// </summary>
  2790. /// <param name="dto"></param>
  2791. /// <returns></returns>
  2792. [HttpPost]
  2793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2794. public async Task<IActionResult> DelFile(DelFileDto dto)
  2795. {
  2796. try
  2797. {
  2798. var TypeName = Request.Headers["TypeName"].ToString();
  2799. string filePath = "";
  2800. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  2801. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  2802. int id = 0;
  2803. if (TypeName == "A")
  2804. {
  2805. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  2806. // 删除该文件
  2807. System.IO.File.Delete(filePath);
  2808. id = await _sqlSugar.Updateable<Grp_DecreasePayments>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_DecreasePayments { FilePath = "" }).ExecuteCommandAsync();
  2809. }
  2810. else if (TypeName == "B")
  2811. {
  2812. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  2813. // 删除该文件
  2814. System.IO.File.Delete(filePath);
  2815. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>().Where(a => a.Id == dto.Id).SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = "" }).ExecuteCommandAsync();
  2816. }
  2817. if (id != 0)
  2818. {
  2819. return Ok(JsonView(true, "成功!"));
  2820. }
  2821. else
  2822. {
  2823. return Ok(JsonView(false, "失败!"));
  2824. }
  2825. }
  2826. catch (Exception ex)
  2827. {
  2828. return Ok(JsonView(false, "程序错误!"));
  2829. throw;
  2830. }
  2831. }
  2832. #endregion
  2833. #region 商邀费用录入
  2834. /// <summary>
  2835. /// 根据团组Id查询商邀费用列表
  2836. /// </summary>
  2837. /// <param name="dto"></param>
  2838. /// <returns></returns>
  2839. [HttpPost]
  2840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2841. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  2842. {
  2843. try
  2844. {
  2845. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  2846. if (groupData.Code != 0)
  2847. {
  2848. return Ok(JsonView(false, groupData.Msg));
  2849. }
  2850. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2851. }
  2852. catch (Exception ex)
  2853. {
  2854. return Ok(JsonView(false, "程序错误!"));
  2855. throw;
  2856. }
  2857. }
  2858. //
  2859. /// <summary>
  2860. /// 商邀费用 Info Page 基础数据源
  2861. /// </summary>
  2862. /// <param name="dto"></param>
  2863. /// <returns></returns>
  2864. [HttpPost]
  2865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2866. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  2867. {
  2868. try
  2869. {
  2870. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  2871. if (groupData.Code != 0)
  2872. {
  2873. return Ok(JsonView(false, groupData.Msg));
  2874. }
  2875. return Ok(JsonView(true, "操作成功", groupData.Data));
  2876. }
  2877. catch (Exception ex)
  2878. {
  2879. return Ok(JsonView(false, ex.Message));
  2880. throw;
  2881. }
  2882. }
  2883. /// <summary>
  2884. /// 根据商邀费用ID查询C表和商邀费用数据
  2885. /// </summary>
  2886. /// <param name="dto"></param>
  2887. /// <returns></returns>
  2888. [HttpPost]
  2889. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2890. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  2891. {
  2892. try
  2893. {
  2894. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  2895. if (groupData.Code != 0)
  2896. {
  2897. return Ok(JsonView(false, groupData.Msg));
  2898. }
  2899. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2900. }
  2901. catch (Exception ex)
  2902. {
  2903. return Ok(JsonView(false, ex.Message));
  2904. throw;
  2905. }
  2906. }
  2907. /// <summary>
  2908. /// 商邀费用录入操作(Status:1.新增,2.修改)
  2909. /// </summary>
  2910. /// <param name="dto"></param>
  2911. /// <returns></returns>
  2912. [HttpPost]
  2913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2914. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  2915. {
  2916. try
  2917. {
  2918. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  2919. if (groupData.Code != 0)
  2920. {
  2921. return Ok(JsonView(false, groupData.Msg));
  2922. }
  2923. #region 应用推送
  2924. try
  2925. {
  2926. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2927. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2928. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2929. }
  2930. catch (Exception ex)
  2931. {
  2932. }
  2933. #endregion
  2934. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2935. }
  2936. catch (Exception ex)
  2937. {
  2938. return Ok(JsonView(false, "程序错误!"));
  2939. throw;
  2940. }
  2941. }
  2942. /// <summary>
  2943. /// 商邀删除
  2944. /// </summary>
  2945. /// <param name="dto"></param>
  2946. /// <returns></returns>
  2947. [HttpPost]
  2948. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2949. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  2950. {
  2951. try
  2952. {
  2953. _sqlSugar.BeginTran();
  2954. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  2955. .SetColumns(it => new Grp_InvitationOfficialActivities()
  2956. {
  2957. IsDel = 1,
  2958. DeleteUserId = dto.DeleteUserId,
  2959. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2960. })
  2961. .Where(it => it.Id == dto.Id)
  2962. .ExecuteCommand();
  2963. if (res1 > 0)
  2964. {
  2965. int _diId = 0;
  2966. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  2967. if (_ioaInfo != null)
  2968. {
  2969. _diId = _ioaInfo.DiId;
  2970. }
  2971. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  2972. .SetColumns(a => new Grp_CreditCardPayment()
  2973. {
  2974. IsDel = 1,
  2975. DeleteUserId = dto.DeleteUserId,
  2976. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2977. })
  2978. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  2979. .ExecuteCommand();
  2980. if (res2 > 0)
  2981. {
  2982. _sqlSugar.CommitTran();
  2983. return Ok(JsonView(true, "删除成功!"));
  2984. }
  2985. }
  2986. _sqlSugar.RollbackTran();
  2987. return Ok(JsonView(false, "删除失败"));
  2988. }
  2989. catch (Exception ex)
  2990. {
  2991. _sqlSugar.RollbackTran();
  2992. return Ok(JsonView(false, ex.Message));
  2993. }
  2994. }
  2995. #endregion
  2996. #region 团组英文资料
  2997. /// <summary>
  2998. /// 查询团组英文所有资料
  2999. /// </summary>
  3000. /// <param name="dto"></param>
  3001. /// <returns></returns>
  3002. [HttpPost]
  3003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3004. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  3005. {
  3006. try
  3007. {
  3008. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  3009. if (groupData.Code != 0)
  3010. {
  3011. return Ok(JsonView(false, groupData.Msg));
  3012. }
  3013. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3014. }
  3015. catch (Exception ex)
  3016. {
  3017. return Ok(JsonView(false, "程序错误!"));
  3018. throw;
  3019. }
  3020. }
  3021. /// <summary>
  3022. /// 团组英文资料操作(Status:1.新增,2.修改)
  3023. /// </summary>
  3024. /// <param name="dto"></param>
  3025. /// <returns></returns>
  3026. [HttpPost]
  3027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3028. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  3029. {
  3030. try
  3031. {
  3032. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  3033. if (groupData.Code != 0)
  3034. {
  3035. return Ok(JsonView(false, groupData.Msg));
  3036. }
  3037. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3038. }
  3039. catch (Exception ex)
  3040. {
  3041. return Ok(JsonView(false, "程序错误!"));
  3042. throw;
  3043. }
  3044. }
  3045. /// <summary>
  3046. /// 团组英文资料Id查询数据
  3047. /// </summary>
  3048. /// <param name="dto"></param>
  3049. /// <returns></returns>
  3050. [HttpPost]
  3051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3052. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  3053. {
  3054. try
  3055. {
  3056. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  3057. if (_DelegationEnData != null)
  3058. {
  3059. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  3060. }
  3061. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  3062. }
  3063. catch (Exception ex)
  3064. {
  3065. return Ok(JsonView(false, "程序错误!"));
  3066. throw;
  3067. }
  3068. }
  3069. /// <summary>
  3070. /// 团组英文资料删除
  3071. /// </summary>
  3072. /// <param name="dto"></param>
  3073. /// <returns></returns>
  3074. [HttpPost]
  3075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3076. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  3077. {
  3078. try
  3079. {
  3080. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  3081. if (!res)
  3082. {
  3083. return Ok(JsonView(false, "删除失败"));
  3084. }
  3085. return Ok(JsonView(true, "删除成功!"));
  3086. }
  3087. catch (Exception ex)
  3088. {
  3089. return Ok(JsonView(false, "程序错误!"));
  3090. throw;
  3091. }
  3092. }
  3093. #endregion
  3094. #region 导出邀请函
  3095. /// <summary>
  3096. /// 导出邀请函页面初始化
  3097. /// </summary>
  3098. /// <param name="dto"></param>
  3099. /// <returns></returns>
  3100. [HttpPost]
  3101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3102. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  3103. {
  3104. try
  3105. {
  3106. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  3107. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  3108. if (dto.DiId == 0)
  3109. {
  3110. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  3111. }
  3112. else
  3113. {
  3114. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  3115. }
  3116. return Ok(JsonView(true, "查询成功!", new
  3117. {
  3118. deleClient = crm_Deles,
  3119. delegations = grp_Delegations
  3120. }));
  3121. }
  3122. catch (Exception ex)
  3123. {
  3124. return Ok(JsonView(false, "程序错误!"));
  3125. throw;
  3126. }
  3127. }
  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> invitationLetter(DecreasePaymentsListDto dto)
  3136. {
  3137. #region 参数验证
  3138. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3139. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3140. #endregion
  3141. try
  3142. {
  3143. Dictionary<string, string> transDic = new Dictionary<string, string>();
  3144. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  3145. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  3146. From Grp_TourClientList tcl
  3147. Left Join
  3148. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  3149. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  3150. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  3151. From Crm_DeleClient dc
  3152. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  3153. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  3154. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  3155. Where dc.IsDel = 0) temp
  3156. On temp.DcId =tcl.ClientId
  3157. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  3158. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  3159. List<string> texts = new List<string>();
  3160. if (datas.Count != 0)
  3161. {
  3162. foreach (TourClientListDetailsView item in datas)
  3163. {
  3164. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  3165. {
  3166. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  3167. }
  3168. else
  3169. {
  3170. string name = item.LastName + item.FirstName;
  3171. texts.Add(name);
  3172. }
  3173. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  3174. {
  3175. if (!transDic.ContainsKey(item.Job))
  3176. {
  3177. texts.Add(item.Job);
  3178. }
  3179. }
  3180. if (!string.IsNullOrEmpty(item.CompanyFullName))
  3181. {
  3182. texts.Add(item.CompanyFullName);
  3183. }
  3184. }
  3185. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3186. if (transData.Count > 0)
  3187. {
  3188. foreach (TranslateResult item in transData)
  3189. {
  3190. if (!transDic.ContainsKey(item.Query))
  3191. {
  3192. transDic.Add(item.Query, item.Translation);
  3193. }
  3194. }
  3195. }
  3196. List<GuestList> list = new List<GuestList>();
  3197. foreach (TourClientListDetailsView dele in datas)
  3198. {
  3199. GuestList guestList = new GuestList();
  3200. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  3201. {
  3202. guestList.Name = dele.Pinyin;
  3203. }
  3204. else
  3205. {
  3206. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  3207. guestList.Name = Name;
  3208. }
  3209. if (dele.Sex == 0)
  3210. {
  3211. guestList.Sex = "Male";
  3212. }
  3213. else if (dele.Sex == 1)
  3214. {
  3215. guestList.Sex = "Female";
  3216. }
  3217. guestList.DOB = dele.BirthDay.Replace('-', '.');
  3218. if (!string.IsNullOrEmpty(dele.Job))
  3219. {
  3220. guestList.Job = dele.Job;
  3221. }
  3222. list.Add(guestList);
  3223. }
  3224. //载入模板
  3225. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  3226. DocumentBuilder builder = new DocumentBuilder(doc);
  3227. //获取word里所有表格
  3228. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3229. //获取所填表格的序数
  3230. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  3231. var rowStart = tableOne.Rows[0]; //获取第1行
  3232. //循环赋值
  3233. for (int i = 0; i < list.Count; i++)
  3234. {
  3235. builder.MoveToCell(0, i + 1, 0, 0);
  3236. builder.Write(list[i].Name.ToString());
  3237. builder.MoveToCell(0, i + 1, 1, 0);
  3238. builder.Write(list[i].Sex.ToString());
  3239. builder.MoveToCell(0, i + 1, 2, 0);
  3240. builder.Write(list[i].DOB.ToString());
  3241. builder.MoveToCell(0, i + 1, 3, 0);
  3242. builder.Write(list[i].Job.ToString());
  3243. }
  3244. //删除多余行
  3245. while (tableOne.Rows.Count > list.Count + 1)
  3246. {
  3247. tableOne.Rows.RemoveAt(list.Count + 1);
  3248. }
  3249. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3250. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  3251. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  3252. doc.Save(filePath);
  3253. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  3254. return Ok(JsonView(true, "操作成功!", Url));
  3255. }
  3256. else
  3257. {
  3258. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  3259. }
  3260. }
  3261. catch (Exception ex)
  3262. {
  3263. return Ok(JsonView(false, ex.Message));
  3264. throw;
  3265. }
  3266. }
  3267. #endregion
  3268. #region 团组经理模块 出入境费用
  3269. ///// <summary>
  3270. ///// 团组模块 - 出入境费用
  3271. ///// </summary>
  3272. ///// <returns></returns>
  3273. //[HttpPost]
  3274. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3275. //public async Task<IActionResult> SetEnterExitCostCurrencyChange()
  3276. //{
  3277. // try
  3278. // {
  3279. // var data = await _enterExitCostRep.SetEnterExitCostCurrencyChange();
  3280. // if (data.Code != 0)
  3281. // {
  3282. // return Ok(JsonView(false, data.Msg));
  3283. // }
  3284. // return Ok(JsonView(true, "查询成功!"));
  3285. // }
  3286. // catch (Exception ex)
  3287. // {
  3288. // return Ok(JsonView(false, ex.Message));
  3289. // throw;
  3290. // }
  3291. //}
  3292. /// <summary>
  3293. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  3294. /// </summary>
  3295. /// <returns></returns>
  3296. [HttpPost]
  3297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3298. public async Task<IActionResult> SetDayAndCostAreaChange()
  3299. {
  3300. try
  3301. {
  3302. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  3303. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  3304. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  3305. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  3306. foreach (var item in unite) //处理交集数据
  3307. {
  3308. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  3309. }
  3310. foreach (var item in merge) //处理差集数据
  3311. {
  3312. int nationalTravelFeeId = 0;
  3313. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  3314. if (cityData != null) nationalTravelFeeId = cityData.Id;
  3315. else
  3316. {
  3317. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  3318. if (countryData != null) nationalTravelFeeId = countryData.Id;
  3319. }
  3320. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  3321. }
  3322. //只更新dayAndCost 的 nationalTravelFeeId;
  3323. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  3324. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  3325. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  3326. }
  3327. catch (Exception ex)
  3328. {
  3329. return Ok(JsonView(false, ex.Message));
  3330. throw;
  3331. }
  3332. }
  3333. /// <summary>
  3334. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  3335. /// </summary>
  3336. /// <returns></returns>
  3337. [HttpPost]
  3338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3339. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  3340. {
  3341. try
  3342. {
  3343. var groupNameData = await _groupRepository.GetGroupNameList(new GroupNameDto { PortType = dto.PortType });
  3344. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  3345. //SetDataInfoView
  3346. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  3347. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  3348. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  3349. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  3350. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  3351. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  3352. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  3353. //默认币种显示
  3354. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3355. {
  3356. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3357. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3358. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3359. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3360. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3361. };
  3362. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3363. if (_currencyRate.Count > 0)
  3364. {
  3365. foreach (var item in _currencyInfos)
  3366. {
  3367. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3368. if (rateInfo != null)
  3369. {
  3370. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  3371. rate1 *= 1.03M;
  3372. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3373. }
  3374. }
  3375. }
  3376. return Ok(JsonView(true, "查询成功!", new
  3377. {
  3378. GroupNameData = groupNameData.Data,
  3379. CurrencyData = _CurrencyData,
  3380. WordTypeData = _WordTypeData,
  3381. ExcelTypeData = _ExcelTypeData,
  3382. CurrencyInit = _currencyInfos
  3383. }));
  3384. }
  3385. catch (Exception ex)
  3386. {
  3387. return Ok(JsonView(false, ex.Message));
  3388. throw;
  3389. }
  3390. }
  3391. /// <summary>
  3392. /// 团组模块 - 出入境费用
  3393. /// 实时汇率 tips
  3394. /// 签证费用 tips
  3395. /// </summary>
  3396. /// <returns></returns>
  3397. [HttpPost]
  3398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3399. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  3400. {
  3401. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  3402. //默认币种显示
  3403. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  3404. {
  3405. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  3406. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  3407. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  3408. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  3409. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  3410. };
  3411. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  3412. List<dynamic> reteInfos = new List<dynamic>();
  3413. if (_currencyRate.Count > 0)
  3414. {
  3415. foreach (var item in _currencyInfos)
  3416. {
  3417. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  3418. if (rateInfo != null)
  3419. {
  3420. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  3421. decimal rate1 = item.Rate;
  3422. rate1 *= 1.03M;
  3423. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  3424. reteInfos.Add(new
  3425. {
  3426. currCode = item.CurrencyCode,
  3427. currName = item.CurrencyName,
  3428. rate = rate2,
  3429. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  3430. });
  3431. }
  3432. }
  3433. }
  3434. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  3435. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  3436. return Ok(JsonView(true, "查询成功!", new
  3437. {
  3438. //GroupNameData = groupNameData.Data,
  3439. visaData = visaData.Data,
  3440. airData = airData.Data,
  3441. reteInfos = reteInfos
  3442. }));
  3443. }
  3444. /// <summary>
  3445. /// 团组模块 - 出入境费用 - Info
  3446. /// </summary>
  3447. /// <returns></returns>
  3448. [HttpPost]
  3449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3450. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  3451. {
  3452. try
  3453. {
  3454. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  3455. if (data.Code != 0)
  3456. {
  3457. return Ok(JsonView(false, data.Msg));
  3458. }
  3459. return Ok(JsonView(true, "查询成功!", data.Data));
  3460. }
  3461. catch (Exception ex)
  3462. {
  3463. return Ok(JsonView(false, ex.Message));
  3464. }
  3465. }
  3466. /// <summary>
  3467. /// 团组模块 - 出入境费用 - Add And Update
  3468. /// </summary>
  3469. /// <returns></returns>
  3470. [HttpPost]
  3471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3472. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  3473. {
  3474. try
  3475. {
  3476. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  3477. if (data.Code != 0)
  3478. {
  3479. return Ok(JsonView(false, data.Msg));
  3480. }
  3481. return Ok(JsonView(true, data.Msg, data.Data));
  3482. }
  3483. catch (Exception ex)
  3484. {
  3485. return Ok(JsonView(false, ex.Message));
  3486. }
  3487. }
  3488. /// <summary>
  3489. /// 团组模块 - 出入境费用 - File downlaod
  3490. /// </summary>
  3491. /// <param name="dto"></param>
  3492. /// <returns></returns>
  3493. [HttpPost]
  3494. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3495. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  3496. {
  3497. try
  3498. {
  3499. if (dto.DiId < 1)
  3500. {
  3501. return Ok(JsonView(false, "请传入有效的DiId参数;"));
  3502. }
  3503. if (dto.ExportType < 1)
  3504. {
  3505. return Ok(JsonView(false, "请传入有效的ExportType参数; 1 明细表 2 表格"));
  3506. }
  3507. if (dto.SubTypeId < 1)
  3508. {
  3509. return Ok(JsonView(false, @"请传入有效的SubTypeId参数;
  3510. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  3511. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  3512. 3 团组成员名单 1 团组成员名单"));
  3513. }
  3514. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3515. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  3516. if (_EnterExitCosts == null)
  3517. {
  3518. return Ok(JsonView(false, "该团组未填写出入境费用;"));
  3519. }
  3520. //数据源
  3521. List<Grp_DayAndCost> dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  3522. List<Grp_DayAndCost> dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  3523. List<Grp_DayAndCost> dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  3524. List<Grp_DayAndCost> dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  3525. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  3526. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  3527. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  3528. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  3529. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  3530. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  3531. .Select((tcl, dc, cc) => new
  3532. {
  3533. Name = dc.LastName + dc.FirstName,
  3534. Sex = dc.Sex,
  3535. Birthday = dc.BirthDay,
  3536. Company = cc.CompanyFullName,
  3537. Job = dc.Job
  3538. })
  3539. .ToList();
  3540. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  3541. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  3542. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  3543. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  3544. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  3545. if (dto.ExportType == 1) //明细表
  3546. {
  3547. if (dto.SubTypeId == 1005) //1005(默认明细表)
  3548. {
  3549. //获取模板
  3550. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  3551. //载入模板
  3552. Document doc = new Document(tempPath);
  3553. DocumentBuilder builder = new DocumentBuilder(doc);
  3554. //利用键值对存放数据
  3555. Dictionary<string, string> dic = new Dictionary<string, string>();
  3556. decimal stayFeeTotal = _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal); // 住宿费
  3557. decimal mealsFeeTotal = _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal); // 伙食费费
  3558. decimal miscellaneousFeeTotal = _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal); // 公杂费
  3559. decimal tainFeeTotal = _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal); // 培训费
  3560. decimal insidePayTotal = _EnterExitCosts.InsidePay;
  3561. string row1_1 = "";
  3562. if (_EnterExitCosts.Visa > 0)
  3563. {
  3564. //insidePayTotal += _EnterExitCosts.Visa;
  3565. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  3566. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  3567. {
  3568. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  3569. }
  3570. }
  3571. string row1_2 = "";
  3572. if (_EnterExitCosts.YiMiao > 0)
  3573. {
  3574. //insidePayTotal += _EnterExitCosts.YiMiao;
  3575. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  3576. }
  3577. if (_EnterExitCosts.HeSuan > 0)
  3578. {
  3579. //insidePayTotal += _EnterExitCosts.HeSuan;
  3580. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  3581. }
  3582. if (_EnterExitCosts.Service > 0)
  3583. {
  3584. //insidePayTotal += _EnterExitCosts.Service;
  3585. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  3586. }
  3587. string row1_3 = "";
  3588. if (_EnterExitCosts.Safe > 0)
  3589. {
  3590. //insidePayTotal += _EnterExitCosts.Safe;
  3591. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  3592. }
  3593. if (_EnterExitCosts.Ticket > 0)
  3594. {
  3595. //insidePayTotal += _EnterExitCosts.Ticket;
  3596. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  3597. }
  3598. string row1 = "";
  3599. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  3600. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  3601. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}";
  3602. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  3603. dic.Add("Row1Str", row1);
  3604. dic.Add("OutsideJJ", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  3605. dic.Add("OutsaideGW", _EnterExitCosts.OutsaideGWPay.ToString("#0.00"));
  3606. dic.Add("AirJJ", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3607. dic.Add("AirGW", _EnterExitCosts.AirGW.ToString("#0.00"));
  3608. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3609. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  3610. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  3611. string miscellaneousFeeTotalStr = miscellaneousFeeTotal.ToString("#0.00");
  3612. dic.Add("SubGZF", miscellaneousFeeTotalStr);
  3613. //dic.Add("SubPX", tainFeeTotal.ToString("#0.00"));
  3614. decimal subJJC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsideJJPay;
  3615. decimal subGWC = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + _EnterExitCosts.OutsaideGWPay;
  3616. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  3617. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  3618. #region 填充word模板书签内容
  3619. foreach (var key in dic.Keys)
  3620. {
  3621. builder.MoveToBookmark(key);
  3622. builder.Write(dic[key]);
  3623. }
  3624. #endregion
  3625. #region 填充word表格内容
  3626. ////获读取指定表格方法二
  3627. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3628. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3629. for (int i = 0; i < dac1.Count; i++)
  3630. {
  3631. Grp_DayAndCost dac = dac1[i];
  3632. if (dac == null) continue;
  3633. builder.MoveToCell(0, i, 0, 0);
  3634. builder.Write("第" + dac.Days.ToString() + "晚:");
  3635. builder.MoveToCell(0, i, 1, 0);
  3636. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  3637. //builder.Write(dac.Place == null ? "" : dac.Place);
  3638. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3639. builder.MoveToCell(0, i, 2, 0);
  3640. builder.Write("费用标准:");
  3641. string curr = "";
  3642. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3643. if (currData != null)
  3644. {
  3645. curr = currData.Name;
  3646. }
  3647. builder.MoveToCell(0, i, 3, 0);
  3648. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3649. builder.MoveToCell(0, i, 4, 0);
  3650. builder.Write("费用小计:");
  3651. builder.MoveToCell(0, i, 5, 0);
  3652. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3653. }
  3654. //删除多余行
  3655. while (table1.Rows.Count > dac1.Count)
  3656. {
  3657. table1.Rows.RemoveAt(dac1.Count);
  3658. }
  3659. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  3660. for (int i = 0; i < dac2.Count; i++)
  3661. {
  3662. Grp_DayAndCost dac = dac2[i];
  3663. if (dac == null) continue;
  3664. builder.MoveToCell(1, i, 0, 0);
  3665. builder.Write("第" + dac.Days.ToString() + "天:");
  3666. builder.MoveToCell(1, i, 1, 0);
  3667. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3668. builder.MoveToCell(1, i, 2, 0);
  3669. builder.Write("费用标准:");
  3670. string curr = "";
  3671. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3672. if (currData != null)
  3673. {
  3674. curr = currData.Name;
  3675. }
  3676. builder.MoveToCell(1, i, 3, 0);
  3677. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3678. builder.MoveToCell(1, i, 4, 0);
  3679. builder.Write("费用小计:");
  3680. builder.MoveToCell(1, i, 5, 0);
  3681. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3682. }
  3683. //删除多余行
  3684. while (table2.Rows.Count > dac2.Count)
  3685. {
  3686. table2.Rows.RemoveAt(dac2.Count);
  3687. }
  3688. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  3689. for (int i = 0; i < dac3.Count; i++)
  3690. {
  3691. Grp_DayAndCost dac = dac3[i];
  3692. if (dac == null) continue;
  3693. builder.MoveToCell(2, i, 0, 0);
  3694. builder.Write("第" + dac.Days.ToString() + "天:");
  3695. builder.MoveToCell(2, i, 1, 0);
  3696. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3697. builder.MoveToCell(2, i, 2, 0);
  3698. builder.Write("费用标准:");
  3699. string curr = "";
  3700. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  3701. if (currData != null)
  3702. {
  3703. curr = currData.Name;
  3704. }
  3705. builder.MoveToCell(2, i, 3, 0);
  3706. builder.Write(dac.Cost.ToString("#0.00") + curr);
  3707. builder.MoveToCell(2, i, 4, 0);
  3708. builder.Write("费用小计:");
  3709. builder.MoveToCell(2, i, 5, 0);
  3710. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  3711. }
  3712. //删除多余行
  3713. while (table3.Rows.Count > dac3.Count)
  3714. {
  3715. table3.Rows.RemoveAt(dac3.Count);
  3716. }
  3717. #endregion
  3718. //文件名
  3719. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  3720. AsposeHelper.removewatermark_v2180();
  3721. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3722. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3723. return Ok(JsonView(true, "成功", new { Url = url }));
  3724. }
  3725. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  3726. {
  3727. //获取模板
  3728. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  3729. //载入模板
  3730. Document doc = new Document(tempPath);
  3731. DocumentBuilder builder = new DocumentBuilder(doc);
  3732. Dictionary<string, string> dic = new Dictionary<string, string>();
  3733. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3734. {
  3735. List<string> list = new List<string>();
  3736. try
  3737. {
  3738. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3739. foreach (var item in spilitArr)
  3740. {
  3741. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3742. var depCode = spDotandEmpty[2].Substring(0, 3);
  3743. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3744. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  3745. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  3746. list.Add(depName);
  3747. list.Add(arrName);
  3748. }
  3749. list = list.Distinct().ToList();
  3750. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3751. }
  3752. catch (Exception)
  3753. {
  3754. dic.Add("ReturnCode", "行程录入不正确!");
  3755. }
  3756. }
  3757. else
  3758. {
  3759. dic.Add("ReturnCode", "未录入行程!");
  3760. }
  3761. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3762. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3763. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3764. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3765. {
  3766. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3767. dic.Add("Day", sp.Days.ToString());
  3768. }
  3769. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3770. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3771. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3772. //dic.Add("Names", Names);
  3773. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  3774. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  3775. decimal dac1totalPrice = 0.00M;
  3776. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  3777. foreach (var dac in dac1)
  3778. {
  3779. if (dac.SubTotal == 0.00M)
  3780. {
  3781. continue;
  3782. }
  3783. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  3784. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  3785. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  3786. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3787. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  3788. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3789. builder.Write(currency);//币种
  3790. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  3791. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3792. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  3793. builder.Write("");//人数
  3794. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  3795. builder.Write("");//天数
  3796. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  3797. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3798. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  3799. decimal rate = 0.00M;
  3800. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3801. builder.Write(rate.ToString("#0.0000"));//汇率
  3802. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  3803. decimal rbmPrice = dac.SubTotal;
  3804. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3805. accommodationStartIndex++;
  3806. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3807. }
  3808. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  3809. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  3810. {
  3811. table1.Rows.RemoveAt(i - 1);
  3812. foodandotherStartIndex--;
  3813. }
  3814. if (dac2.Count == dac3.Count)//国家 币种 金额
  3815. {
  3816. for (int i = 0; i < dac2.Count; i++)
  3817. {
  3818. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3819. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3820. }
  3821. }
  3822. decimal dac2totalPrice = 0.00M;
  3823. foreach (var dac in dac2)
  3824. {
  3825. if (dac.SubTotal == 0)
  3826. {
  3827. continue;
  3828. }
  3829. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  3830. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  3831. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  3832. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  3833. builder.Write(currency);//币种
  3834. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  3835. builder.Write(dac.Cost.ToString("#0.00"));//标准
  3836. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  3837. builder.Write("");//人数
  3838. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  3839. builder.Write("");//天数
  3840. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  3841. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  3842. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  3843. decimal rate = 0.00M;
  3844. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  3845. builder.Write(rate.ToString("#0.0000"));//汇率
  3846. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  3847. decimal rbmPrice = dac.SubTotal;
  3848. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  3849. foodandotherStartIndex++;
  3850. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  3851. }
  3852. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  3853. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  3854. {
  3855. table1.Rows.RemoveAt(i - 1);
  3856. }
  3857. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  3858. string otherFeeStr = "";
  3859. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  3860. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  3861. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  3862. if (otherFeeStr.Length > 0)
  3863. {
  3864. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  3865. otherFeeStr = $"({otherFeeStr})";
  3866. dic.Add("OtherFeeStr", otherFeeStr);
  3867. }
  3868. //总计
  3869. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  3870. //国际旅费
  3871. string outsideJJ = "";
  3872. string allPriceJJ = "";
  3873. if (_EnterExitCosts.SumJJC == 1)
  3874. {
  3875. outsideJJ = string.Format(@"经济舱:{0} 元/人", _EnterExitCosts.AirJJ.ToString("#0.00"));
  3876. allPriceJJ = string.Format(@"经济舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  3877. }
  3878. string outsideGW = "";
  3879. string allPriceGW = "";
  3880. if (_EnterExitCosts.SumGWC == 1)
  3881. {
  3882. outsideGW = string.Format(@"公务舱:{0} 元/人", _EnterExitCosts.AirGW.ToString("#0.00"));
  3883. allPriceGW = string.Format(@"公务舱:{0} 元/人", (allPrice + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  3884. }
  3885. if (_EnterExitCosts.SumJJC == 1 || _EnterExitCosts.SumGWC == 1)
  3886. {
  3887. string InTravelPriceStr = string.Format(@" ({0} {1})", outsideJJ, outsideGW);
  3888. dic.Add("InTravelPrice", InTravelPriceStr);
  3889. string FinalSumPriceStr = string.Format(@" ({0} {1})", allPriceJJ, allPriceGW);
  3890. dic.Add("FinalSumPrice", FinalSumPriceStr);
  3891. }
  3892. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  3893. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  3894. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  3895. foreach (var key in dic.Keys)
  3896. {
  3897. builder.MoveToBookmark(key);
  3898. builder.Write(dic[key]);
  3899. }
  3900. //模板文件名
  3901. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表.docx";
  3902. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  3903. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  3904. return Ok(JsonView(true, "成功", new { Url = url }));
  3905. }
  3906. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  3907. {
  3908. //获取模板
  3909. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  3910. //载入模板
  3911. WorkbookDesigner designer = new WorkbookDesigner();
  3912. designer.Workbook = new Workbook(tempPath);
  3913. Dictionary<string, string> dic = new Dictionary<string, string>();
  3914. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  3915. {
  3916. List<string> list = new List<string>();
  3917. try
  3918. {
  3919. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  3920. foreach (var item in spilitArr)
  3921. {
  3922. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  3923. var depCode = spDotandEmpty[2].Substring(0, 3);
  3924. var arrCode = spDotandEmpty[2].Substring(3, 3);
  3925. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  3926. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  3927. list.Add(depName);
  3928. list.Add(arrName);
  3929. }
  3930. list = list.Distinct().ToList();
  3931. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  3932. }
  3933. catch (Exception)
  3934. {
  3935. dic.Add("ReturnCode", "行程录入不正确!");
  3936. }
  3937. }
  3938. else
  3939. {
  3940. dic.Add("ReturnCode", "未录入行程!");
  3941. }
  3942. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  3943. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  3944. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  3945. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  3946. {
  3947. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  3948. dic.Add("Day", sp.Days.ToString());
  3949. }
  3950. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  3951. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  3952. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  3953. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  3954. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  3955. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  3956. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  3957. designer.SetDataSource("Name", Names);
  3958. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  3959. designer.SetDataSource("Day", dic["Day"] + "天");
  3960. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  3961. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  3962. int startIndex = 10;
  3963. const int startIndexcopy = 10;
  3964. if (dac2.Count == dac3.Count)//国家 币种 金额
  3965. {
  3966. for (int i = 0; i < dac2.Count; i++)
  3967. {
  3968. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  3969. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  3970. }
  3971. }
  3972. DataTable dtdac1 = new DataTable();
  3973. List<string> place = new List<string>();
  3974. dtdac1.Columns.AddRange(new DataColumn[] {
  3975. new DataColumn(){ ColumnName = "city"},
  3976. new DataColumn(){ ColumnName = "curr"},
  3977. new DataColumn(){ ColumnName = "criterion"},
  3978. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3979. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3980. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3981. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3982. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  3983. });
  3984. DataTable dtdac2 = new DataTable();
  3985. dtdac2.Columns.AddRange(new DataColumn[] {
  3986. new DataColumn(){ ColumnName = "city"},
  3987. new DataColumn(){ ColumnName = "curr"},
  3988. new DataColumn(){ ColumnName = "criterion"},
  3989. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  3990. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  3991. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  3992. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  3993. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  3994. });
  3995. dtdac1.TableName = "tb1";
  3996. dtdac2.TableName = "tb2";
  3997. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  3998. foreach (var item in dac1)
  3999. {
  4000. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4001. if (place.Contains(item.Place))
  4002. {
  4003. continue;
  4004. }
  4005. DataRow row = dtdac1.NewRow();
  4006. row["city"] = item.Place;
  4007. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4008. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4009. row["curr"] = currency;
  4010. row["rate"] = rate.ToString("#0.0000");
  4011. row["criterion"] = item.Cost.ToString("#0.00");
  4012. row["number"] = 1;
  4013. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4014. //row["costRMB"] = rbmPrice;
  4015. dtdac1.Rows.Add(row);
  4016. place.Add(item.Place);
  4017. }
  4018. place = new List<string>();
  4019. foreach (var item in dac2)
  4020. {
  4021. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  4022. if (place.Contains(item.Place))
  4023. {
  4024. continue;
  4025. }
  4026. DataRow row = dtdac2.NewRow();
  4027. row["city"] = item.Place;
  4028. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  4029. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4030. row["curr"] = currency;
  4031. row["rate"] = rate.ToString("#0.0000");
  4032. row["criterion"] = item.Cost.ToString("#0.00");
  4033. row["number"] = 1;
  4034. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  4035. //row["cost"] = item.SubTotal;
  4036. //row["costRMB"] = rbmPrice;
  4037. dtdac2.Rows.Add(row);
  4038. place.Add(item.Place);
  4039. //dac2totalPrice += rbmPrice;
  4040. }
  4041. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  4042. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  4043. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4044. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  4045. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  4046. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  4047. string cell4Str = $" 4.国际旅费:经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人,公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人";
  4048. string cellStr = $" 5.其他费用(";
  4049. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  4050. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  4051. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  4052. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  4053. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  4054. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  4055. if (cellStr.Length > 8)
  4056. {
  4057. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  4058. }
  4059. cellStr += ")";
  4060. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service;
  4061. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay + otherFee;
  4062. decimal pxFee = dac4.Sum(it => it.Cost);
  4063. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay;
  4064. string celllastStr1 = "";
  4065. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  4066. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  4067. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  4068. celllastStr1 += $",国际旅费 元";
  4069. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  4070. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  4071. designer.SetDataSource("cell4Str", cell4Str);
  4072. designer.SetDataSource("cellStr", cellStr);
  4073. designer.SetDataSource("cellSum", (_EnterExitCosts.Visa + _EnterExitCosts.Safe).ToString("#0.00"));
  4074. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsaideGWPay).ToString("#0.00"));
  4075. designer.SetDataSource("celllastStr", celllastStr);
  4076. Workbook wb = designer.Workbook;
  4077. var sheet = wb.Worksheets[0];
  4078. //绑定datatable数据集
  4079. designer.SetDataSource(dtdac1);
  4080. designer.SetDataSource(dtdac2);
  4081. designer.Process();
  4082. var rowStart = dtdac1.Rows.Count;
  4083. while (rowStart > 0)
  4084. {
  4085. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  4086. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4087. startIndex++;
  4088. rowStart--;
  4089. }
  4090. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  4091. startIndex += 1; //总计行
  4092. rowStart = dtdac2.Rows.Count;
  4093. while (rowStart > 0)
  4094. {
  4095. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  4096. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  4097. startIndex++;
  4098. rowStart--;
  4099. }
  4100. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  4101. wb.CalculateFormula(true);
  4102. //模板文件名
  4103. string strFileName = $"四川省商务厅出国经费财政先行审核表.xls";
  4104. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4105. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4106. return Ok(JsonView(true, "成功", new { Url = url }));
  4107. }
  4108. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  4109. {
  4110. //获取模板
  4111. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  4112. //载入模板
  4113. Document doc = new Document(tempPath);
  4114. DocumentBuilder builder = new DocumentBuilder(doc);
  4115. Dictionary<string, string> dic = new Dictionary<string, string>();
  4116. dic.Add("GroupName", _DelegationInfo.TeamName);
  4117. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4118. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  4119. string missionLeaderJob = "";//负责人job
  4120. int groupNumber = 0; //团人数
  4121. if (DeleClientList.Count > 0)
  4122. {
  4123. missionLeader = DeleClientList[0]?.Name ?? "";
  4124. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  4125. }
  4126. dic.Add("MissionLeader", missionLeader); //团负责人
  4127. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  4128. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  4129. #region MyRegion
  4130. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  4131. //{
  4132. // List<string> list = new List<string>();
  4133. // try
  4134. // {
  4135. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  4136. // foreach (var item in spilitArr)
  4137. // {
  4138. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  4139. // var depCode = spDotandEmpty[2].Substring(0, 3);
  4140. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  4141. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  4142. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  4143. // list.Add(depName);
  4144. // list.Add(arrName);
  4145. // }
  4146. // list = list.Distinct().ToList();
  4147. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  4148. // }
  4149. // catch (Exception)
  4150. // {
  4151. // dic.Add("ReturnCode", "行程录入不正确!");
  4152. // }
  4153. //}
  4154. //else
  4155. //{
  4156. // dic.Add("ReturnCode", "未录入行程!");
  4157. //}
  4158. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  4159. dic.Add("ReturnCode", string.Join("、", countrys));
  4160. #endregion
  4161. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  4162. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4163. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4164. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  4165. //{
  4166. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4167. // dic.Add("Day", sp.Days.ToString());
  4168. //}
  4169. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  4170. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  4171. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4172. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4173. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4174. //培训人员名单
  4175. int cultivateRowIndex = 7;
  4176. foreach (var item in DeleClientList)
  4177. {
  4178. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  4179. builder.Write(item.Name);
  4180. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  4181. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  4182. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  4183. string birthDay = "";
  4184. if (item.Birthday != null)
  4185. {
  4186. DateTime dt = Convert.ToDateTime(item.Birthday);
  4187. birthDay = $"{dt.Year}.{dt.Month}";
  4188. }
  4189. builder.Write(birthDay);
  4190. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  4191. builder.Write(item.Company);
  4192. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  4193. builder.Write(item.Job);
  4194. cultivateRowIndex++;
  4195. }
  4196. //删除多余行
  4197. //cultivateRowIndex -= 2;
  4198. int delRows = 10 + 7 - cultivateRowIndex;
  4199. if (delRows > 0)
  4200. {
  4201. for (int i = 0; i < delRows; i++)
  4202. {
  4203. table1.Rows.RemoveAt(cultivateRowIndex);
  4204. //cultivateRowIndex++;
  4205. }
  4206. }
  4207. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  4208. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  4209. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  4210. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  4211. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  4212. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  4213. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  4214. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  4215. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  4216. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  4217. //其他费用
  4218. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service;
  4219. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  4220. //其他费用合计
  4221. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  4222. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  4223. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  4224. //公务舱合计
  4225. //国际旅费
  4226. string outsideJJ = "";
  4227. string allPriceJJ = "";
  4228. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  4229. {
  4230. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  4231. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  4232. }
  4233. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  4234. {
  4235. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  4236. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  4237. }
  4238. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  4239. {
  4240. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  4241. dic.Add("AirFeeTotal", airFeeTotalStr);
  4242. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  4243. dic.Add("FeeTotal", feeTotalStr);
  4244. }
  4245. foreach (var key in dic.Keys)
  4246. {
  4247. builder.MoveToBookmark(key);
  4248. builder.Write(dic[key]);
  4249. }
  4250. //模板文件名
  4251. string strFileName = $"{_DelegationInfo.TeamName}成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  4252. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4253. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4254. return Ok(JsonView(true, "成功", new { Url = url }));
  4255. }
  4256. }
  4257. else if (dto.ExportType == 2) //表格
  4258. {
  4259. //利用键值对存放数据
  4260. Dictionary<string, string> dic = new Dictionary<string, string>();
  4261. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  4262. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  4263. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  4264. dic.Add("Day", sp.Days.ToString());
  4265. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  4266. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  4267. {
  4268. //获取模板
  4269. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  4270. //载入模板
  4271. Document doc = new Document(tempPath);
  4272. DocumentBuilder builder = new DocumentBuilder(doc);
  4273. dic.Add("TeamName", _DelegationInfo.TeamName);
  4274. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  4275. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  4276. string missionLeaderName = "",
  4277. missionLeaderJob = "";
  4278. if (DeleClientList.Count > 0)
  4279. {
  4280. missionLeaderName = DeleClientList[0].Name;
  4281. missionLeaderJob = DeleClientList[0].Job;
  4282. }
  4283. dic.Add("MissionLeaderName", missionLeaderName);
  4284. dic.Add("MissionLeaderJob", missionLeaderJob);
  4285. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  4286. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  4287. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4288. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4289. int rowCount = 10;//总人数行
  4290. int startRowIndex = 7; //起始行
  4291. for (int i = 0; i < DeleClientList.Count; i++)
  4292. {
  4293. builder.MoveToCell(0, startRowIndex, 0, 0);
  4294. builder.Write(DeleClientList[i].Name); //出国人员姓名
  4295. builder.MoveToCell(0, startRowIndex, 1, 0);
  4296. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4297. builder.Write(sex);//性别
  4298. builder.MoveToCell(0, startRowIndex, 2, 0);
  4299. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  4300. builder.MoveToCell(0, startRowIndex, 3, 0);
  4301. builder.Write(DeleClientList[i].Company);//工作单位
  4302. builder.MoveToCell(0, startRowIndex, 4, 0);
  4303. builder.Write(DeleClientList[i].Job);//职务及级别
  4304. builder.MoveToCell(0, startRowIndex, 5, 0);
  4305. builder.Write("");//人员属性
  4306. builder.MoveToCell(0, startRowIndex, 6, 0);
  4307. builder.Write("");//上次出国时间
  4308. startRowIndex++;
  4309. }
  4310. int nullRow = rowCount - DeleClientList.Count;//空行
  4311. for (int i = 0; i < nullRow; i++)
  4312. {
  4313. table1.Rows.Remove(table1.Rows[startRowIndex]);
  4314. }
  4315. foreach (var key in dic.Keys)
  4316. {
  4317. builder.MoveToBookmark(key);
  4318. builder.Write(dic[key]);
  4319. }
  4320. //模板文件名
  4321. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  4322. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4323. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4324. return Ok(JsonView(true, "成功", new { Url = url }));
  4325. }
  4326. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  4327. {
  4328. //获取模板
  4329. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  4330. //载入模板
  4331. Document doc = new Document(tempPath);
  4332. DocumentBuilder builder = new DocumentBuilder(doc);
  4333. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  4334. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  4335. dic.Add("Names", Names);
  4336. int accommodationRows = 12, foodandotherRows = 12;
  4337. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4338. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  4339. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4340. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  4341. int accommodationStartIndex = 6;
  4342. decimal dac1totalPrice = 0.00M;
  4343. foreach (var dac in dac1)
  4344. {
  4345. if (dac.SubTotal == 0)
  4346. {
  4347. continue;
  4348. }
  4349. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  4350. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  4351. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4352. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4353. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  4354. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4355. builder.Write(currency);//币种
  4356. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  4357. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4358. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  4359. builder.Write("");//人数
  4360. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  4361. builder.Write("");//天数
  4362. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  4363. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4364. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  4365. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4366. builder.Write(rate.ToString("#0.0000"));//汇率
  4367. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4368. decimal rbmPrice = rate * dac.SubTotal;
  4369. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4370. accommodationStartIndex++;
  4371. dac1totalPrice += rbmPrice;
  4372. }
  4373. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  4374. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  4375. builder.Write("小计");
  4376. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  4377. builder.Write(dac1totalPrice.ToString("#0.00"));
  4378. accommodationStartIndex++;
  4379. int nullRow = accommodationRows - dac1.Count;
  4380. //删除空行
  4381. //if (nullRow > 0)
  4382. //{
  4383. // int rowIndex = accommodationStartIndex;
  4384. // for (int i = 0; i < nullRow; i++)
  4385. // {
  4386. // Row row = table1.Rows[rowIndex];
  4387. // row.Remove();
  4388. // rowIndex++;
  4389. // }
  4390. //}
  4391. if (dac2.Count == dac3.Count)//国家 币种 金额
  4392. {
  4393. for (int i = 0; i < dac2.Count; i++)
  4394. {
  4395. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  4396. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  4397. }
  4398. }
  4399. int foodandotherStartIndex = 19;//
  4400. decimal dac2totalPrice = 0.00M;
  4401. foreach (var dac in dac2)
  4402. {
  4403. if (dac.SubTotal == 0)
  4404. {
  4405. continue;
  4406. }
  4407. //foodandotherStartIndex = 12;
  4408. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  4409. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  4410. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  4411. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  4412. builder.Write(currency);//币种
  4413. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  4414. builder.Write(dac.Cost.ToString("#0.00"));//标准
  4415. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  4416. builder.Write("");//人数
  4417. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  4418. builder.Write("");//天数
  4419. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  4420. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  4421. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  4422. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  4423. builder.Write(rate.ToString("#0.0000"));//汇率
  4424. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  4425. decimal rbmPrice = rate * dac.SubTotal;
  4426. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  4427. foodandotherStartIndex++;
  4428. dac2totalPrice += rbmPrice;
  4429. }
  4430. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  4431. //删除空行
  4432. if (dac2.Count < foodandotherRows)
  4433. {
  4434. //int nullRow = accommodationRows - dac2.Count;
  4435. //while (table2.Rows.Count > dac2.Count)
  4436. //{
  4437. // table2.Rows.RemoveAt(dac2.Count);
  4438. //}
  4439. }
  4440. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  4441. string otherFeeStr = "";
  4442. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  4443. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  4444. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  4445. if (otherFeeStr.Length > 0)
  4446. {
  4447. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  4448. otherFeeStr = $"({otherFeeStr})";
  4449. dic.Add("OtherFeeStr", otherFeeStr);
  4450. }
  4451. foreach (var key in dic.Keys)
  4452. {
  4453. builder.MoveToBookmark(key);
  4454. builder.Write(dic[key]);
  4455. }
  4456. //模板文件名
  4457. string strFileName = $"省级单位出(境)经费报销单.docx";
  4458. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4459. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4460. return Ok(JsonView(true, "成功", new { Url = url }));
  4461. }
  4462. }
  4463. else if (dto.ExportType == 3)
  4464. {
  4465. if (dto.SubTypeId == 1) //团组成员名单
  4466. {
  4467. if (DeleClientList.Count < 1)
  4468. {
  4469. return Ok(JsonView(false, "团组成员暂未录入!!!"));
  4470. }
  4471. //获取模板
  4472. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  4473. //载入模板
  4474. Document doc = new Document(tempPath);
  4475. DocumentBuilder builder = new DocumentBuilder(doc);
  4476. //获取word里所有表格
  4477. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4478. //获取所填表格的序数
  4479. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4480. var rowStart = tableOne.Rows[0]; //获取第1行
  4481. //循环赋值
  4482. for (int i = 0; i < DeleClientList.Count; i++)
  4483. {
  4484. builder.MoveToCell(0, i + 1, 0, 0);
  4485. builder.Write(DeleClientList[i].Name);
  4486. builder.MoveToCell(0, i + 1, 1, 0);
  4487. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  4488. builder.Write(sex);
  4489. builder.MoveToCell(0, i + 1, 2, 0);
  4490. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  4491. builder.MoveToCell(0, i + 1, 3, 0);
  4492. builder.Write(DeleClientList[i].Company);
  4493. builder.MoveToCell(0, i + 1, 4, 0);
  4494. builder.Write(DeleClientList[i].Job);
  4495. }
  4496. //删除多余行
  4497. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  4498. {
  4499. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  4500. }
  4501. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  4502. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  4503. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  4504. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  4505. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  4506. return Ok(JsonView(true, "成功", new { Url = url }));
  4507. }
  4508. }
  4509. return Ok(JsonView(false, "操作失败!"));
  4510. }
  4511. catch (Exception ex)
  4512. {
  4513. return Ok(JsonView(false, ex.Message));
  4514. }
  4515. }
  4516. /// <summary>
  4517. /// 获取三公费用标准city
  4518. /// </summary>
  4519. /// <param name="placeData"></param>
  4520. /// <param name="nationalTravelFeeId"></param>
  4521. /// <returns></returns>
  4522. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  4523. {
  4524. string _city = string.Empty;
  4525. if (placeData.Count < 1) return _city;
  4526. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  4527. if (data == null) return _city;
  4528. string country = data.Country;
  4529. string city = data.City;
  4530. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  4531. else _city = city;
  4532. return _city;
  4533. }
  4534. /// <summary>
  4535. /// 团组模块 - 出入境费用 - 明细表导出
  4536. /// </summary>
  4537. /// <returns></returns>
  4538. [HttpPost]
  4539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4540. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  4541. {
  4542. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4543. if (data.Code != 0)
  4544. {
  4545. return Ok(JsonView(false, data.Msg));
  4546. }
  4547. return Ok(JsonView(true, data.Msg, data.Data));
  4548. }
  4549. /// <summary>
  4550. /// 团组模块 - 出入境费用 - 一键清空
  4551. /// </summary>
  4552. /// <returns></returns>
  4553. [HttpPost]
  4554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4555. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  4556. {
  4557. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  4558. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  4559. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  4560. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  4561. if (_view.Code == 0)
  4562. {
  4563. return Ok(JsonView(true, "操作成功"));
  4564. }
  4565. return Ok(JsonView(false, "操作失败"));
  4566. }
  4567. /// <summary>
  4568. /// 团组模块 - 出入境费用 - 子项删除
  4569. /// </summary>
  4570. /// <returns></returns>
  4571. [HttpPost]
  4572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4573. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  4574. {
  4575. try
  4576. {
  4577. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  4578. if (data.Code != 0)
  4579. {
  4580. return Ok(JsonView(false, data.Msg));
  4581. }
  4582. return Ok(JsonView(true, "操作成功!", data.Data));
  4583. }
  4584. catch (Exception ex)
  4585. {
  4586. return Ok(JsonView(false, ex.Message));
  4587. }
  4588. }
  4589. /// <summary>
  4590. /// 团组模块 - 出入境国家费用标准 List
  4591. /// </summary>
  4592. /// <returns></returns>
  4593. [HttpPost]
  4594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4595. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  4596. {
  4597. try
  4598. {
  4599. Stopwatch sw = new Stopwatch();
  4600. sw.Start();
  4601. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  4602. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4603. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4604. Where gntf.Isdel = 0");
  4605. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  4606. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  4607. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  4608. //foreach (var item in nationalTravel)
  4609. //{
  4610. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  4611. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  4612. // if (otherData != null)
  4613. // {
  4614. // cityData.Remove(otherData);
  4615. // cityData.Add(otherData);
  4616. // }
  4617. // nationalTravelFeeData1.Add(new
  4618. // {
  4619. // Country = item.Country,
  4620. // CityData = cityData
  4621. // });
  4622. //}
  4623. sw.Stop();
  4624. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  4625. }
  4626. catch (Exception ex)
  4627. {
  4628. return Ok(JsonView(false, ex.Message));
  4629. throw;
  4630. }
  4631. }
  4632. /// <summary>
  4633. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  4634. /// </summary>
  4635. /// <returns></returns>
  4636. [HttpPost]
  4637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4638. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  4639. {
  4640. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  4641. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  4642. List<string> countryData = new List<string>();
  4643. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  4644. countryData = countryData.Distinct().ToList();
  4645. List<dynamic> dataSource = new List<dynamic>();
  4646. foreach (var item in countryData)
  4647. {
  4648. List<string> cityData1 = new List<string>();
  4649. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  4650. var countryData2 = new
  4651. {
  4652. CountryName = item,
  4653. CityData = cityData1
  4654. };
  4655. dataSource.Add(countryData2);
  4656. }
  4657. return Ok(JsonView(true, "查询成功!", dataSource));
  4658. }
  4659. /// <summary>
  4660. /// 团组模块 - 出入境国家费用标准 Page List
  4661. /// </summary>
  4662. /// <returns></returns>
  4663. [HttpPost]
  4664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4665. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  4666. {
  4667. int portId = dto.PortType;
  4668. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4669. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  4670. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  4671. string whereSql = string.Empty;
  4672. if (!string.IsNullOrEmpty(dto.Country))
  4673. {
  4674. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  4675. }
  4676. if (!string.IsNullOrEmpty(dto.City))
  4677. {
  4678. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  4679. }
  4680. string pageSql = string.Format(@"Select * From (
  4681. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  4682. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  4683. From Grp_NationalTravelFee gntf
  4684. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4685. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4686. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  4687. RefAsync<int> total = 0;
  4688. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  4689. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  4690. }
  4691. /// <summary>
  4692. /// 团组模块 - 出入境国家费用标准 根据城市查询
  4693. /// </summary>
  4694. /// <returns></returns>
  4695. [HttpPost]
  4696. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4697. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  4698. {
  4699. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  4700. int portId = dto.PortType;
  4701. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  4702. string whereSql = string.Empty;
  4703. if (!string.IsNullOrEmpty(dto.Country))
  4704. {
  4705. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  4706. }
  4707. if (!string.IsNullOrEmpty(dto.City))
  4708. {
  4709. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  4710. }
  4711. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  4712. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  4713. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  4714. From Grp_NationalTravelFee gntf
  4715. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  4716. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  4717. Where gntf.Isdel = 0 {0} ", whereSql);
  4718. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  4719. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  4720. }
  4721. /// <summary>
  4722. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  4723. /// </summary>
  4724. /// <returns></returns>
  4725. [HttpPost]
  4726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4727. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  4728. {
  4729. try
  4730. {
  4731. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  4732. if (data.Code != 0)
  4733. {
  4734. return Ok(JsonView(false, data.Msg));
  4735. }
  4736. return Ok(JsonView(true, "操作成功!", data.Data));
  4737. }
  4738. catch (Exception ex)
  4739. {
  4740. return Ok(JsonView(false, ex.Message));
  4741. }
  4742. }
  4743. /// <summary>
  4744. /// 团组模块 - 出入境国家费用标准 - Del
  4745. /// </summary>
  4746. /// <returns></returns>
  4747. [HttpPost]
  4748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4749. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  4750. {
  4751. try
  4752. {
  4753. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  4754. {
  4755. Id = dto.Id,
  4756. DeleteUserId = dto.DeleteUserId,
  4757. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  4758. IsDel = 1
  4759. };
  4760. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  4761. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  4762. .WhereColumns(it => new { it.Id })
  4763. .ExecuteCommandAsync();
  4764. if (delStatus <= 0)
  4765. {
  4766. return Ok(JsonView(false, "删除失败!"));
  4767. }
  4768. return Ok(JsonView(true, "操作成功!"));
  4769. }
  4770. catch (Exception ex)
  4771. {
  4772. return Ok(JsonView(false, ex.Message));
  4773. }
  4774. }
  4775. #endregion
  4776. #region 签证费用录入
  4777. /// <summary>
  4778. /// 根据diid查询签证费用列表
  4779. /// </summary>
  4780. /// <param name="dto"></param>
  4781. /// <returns></returns>
  4782. [HttpPost]
  4783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4784. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  4785. {
  4786. try
  4787. {
  4788. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  4789. if (groupData.Code != 0)
  4790. {
  4791. return Ok(JsonView(false, groupData.Msg));
  4792. }
  4793. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4794. }
  4795. catch (Exception ex)
  4796. {
  4797. return Ok(JsonView(false, ex.Message));
  4798. }
  4799. }
  4800. /// <summary>
  4801. /// 根据签证费用Id查询单条数据及c表数据
  4802. /// </summary>
  4803. /// <param name="dto"></param>
  4804. /// <returns></returns>
  4805. [HttpPost]
  4806. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4807. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  4808. {
  4809. try
  4810. {
  4811. Result groupData = await _visaPriceRep.PostVisaById(dto);
  4812. if (groupData.Code != 0)
  4813. {
  4814. return Ok(JsonView(false, groupData.Msg));
  4815. }
  4816. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4817. }
  4818. catch (Exception ex)
  4819. {
  4820. return Ok(JsonView(false, ex.Message));
  4821. }
  4822. }
  4823. /// <summary>
  4824. /// 签证费用删除
  4825. /// </summary>
  4826. /// <param name="dto"></param>
  4827. /// <returns></returns>
  4828. [HttpPost]
  4829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4830. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  4831. {
  4832. _sqlSugar.BeginTran();
  4833. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  4834. if (!res)
  4835. {
  4836. _sqlSugar.RollbackTran();
  4837. return Ok(JsonView(false, "删除失败"));
  4838. }
  4839. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4840. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  4841. .SetColumns(a => new Grp_CreditCardPayment()
  4842. {
  4843. IsDel = 1,
  4844. DeleteUserId = dto.DeleteUserId,
  4845. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4846. }).ExecuteCommand();
  4847. if (resSub < 1)
  4848. {
  4849. _sqlSugar.RollbackTran();
  4850. return Ok(JsonView(false, "删除失败"));
  4851. }
  4852. _sqlSugar.CommitTran();
  4853. return Ok(JsonView(true, "删除成功!"));
  4854. }
  4855. /// <summary>
  4856. /// 签证费用录入下拉框初始化
  4857. /// </summary>
  4858. /// <returns></returns>
  4859. [HttpPost]
  4860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4861. public async Task<IActionResult> VisaPriceAddSelect()
  4862. {
  4863. try
  4864. {
  4865. //支付方式
  4866. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  4867. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  4868. //币种
  4869. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  4870. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  4871. //乘客类型
  4872. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  4873. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  4874. //卡类型
  4875. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  4876. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  4877. var data = new
  4878. {
  4879. Payment = _Payment,
  4880. CurrencyList = _CurrencyList,
  4881. PassengerType = _PassengerType,
  4882. BankCard = _BankCard
  4883. };
  4884. return Ok(JsonView(true, "查询成功!", data));
  4885. }
  4886. catch (Exception ex)
  4887. {
  4888. return Ok(JsonView(false, "程序错误!"));
  4889. throw;
  4890. }
  4891. }
  4892. /// <summary>
  4893. /// 签证费用录入操作(Status:1.新增,2.修改)
  4894. /// </summary>
  4895. /// <param name="dto"></param>
  4896. /// <returns></returns>
  4897. [HttpPost]
  4898. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4899. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  4900. {
  4901. try
  4902. {
  4903. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  4904. if (groupData.Code != 0)
  4905. {
  4906. return Ok(JsonView(false, groupData.Msg));
  4907. }
  4908. #region 应用推送
  4909. try
  4910. {
  4911. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4912. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4913. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4914. }
  4915. catch (Exception ex)
  4916. {
  4917. }
  4918. #endregion
  4919. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4920. }
  4921. catch (Exception ex)
  4922. {
  4923. return Ok(JsonView(false, ex.Message));
  4924. }
  4925. }
  4926. #endregion
  4927. #region op费用录入
  4928. /// <summary>
  4929. /// 根据diid查询op费用列表
  4930. /// </summary>
  4931. /// <param name="dto"></param>
  4932. /// <returns></returns>
  4933. [HttpPost]
  4934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4935. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  4936. {
  4937. try
  4938. {
  4939. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  4940. if (groupData.Code != 0)
  4941. {
  4942. return Ok(JsonView(false, groupData.Msg));
  4943. }
  4944. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4945. }
  4946. catch (Exception ex)
  4947. {
  4948. return Ok(JsonView(false, ex.Message));
  4949. }
  4950. }
  4951. /// <summary>
  4952. /// 根据op费用Id查询单条数据及c表数据
  4953. /// </summary>
  4954. /// <param name="dto"></param>
  4955. /// <returns></returns>
  4956. [HttpPost]
  4957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4958. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  4959. {
  4960. try
  4961. {
  4962. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  4963. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  4964. var data = new
  4965. {
  4966. CarTouristGuideGround = _groupData,
  4967. CreditCardPayment = _creditCardPayment
  4968. };
  4969. return Ok(JsonView(true, "查询成功!", data));
  4970. }
  4971. catch (Exception ex)
  4972. {
  4973. return Ok(JsonView(false, "程序错误!"));
  4974. }
  4975. }
  4976. /// <summary>
  4977. /// op费用删除
  4978. /// </summary>
  4979. /// <param name="dto"></param>
  4980. /// <returns></returns>
  4981. [HttpPost]
  4982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4983. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  4984. {
  4985. try
  4986. {
  4987. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  4988. if (!res)
  4989. {
  4990. return Ok(JsonView(false, "删除失败"));
  4991. }
  4992. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  4993. {
  4994. IsDel = 1,
  4995. DeleteUserId = dto.DeleteUserId,
  4996. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4997. }).ExecuteCommandAsync();
  4998. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  4999. {
  5000. IsDel = 1,
  5001. DeleteUserId = dto.DeleteUserId,
  5002. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5003. }).ExecuteCommandAsync();
  5004. return Ok(JsonView(true, "删除成功!"));
  5005. }
  5006. catch (Exception ex)
  5007. {
  5008. return Ok(JsonView(false, "程序错误!"));
  5009. throw;
  5010. }
  5011. }
  5012. /// <summary>
  5013. /// op费用录入操作(Status:1.新增,2.修改)
  5014. /// </summary>
  5015. /// <param name="dto"></param>
  5016. /// <returns></returns>
  5017. [HttpPost]
  5018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5019. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  5020. {
  5021. try
  5022. {
  5023. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  5024. if (groupData.Code != 0)
  5025. {
  5026. return Ok(JsonView(false, groupData.Msg));
  5027. }
  5028. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5029. }
  5030. catch (Exception ex)
  5031. {
  5032. return Ok(JsonView(false, ex.Message));
  5033. }
  5034. }
  5035. /// <summary>
  5036. /// 填写费用详细页面初始化绑定
  5037. /// </summary>
  5038. /// <param name="dto"></param>
  5039. /// <returns></returns>
  5040. [HttpPost]
  5041. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5042. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  5043. {
  5044. try
  5045. {
  5046. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  5047. if (groupData.Code != 0)
  5048. {
  5049. return Ok(JsonView(false, groupData.Msg));
  5050. }
  5051. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5052. }
  5053. catch (Exception ex)
  5054. {
  5055. return Ok(JsonView(false, ex.Message));
  5056. }
  5057. }
  5058. /// <summary>
  5059. /// 根据op费用Id查询详细数据
  5060. /// </summary>
  5061. /// <param name="dto"></param>
  5062. /// <returns></returns>
  5063. [HttpPost]
  5064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5065. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  5066. {
  5067. try
  5068. {
  5069. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  5070. if (groupData.Code != 0)
  5071. {
  5072. return Ok(JsonView(false, groupData.Msg));
  5073. }
  5074. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5075. }
  5076. catch (Exception ex)
  5077. {
  5078. return Ok(JsonView(false, ex.Message));
  5079. }
  5080. }
  5081. /// <summary>
  5082. /// OP费用录入填写详情
  5083. /// </summary>
  5084. /// <param name="dto"></param>
  5085. /// <returns></returns>
  5086. [HttpPost]
  5087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5088. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  5089. {
  5090. try
  5091. {
  5092. #region 参数校验
  5093. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  5094. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  5095. if (di == null) return Ok(JsonView(false, "团组错误!"));
  5096. #endregion
  5097. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5098. if (groupData.Code != 0)
  5099. {
  5100. return Ok(JsonView(false, groupData.Msg));
  5101. }
  5102. #region 应用推送
  5103. try
  5104. {
  5105. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5106. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5107. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5108. }
  5109. catch (Exception ex)
  5110. {
  5111. }
  5112. #endregion
  5113. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5114. }
  5115. catch (Exception ex)
  5116. {
  5117. return Ok(JsonView(false, ex.Message));
  5118. }
  5119. }
  5120. /// <summary>
  5121. /// 获取三公详细所有城市
  5122. /// </summary>
  5123. /// <returns></returns>
  5124. [HttpGet]
  5125. public IActionResult OpCarCityResult()
  5126. {
  5127. var jw = JsonView(false);
  5128. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5129. {
  5130. x.Id,
  5131. x.Country,
  5132. x.City,
  5133. }).ToList();
  5134. if (data.Count > 0)
  5135. {
  5136. jw = JsonView(true, "获取成功!", data);
  5137. }
  5138. else
  5139. {
  5140. jw.Msg = "城市数据为空!";
  5141. jw.Data = new string[0];
  5142. }
  5143. return Ok(jw);
  5144. }
  5145. /// <summary>
  5146. /// 导出地接费用明细
  5147. /// </summary>
  5148. /// <param name="dto"></param>
  5149. /// <returns></returns>
  5150. [HttpPost]
  5151. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5152. {
  5153. var jw = JsonView(false);
  5154. if (dto.Diid < 1)
  5155. {
  5156. jw.Msg = "请输入正确的diid!";
  5157. return Ok(jw);
  5158. }
  5159. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5160. if (group == null)
  5161. {
  5162. jw.Msg = "未找到团组信息!";
  5163. return Ok(jw);
  5164. }
  5165. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5166. if (localGuideArr.Count == 0)
  5167. {
  5168. jw.Msg = "该团组暂无地接信息!";
  5169. return Ok(jw);
  5170. }
  5171. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5172. var overspendSoure = new Dictionary<int, int>
  5173. {
  5174. { 91, 982 }, //车
  5175. { 92 , 1059} ,//导游
  5176. { 994 , 1073}, //翻译
  5177. { 988 , 1074 }, //早餐
  5178. { 93 , 1075 }, //午餐
  5179. { 989 , 1076 }, //晚餐
  5180. };
  5181. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5182. foreach (var groupArr in localGroup)
  5183. {
  5184. var keyValue = groupArr.Key;
  5185. if (int.TryParse(keyValue, out int cityid))
  5186. {
  5187. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5188. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5189. }
  5190. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5191. foreach (var item in groupArr)
  5192. {
  5193. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5194. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5195. new Grp_CarTouristGuideGroundReservationsContentExtend
  5196. {
  5197. Count = a.Count,
  5198. CreateTime = a.CreateTime,
  5199. CreateUserId = a.CreateUserId,
  5200. CTGGRId = a.CTGGRId,
  5201. Currency = a.Currency,
  5202. DatePrice = a.DatePrice,
  5203. DeleteTime = a.DeleteTime,
  5204. DeleteUserId = a.DeleteUserId,
  5205. DiId = a.DiId,
  5206. Id = a.Id,
  5207. IsDel = a.IsDel,
  5208. Price = a.Price,
  5209. PriceContent = a.PriceContent,
  5210. Remark = a.Remark,
  5211. SId = a.SId,
  5212. SidName = b.Name,
  5213. Units = a.Units,
  5214. }
  5215. ).ToList();
  5216. if (content.Count > 0)
  5217. {
  5218. contentArr.Add(content);
  5219. }
  5220. }
  5221. //open excel
  5222. //set excel
  5223. //save excel
  5224. try
  5225. {
  5226. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5227. IWorkbook workbook;
  5228. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5229. {
  5230. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5231. }
  5232. else
  5233. {
  5234. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5235. }
  5236. ISheet sheet = workbook.GetSheetAt(0);
  5237. var rowStartIndex = 2;
  5238. var clounmCount = 10;
  5239. var initStyleRow = sheet.GetRow(2);
  5240. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5241. //var overspendArrDetail =
  5242. var existsId = new List<CarCompare>();
  5243. var lastElem = arr.Last();
  5244. var thisSid = -1;
  5245. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5246. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5247. {
  5248. Name = "未知币种!",
  5249. Remark = "未知币种!",
  5250. };
  5251. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5252. Action cloneRowFn = () =>
  5253. {
  5254. rowStartIndex++;
  5255. var cloneRow = sheet.CreateRow(rowStartIndex);
  5256. // 复制样式
  5257. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5258. {
  5259. ICell sourceCell = initStyleRow.GetCell(i);
  5260. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5261. // 确保单元格存在样式
  5262. if (sourceCell.CellStyle != null)
  5263. {
  5264. targetCell.CellStyle = sourceCell.CellStyle;
  5265. }
  5266. }
  5267. };
  5268. var mergeRow = () =>
  5269. {
  5270. for (int i = 2; i < sheet.LastRowNum; i++)
  5271. {
  5272. var row = sheet.GetRow(i);
  5273. var cellFirst = row.GetCell(0);
  5274. var thisIndex = i + 1;
  5275. while (thisIndex < sheet.LastRowNum)
  5276. {
  5277. var nextRow = sheet.GetRow(thisIndex);
  5278. var nextCellFirst = nextRow.GetCell(0);
  5279. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5280. {
  5281. thisIndex++;
  5282. }
  5283. else
  5284. {
  5285. break;
  5286. }
  5287. }
  5288. thisIndex--;
  5289. if (thisIndex != i)
  5290. {
  5291. //合并row
  5292. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5293. i, // 起始行索引(0-based)
  5294. thisIndex, // 结束行索引(0-based)
  5295. 0, // 起始列索引(0-based)
  5296. 0 // 结束列索引(0-based)
  5297. );
  5298. sheet.AddMergedRegion(cellRangeAddress);
  5299. i = thisIndex;
  5300. }
  5301. }
  5302. };
  5303. var chaoshiNumber = 0;
  5304. var totalNumber = 0.00M;
  5305. string lastStr = "";
  5306. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5307. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5308. {
  5309. b.IsAuditGM,
  5310. x.Id,
  5311. x.Area,
  5312. b.PayPercentage,
  5313. b.PayMoney,
  5314. }).ToList();
  5315. string yesPayment = "", noPayment = "";
  5316. foreach (var item in queryCarArrByCityAndDiid)
  5317. {
  5318. if (item.IsAuditGM == 1)
  5319. {
  5320. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5321. }
  5322. else
  5323. {
  5324. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5325. }
  5326. }
  5327. lastStr = yesPayment + noPayment;
  5328. foreach (var item in arr)
  5329. {
  5330. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5331. {
  5332. if (thisSid != item.SId)
  5333. {
  5334. if (thisSid == -1)
  5335. {
  5336. thisSid = item.SId;
  5337. }
  5338. else
  5339. {
  5340. //合并小计行
  5341. //创建合并区域的实例
  5342. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5343. rowStartIndex, // 起始行索引(0-based)
  5344. rowStartIndex, // 结束行索引(0-based)
  5345. 0, // 起始列索引(0-based)
  5346. 3 // 结束列索引(0-based)
  5347. );
  5348. sheet.AddMergedRegion(cellRangeAddress);
  5349. var CellStyle = workbook.CreateCellStyle();
  5350. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5351. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5352. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5353. for (int i = 0; i <= clounmCount; i++)
  5354. {
  5355. if (i > 6)
  5356. {
  5357. var CellStyle1 = workbook.CreateCellStyle();
  5358. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5359. IFont Font = workbook.CreateFont(); // 创建字体
  5360. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5361. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5362. CellStyle1.SetFont(Font);
  5363. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5364. }
  5365. else
  5366. {
  5367. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5368. }
  5369. }
  5370. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5371. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5372. //超时合计
  5373. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5374. //超时数
  5375. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5376. //超时合计费用
  5377. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5378. thisSid = item.SId;
  5379. cloneRowFn();
  5380. chaoshiNumber = 0;
  5381. totalNumber = 0;
  5382. }
  5383. }
  5384. IRow row = sheet.GetRow(rowStartIndex);
  5385. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5386. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5387. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5388. if (isOpenOverspendSoure)
  5389. {
  5390. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5391. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5392. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5393. }
  5394. for (int i = 0; i <= clounmCount; i++)
  5395. {
  5396. var cell = row.GetCell(i);
  5397. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5398. if (cell == null)
  5399. {
  5400. cell = row.CreateCell(i);
  5401. }
  5402. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5403. fontRed.CloneStyleFrom(cell.CellStyle);
  5404. IFont Font = workbook.CreateFont(); // 创建字体
  5405. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5406. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5407. fontRed.SetFont(Font);
  5408. byte[] rgb = new byte[3] { 255, 242, 204 };
  5409. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5410. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5411. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5412. if (workbook is XSSFWorkbook)
  5413. {
  5414. BackgroundColor255_242_204.FillForegroundColor = 0;
  5415. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5416. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5417. }
  5418. else
  5419. {
  5420. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5421. }
  5422. if (i == 1 || i > 6)
  5423. {
  5424. if (i > 6)
  5425. {
  5426. fontRed.FillForegroundColor = 0;
  5427. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5428. fontRed.FillPattern = FillPattern.SolidForeground;
  5429. }
  5430. cell.CellStyle = fontRed;
  5431. }
  5432. if (i > 2 && i < 7)
  5433. {
  5434. cell.CellStyle = BackgroundColor255_242_204;
  5435. }
  5436. cell.SetCellValue(setCellValue); //写入单元格
  5437. }
  5438. if (overspendSoure.ContainsKey(thisSid)) {
  5439. var overspendId = overspendSoure[thisSid];
  5440. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5441. }
  5442. cloneRowFn();
  5443. existsId.Add(new CarCompare
  5444. {
  5445. DataPrice = item.DatePrice.ObjToDate(),
  5446. Sid = item.SId
  5447. });
  5448. }
  5449. if (item.Equals(lastElem))
  5450. {
  5451. //合并小计行
  5452. //创建合并区域的实例
  5453. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5454. rowStartIndex, // 起始行索引(0-based)
  5455. rowStartIndex, // 结束行索引(0-based)
  5456. 0, // 起始列索引(0-based)
  5457. 3 // 结束列索引(0-based)
  5458. );
  5459. sheet.AddMergedRegion(cellRangeAddress);
  5460. var CellStyle = workbook.CreateCellStyle();
  5461. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5462. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5463. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5464. for (int i = 0; i <= clounmCount; i++)
  5465. {
  5466. if (i > 6)
  5467. {
  5468. var CellStyle1 = workbook.CreateCellStyle();
  5469. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5470. IFont Font = workbook.CreateFont(); // 创建字体
  5471. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5472. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5473. CellStyle1.SetFont(Font);
  5474. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5475. }
  5476. else
  5477. {
  5478. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5479. }
  5480. }
  5481. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5482. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5483. //超时合计
  5484. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5485. //超时数
  5486. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5487. //超时合计费用
  5488. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5489. cloneRowFn();
  5490. // 创建合并区域的实例
  5491. cellRangeAddress = new CellRangeAddress(
  5492. rowStartIndex, // 起始行索引(0-based)
  5493. rowStartIndex, // 结束行索引(0-based)
  5494. 0, // 起始列索引(0-based)
  5495. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5496. );
  5497. // 添加合并区域
  5498. sheet.AddMergedRegion(cellRangeAddress);
  5499. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5500. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5501. }
  5502. }
  5503. mergeRow();
  5504. // 保存修改后的Excel文件到新文件
  5505. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5506. // new FileStream(newFilePath, FileMode.CreateNew)
  5507. using (var stream = new MemoryStream())
  5508. {
  5509. workbook.Write(stream, true);
  5510. stream.Flush();
  5511. stream.Seek(0, SeekOrigin.Begin);
  5512. MemoryStream memoryStream = new MemoryStream();
  5513. stream.CopyTo(memoryStream);
  5514. memoryStream.Seek(0, SeekOrigin.Begin);
  5515. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5516. }
  5517. workbook.Close();
  5518. workbook.Dispose();
  5519. }
  5520. catch (Exception ex)
  5521. {
  5522. jw.Msg = "出现异常!" + ex.Message;
  5523. return Ok(jw);
  5524. }
  5525. }
  5526. if (Zips.Count > 0)
  5527. {
  5528. IOOperatorHelper io = new IOOperatorHelper();
  5529. var byts = io.ConvertZipStream(Zips);
  5530. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5531. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5532. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5533. }
  5534. else
  5535. {
  5536. jw.Msg = "暂无生成文件!";
  5537. }
  5538. return Ok(jw);
  5539. }
  5540. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5541. {
  5542. string outStr = string.Empty;
  5543. switch (i)
  5544. {
  5545. case 0:
  5546. outStr = arr[0].SidName;
  5547. break;
  5548. case 1:
  5549. outStr = arr[0].DataPriceStr;
  5550. break;
  5551. case 2:
  5552. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5553. break;
  5554. case 4:
  5555. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5556. break;
  5557. case 7:
  5558. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5559. {
  5560. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5561. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5562. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5563. }
  5564. break;
  5565. case 8:
  5566. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5567. {
  5568. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5569. }
  5570. break;
  5571. case 9:
  5572. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5573. {
  5574. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5575. }
  5576. break;
  5577. case 10:
  5578. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5579. {
  5580. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5581. }
  5582. break;
  5583. }
  5584. return outStr;
  5585. }
  5586. #region OP行程单
  5587. /// <summary>
  5588. /// OP行程单初始化
  5589. /// </summary>
  5590. /// <param name="dto"></param>
  5591. /// <returns></returns>
  5592. [HttpPost]
  5593. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5594. {
  5595. var jw = JsonView(false);
  5596. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5597. var group = groupList.First();
  5598. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5599. if (group == null)
  5600. {
  5601. jw.Msg = "暂无团组!";
  5602. return Ok(jw);
  5603. }
  5604. group = groupList.Find(x => x.Id == diid);
  5605. if (group == null)
  5606. {
  5607. jw.Msg = "请输入正确的团组ID!";
  5608. return Ok(jw);
  5609. }
  5610. string city = string.Empty;
  5611. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5612. if (blackCode.Count > 0)
  5613. {
  5614. var black = blackCode.First();
  5615. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5616. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5617. if (blackSp.Length > 0)
  5618. {
  5619. try
  5620. {
  5621. var cityArrCode = new List<string>(20);
  5622. foreach (var item in blackSp)
  5623. {
  5624. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5625. var IndexSelect = itemSp[2];
  5626. var cityArrCodeLength = cityArrCode.Count - 1;
  5627. var startCity = IndexSelect.Substring(0, 3);
  5628. if (cityArrCodeLength > 0)
  5629. {
  5630. var arrEndCity = cityArrCode[cityArrCodeLength];
  5631. if (arrEndCity != startCity)
  5632. {
  5633. cityArrCode.Add(startCity.ToUpper());
  5634. }
  5635. }
  5636. else
  5637. {
  5638. cityArrCode.Add(startCity.ToUpper());
  5639. }
  5640. var endCity = IndexSelect.Substring(3, 3);
  5641. cityArrCode.Add(endCity.ToUpper());
  5642. }
  5643. var cityThree = string.Empty;
  5644. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5645. cityThree = cityThree.TrimEnd(',');
  5646. if (string.IsNullOrWhiteSpace(cityThree))
  5647. {
  5648. throw new
  5649. Exception("error");
  5650. }
  5651. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5652. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5653. foreach (var item in cityArrCode)
  5654. {
  5655. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5656. if (find != null)
  5657. {
  5658. city += find.City + "/";
  5659. }
  5660. else
  5661. {
  5662. city += item + "三字码未收入/";
  5663. }
  5664. }
  5665. city = city.TrimEnd('/');
  5666. }
  5667. catch (Exception e)
  5668. {
  5669. city = "黑屏代码格式不正确!";
  5670. }
  5671. }
  5672. }
  5673. else
  5674. {
  5675. city = "未录入黑屏代码";
  5676. }
  5677. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5678. {
  5679. Date = x.Date,
  5680. Days = x.Days,
  5681. Diffgroup = x.Diffgroup,
  5682. Diid = x.Diid,
  5683. Traffic_First = x.Traffic_First,
  5684. Traffic_Second = x.Traffic_Second,
  5685. Trip = x.Trip,
  5686. WeekDay = x.WeekDay,
  5687. Id = x.Id
  5688. }).ToList();
  5689. jw.Data = new
  5690. {
  5691. groupList = groupList.Select(x => new
  5692. {
  5693. x.Id,
  5694. x.TeamName,
  5695. x.TourCode
  5696. }).ToList(),
  5697. groupInfo = new
  5698. {
  5699. group.VisitDays,
  5700. group.TourCode,
  5701. group.VisitPNumber,
  5702. group.TeamName,
  5703. city
  5704. },
  5705. OpTravelList
  5706. };
  5707. jw.Code = 200;
  5708. jw.Msg = "操作成功!";
  5709. return Ok(jw);
  5710. }
  5711. /// <summary>
  5712. /// 删除团组行程单
  5713. /// </summary>
  5714. /// <returns></returns>
  5715. [HttpPost]
  5716. public IActionResult DelTravel(DelOpTravelDto dto)
  5717. {
  5718. var jw = JsonView(false);
  5719. if (dto.UserId <= 0 || dto.Diid <= 0)
  5720. {
  5721. jw.Msg = "请输入正确的参数!";
  5722. return Ok(jw);
  5723. }
  5724. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5725. .SetColumns(x => new Grp_TravelList
  5726. {
  5727. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5728. DeleteUserId = dto.UserId,
  5729. IsDel = 1,
  5730. }).ExecuteCommand();
  5731. jw = JsonView(true);
  5732. return Ok(jw);
  5733. }
  5734. /// <summary>
  5735. /// 行程单保存
  5736. /// </summary>
  5737. /// <returns></returns>
  5738. [HttpPost]
  5739. public IActionResult TravelSave(TravelSaveDto dto)
  5740. {
  5741. var jw = JsonView(false);
  5742. if (dto.Arr.Count > 0)
  5743. {
  5744. try
  5745. {
  5746. _sqlSugar.BeginTran();
  5747. foreach (var item in dto.Arr)
  5748. {
  5749. if (item.Id == 0)
  5750. {
  5751. throw new Exception("请传入正确的Id");
  5752. }
  5753. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5754. .SetColumns(x => new Grp_TravelList
  5755. {
  5756. Trip = item.Trip
  5757. }).ExecuteCommand();
  5758. }
  5759. _sqlSugar.CommitTran();
  5760. jw = JsonView(true);
  5761. }
  5762. catch (Exception ex)
  5763. {
  5764. _sqlSugar.RollbackTran();
  5765. jw.Msg = "程序异常!" + ex.Message;
  5766. }
  5767. }
  5768. else
  5769. {
  5770. jw.Msg = "请传入正确的参数!";
  5771. }
  5772. return Ok(jw);
  5773. }
  5774. /// <summary>
  5775. /// 导出行程单
  5776. /// </summary>
  5777. /// <param name="dto"></param>
  5778. /// <returns></returns>
  5779. [HttpPost]
  5780. public IActionResult ExportTravel(InitOpTravelDto dto)
  5781. {
  5782. var jw = JsonView(false);
  5783. //数据源
  5784. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5785. int diid = 0;
  5786. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5787. if (Find == null)
  5788. {
  5789. jw.Msg = "请选择正确的团组!";
  5790. return Ok(jw);
  5791. }
  5792. else
  5793. {
  5794. diid = Find.Id;
  5795. }
  5796. DataTable dtBlack = null;
  5797. try
  5798. {
  5799. dtBlack = GetTableByBlackCode(diid);
  5800. }
  5801. catch (Exception)
  5802. {
  5803. jw.Msg = "机票黑屏代码有误!";
  5804. return Ok(jw);
  5805. }
  5806. string CityStr1 = "";
  5807. List<string> countriesList = new List<string>();
  5808. List<string> cityList = new List<string>();
  5809. string countriesIntroduction = "";
  5810. string cityIntroduction = "";
  5811. string timeDifference = "";
  5812. string currExchangeRate = "";
  5813. string txt_itemPrepare = "";
  5814. string txt_specialReminder = "";
  5815. string txt_cGPrecautions = "";
  5816. string txt_yGCG = "";
  5817. string txt_conduct = "";
  5818. string txt_commonEnglish = "";
  5819. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5820. {
  5821. //提示
  5822. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5823. }
  5824. else
  5825. {
  5826. //创建三字码示例
  5827. Res_ThreeCode t = new Res_ThreeCode();
  5828. //城市缓存
  5829. string city = "";
  5830. //出访城市
  5831. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5832. {
  5833. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5834. {
  5835. continue;
  5836. }
  5837. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5838. {
  5839. //出发城市
  5840. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5841. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5842. if (t != null)
  5843. {
  5844. city = city + "/" + t.City;
  5845. }
  5846. else
  5847. {
  5848. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5849. }
  5850. if (i == dtBlack.Rows.Count - 1)
  5851. {
  5852. //抵达城市
  5853. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5854. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5855. if (t != null)
  5856. {
  5857. city = city + "/" + t.City;
  5858. }
  5859. else
  5860. {
  5861. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5862. }
  5863. }
  5864. }
  5865. }
  5866. if (city != "" && city != null)
  5867. {
  5868. string[] cityStr2 = city.Split('/');
  5869. string[] strs = cityStr2.Distinct().ToArray(); ;
  5870. string str = "";
  5871. foreach (var s in strs)
  5872. {
  5873. str += s + "/";
  5874. }
  5875. str = str.TrimStart('/');
  5876. str = str.TrimEnd('/');
  5877. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5878. CityStr1 = city.TrimStart('/');
  5879. }
  5880. // 行程repeater
  5881. if (GetByDiid(diid).Count > 0)
  5882. {
  5883. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5884. }
  5885. else
  5886. {
  5887. //生成该时间段日期
  5888. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5889. if (timeList != null)
  5890. {
  5891. string[] str = new string[timeList.Count];
  5892. //rpData.DataSource = str;
  5893. //rpData.DataBind();
  5894. }
  5895. }
  5896. }
  5897. //创建数据源Table
  5898. DataTable dtSource = new DataTable();
  5899. dtSource.Columns.Add("Days", typeof(string));
  5900. dtSource.Columns.Add("Date", typeof(string));
  5901. dtSource.Columns.Add("Week", typeof(string));
  5902. dtSource.Columns.Add("Traffic", typeof(string));
  5903. dtSource.Columns.Add("Trip", typeof(string));
  5904. //获取数据,放到datatable
  5905. foreach (var item in _travelList)
  5906. {
  5907. DataRow dr = dtSource.NewRow();
  5908. dr["Days"] = item.Days;
  5909. dr["Date"] = item.Date;
  5910. dr["Week"] = item.WeekDay;
  5911. dr["Traffic"] = item.Traffic_First
  5912. + "\r\n"
  5913. + item.Traffic_Second;
  5914. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5915. {
  5916. item.Trip += @"
  5917. 08:00 早餐于酒店;
  5918. 09:00 公务活动;
  5919. 10:30 公务活动;
  5920. 12:00 午餐于当地餐厅;
  5921. 14:00 公务活动;
  5922. 16:00 公务活动;
  5923. 18:00 晚餐于当地餐厅;
  5924. 19:00 入住酒店休息;";
  5925. }
  5926. dr["Trip"] = item.Trip;
  5927. dtSource.Rows.Add(dr);
  5928. }
  5929. //lblTeamName.Text = di.TourCode;
  5930. //lblVisitDays.Text = di.VisitDays.ToString();
  5931. //lblVisitDays2.Text = di.VisitDays.ToString();
  5932. //lblPNumber.Text = di.VisitPNumber.ToString();
  5933. //lblGroup.Text = di.TeamName.ToString();
  5934. Dictionary<string, string> dic = new Dictionary<string, string>();
  5935. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5936. dic.Add("City", CityStr1);
  5937. dic.Add("Days", Find.VisitDays.ToString());
  5938. dic.Add("DeleCode", Find.TourCode);
  5939. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5940. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5941. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5942. if (leader != null && leader.Count > 0)
  5943. {
  5944. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5945. }
  5946. else
  5947. {
  5948. dic.Add("Leader", "");
  5949. }
  5950. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5951. int UserId = 253;
  5952. dic.Add("OP", "");
  5953. dic.Add("OPTel", "");
  5954. //dic.Add("OP", "OP姓名");
  5955. //dic.Add("OPTel", "OP手机号码");
  5956. string countriesStr = "";
  5957. countriesList.ForEach(s => countriesStr += s + "、");
  5958. countriesStr = countriesStr.TrimEnd('、');
  5959. string cityStr = "";
  5960. cityList.ForEach(s => cityStr += s + "、");
  5961. cityStr = cityStr.TrimEnd('、');
  5962. //下方数据
  5963. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5964. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5965. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5966. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5967. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5968. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5969. dic.Add("temperature", "");
  5970. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5971. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5972. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5973. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5974. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5975. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5976. //模板路径
  5977. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5978. //载入模板
  5979. Document doc = null;
  5980. DocumentBuilder builder = null;
  5981. try
  5982. {
  5983. //载入模板
  5984. doc = new Document(tempPath);
  5985. builder = new DocumentBuilder(doc);
  5986. }
  5987. catch (Exception)
  5988. {
  5989. jw.Msg = "模板位置不存在!";
  5990. return Ok(jw);
  5991. }
  5992. foreach (var key in dic.Keys)
  5993. {
  5994. Bookmark bookmark = doc.Range.Bookmarks[key];
  5995. if (bookmark != null)
  5996. {
  5997. builder.MoveToBookmark(key);
  5998. builder.Write(dic[key]);
  5999. }
  6000. }
  6001. //获取word里所有表格
  6002. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6003. //获取所填表格的序数
  6004. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6005. try
  6006. {
  6007. //循环赋值
  6008. for (int i = 0; i < dtSource.Rows.Count; i++)
  6009. {
  6010. builder.MoveToCell(0, i + 1, 0, 0);
  6011. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6012. builder.MoveToCell(0, i + 1, 1, 0);
  6013. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6014. builder.MoveToCell(0, i + 1, 2, 0);
  6015. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6016. var trip = dtSource.Rows[i]["Trip"].ToString();
  6017. builder.MoveToCell(0, i + 1, 3, 0);
  6018. builder.Write(trip);
  6019. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6020. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6021. // 获取特定索引的段落
  6022. Paragraph paragraph = (Paragraph)paragraphs[0];
  6023. Run run = paragraph.Runs[0];
  6024. Aspose.Words.Font font = run.Font;
  6025. font.Name = "黑体";
  6026. //设置双休红色
  6027. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6028. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6029. paragraph = (Paragraph)paragraphs[1];
  6030. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6031. {
  6032. run = paragraph.Runs[0];
  6033. font = run.Font;
  6034. font.Color = Color.Red;
  6035. }
  6036. }
  6037. }
  6038. catch (Exception ex)
  6039. {
  6040. }
  6041. //删除多余行
  6042. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6043. {
  6044. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6045. }
  6046. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6047. if (!Directory.Exists(savePath))
  6048. {
  6049. try
  6050. {
  6051. Directory.CreateDirectory(savePath);
  6052. }
  6053. catch
  6054. {
  6055. }
  6056. }
  6057. string path = savePath + Find.TeamName + "出访日程.docx";
  6058. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  6059. try
  6060. {
  6061. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  6062. jw = JsonView(true, "导出成功", ftpPath);
  6063. }
  6064. catch (Exception)
  6065. {
  6066. jw = JsonView(false);
  6067. }
  6068. return Ok(jw);
  6069. }
  6070. /// <summary>
  6071. ///根据机票黑屏代码整理DataTable
  6072. /// </summary>
  6073. /// <param name="diid"></param>
  6074. /// <returns></returns>
  6075. DataTable GetTableByBlackCode(int diid)
  6076. {
  6077. //黑屏代码信息
  6078. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6079. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6080. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6081. DataTable dt = new DataTable();
  6082. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6083. dt.Columns.Add("Date", typeof(string));//起飞日期
  6084. dt.Columns.Add("Three", typeof(string));//三字码
  6085. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6086. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6087. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6088. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6089. dt.Columns.Add("AirModel", typeof(string)); //机型
  6090. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6091. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6092. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6093. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6094. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6095. //判断是否录入黑屏代码
  6096. if (listcode.Count() == 0 || listcode == null)
  6097. {
  6098. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6099. }
  6100. else
  6101. {
  6102. //读取单段黑屏代码
  6103. for (int i = 0; i < listcode.Count; i++)
  6104. {
  6105. //去除序号
  6106. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6107. //去除多余空格,方法一Linq扩展方法
  6108. CodeList = CodeList.Where(str => str != "").ToArray();
  6109. CodeList = CodeList.Where(str => str != " ").ToArray();
  6110. //年
  6111. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6112. //读取单条黑屏代码
  6113. for (int j = 0; j < CodeList.Count(); j++)
  6114. {
  6115. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6116. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6117. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6118. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6119. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6120. //去除多余空格
  6121. Info = Info.Where(str => str != "").ToArray();
  6122. Info = Info.Where(str => str != " ").ToArray();
  6123. //判断黑屏代码是否正确拆分; 理应拆成9段
  6124. if (Info.Count() < 9)
  6125. {
  6126. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6127. }
  6128. else
  6129. {
  6130. try
  6131. {
  6132. //月
  6133. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6134. //日
  6135. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6136. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6137. if (j > 0)
  6138. {
  6139. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6140. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6141. Temp = Temp.Where(str => str != "").ToArray();
  6142. Temp = Temp.Where(str => str != " ").ToArray();
  6143. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6144. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6145. if (month - monthTemp < 0)
  6146. {
  6147. year = year + 1;
  6148. }
  6149. //如果相邻代码三字码不顶真,提醒
  6150. string FootThree = Temp[2].Substring(3, 3);
  6151. string HeadThree = Info[2].Substring(0, 3);
  6152. if (FootThree != HeadThree)
  6153. {
  6154. //DelegationInfoService s = new DelegationInfoService();
  6155. //UsersService us = new UsersService();
  6156. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6157. //77 行程
  6158. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6159. foreach (var temp in list2)
  6160. {
  6161. //if (temp.UId != 21)
  6162. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6163. // "黑屏代码提醒",
  6164. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6165. }
  6166. //85 机票预订
  6167. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6168. foreach (var temp in list6)
  6169. {
  6170. //if (temp.UId != 21)
  6171. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6172. // "黑屏代码提醒",
  6173. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6174. }
  6175. }
  6176. }
  6177. #endregion
  6178. #region 判断到达日期是否需要加1
  6179. if (Info[4].Contains("+"))
  6180. {
  6181. //日期+1
  6182. day = day + 1;
  6183. //判断是否进入下一月
  6184. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6185. {
  6186. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6187. month = month + 1;
  6188. //判断是否进入下一年
  6189. if (month > 12)
  6190. {
  6191. month = month - 12;
  6192. year = year + 1;
  6193. }
  6194. }
  6195. //月份整理格式
  6196. string monthTemp = month.ToString();
  6197. if (month < 10)
  6198. {
  6199. monthTemp = "0" + monthTemp;
  6200. }
  6201. //日期整理格式
  6202. string daytemp = day.ToString();
  6203. if (day < 10)
  6204. {
  6205. daytemp = "0" + daytemp;
  6206. }
  6207. string temp = Info[4].Split('+')[0];
  6208. //添加起飞数据
  6209. dt.Rows.Add(Info[0],
  6210. Info[1],
  6211. Info[2],
  6212. Info[3],
  6213. temp,
  6214. Info[5],
  6215. Info[6],
  6216. Info[7],
  6217. Info[8],
  6218. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6219. year + "-" + monthTemp + "-" + daytemp,
  6220. "",
  6221. "0");
  6222. //加1天,添加到达数据
  6223. dt.Rows.Add(Info[0],
  6224. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6225. Info[2],
  6226. Info[3],
  6227. temp,
  6228. Info[5],
  6229. Info[6],
  6230. Info[7],
  6231. Info[8],
  6232. year + "-" + monthTemp + "-" + daytemp,
  6233. year + "-" + monthTemp + "-" + daytemp,
  6234. "",
  6235. "1");
  6236. }
  6237. else
  6238. {
  6239. //月份整理格式
  6240. string monthTemp = month.ToString();
  6241. if (month < 10)
  6242. {
  6243. monthTemp = "0" + monthTemp;
  6244. }
  6245. //日期整理格式
  6246. string daytemp = day.ToString();
  6247. if (day < 10)
  6248. {
  6249. daytemp = "0" + daytemp;
  6250. }
  6251. dt.Rows.Add(Info[0],
  6252. Info[1],
  6253. Info[2],
  6254. Info[3],
  6255. Info[4],
  6256. Info[5],
  6257. Info[6],
  6258. Info[7],
  6259. Info[8],
  6260. year + "-" + monthTemp + "-" + daytemp,
  6261. year + "-" + monthTemp + "-" + daytemp,
  6262. "",
  6263. "0");
  6264. }
  6265. #endregion
  6266. }
  6267. catch (Exception ex)
  6268. {
  6269. string exstr = ex.Message.ToString();
  6270. }
  6271. }
  6272. }
  6273. //排序
  6274. dt.DefaultView.Sort = "Day asc";
  6275. dt = dt.DefaultView.ToTable();
  6276. }
  6277. }
  6278. return dt;
  6279. }
  6280. /// <summary>
  6281. /// 根据团组编号查询信息
  6282. /// </summary>
  6283. /// <returns>返回空或者对象信息</returns>
  6284. List<Grp_TravelList> GetByDiid(int Diid)
  6285. {
  6286. //调用获取单个对象的方法
  6287. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6288. }
  6289. /// <summary>
  6290. /// 20210816
  6291. /// 根据datatable生成某一时间段的日期
  6292. /// </summary>
  6293. /// <param name="dt">黑屏代码生成的datatable</param>
  6294. /// <returns></returns>
  6295. List<string> GetTimeListByDataTable(DataTable dt)
  6296. {
  6297. if (dt.Rows[0]["Day"].ToString() != "")
  6298. {
  6299. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6300. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6301. List<string> timeList = new List<string>();
  6302. while (datestart <= dateend)
  6303. {
  6304. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6305. datestart = datestart.AddDays(1);
  6306. }
  6307. return timeList;
  6308. }
  6309. return null;
  6310. }
  6311. /// <summary>
  6312. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6313. /// </summary>
  6314. /// <param name="num"></param>
  6315. /// <returns></returns>
  6316. string GetNum(string num)
  6317. {
  6318. string str = "";
  6319. switch (num)
  6320. {
  6321. case "1":
  6322. str = "一";
  6323. break;
  6324. case "2":
  6325. str = "二";
  6326. break;
  6327. case "3":
  6328. str = "三";
  6329. break;
  6330. case "4":
  6331. str = "四";
  6332. break;
  6333. case "5":
  6334. str = "五";
  6335. break;
  6336. case "6":
  6337. str = "六";
  6338. break;
  6339. case "7":
  6340. str = "七";
  6341. break;
  6342. case "8":
  6343. str = "八";
  6344. break;
  6345. case "9":
  6346. str = "九";
  6347. break;
  6348. case "10":
  6349. str = "十";
  6350. break;
  6351. case "11":
  6352. str = "十一";
  6353. break;
  6354. case "12":
  6355. str = "十二";
  6356. break;
  6357. case "一":
  6358. str = "1";
  6359. break;
  6360. case "二":
  6361. str = "2";
  6362. break;
  6363. case "三":
  6364. str = "3";
  6365. break;
  6366. case "四":
  6367. str = "4";
  6368. break;
  6369. case "五":
  6370. str = "5";
  6371. break;
  6372. case "六":
  6373. str = "6";
  6374. break;
  6375. case "七":
  6376. str = "7";
  6377. break;
  6378. case "八":
  6379. str = "8";
  6380. break;
  6381. case "九":
  6382. str = "9";
  6383. break;
  6384. case "十":
  6385. str = "10";
  6386. break;
  6387. case "十一":
  6388. str = "11";
  6389. break;
  6390. case "十二":
  6391. str = "12";
  6392. break;
  6393. }
  6394. return str;
  6395. }
  6396. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6397. {
  6398. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6399. }
  6400. /// <summary>
  6401. /// 根据星期,月份的缩写,转换成数字或者全称
  6402. /// 根据币种中文名称返回币种代码
  6403. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6404. /// 20210903贾文滔
  6405. /// </summary>
  6406. /// <param name="startDate"></param>
  6407. /// <param name="endDate"></param>
  6408. /// <returns></returns>
  6409. string GetLonger(string temp)
  6410. {
  6411. string str = "";
  6412. switch (temp.ToUpper())
  6413. {
  6414. case "美元":
  6415. str = "USD";
  6416. break;
  6417. case "日元":
  6418. str = "JPY";
  6419. break;
  6420. case "英镑":
  6421. str = "GBP";
  6422. break;
  6423. case "欧元":
  6424. str = "EUR";
  6425. break;
  6426. case "港币":
  6427. str = "HKD";
  6428. break;
  6429. case "MO":
  6430. str = "星期一";
  6431. break;
  6432. case "TU":
  6433. str = "星期二";
  6434. break;
  6435. case "WE":
  6436. str = "星期三";
  6437. break;
  6438. case "TH":
  6439. str = "星期四";
  6440. break;
  6441. case "FR":
  6442. str = "星期五";
  6443. break;
  6444. case "SA":
  6445. str = "星期六";
  6446. break;
  6447. case "SU":
  6448. str = "星期天";
  6449. break;
  6450. case "JAN":
  6451. str = "01";
  6452. break;
  6453. case "FEB":
  6454. str = "02";
  6455. break;
  6456. case "MAR":
  6457. str = "03";
  6458. break;
  6459. case "APR":
  6460. str = "04";
  6461. break;
  6462. case "MAY":
  6463. str = "05";
  6464. break;
  6465. case "JUN":
  6466. str = "06";
  6467. break;
  6468. case "JUL":
  6469. str = "07";
  6470. break;
  6471. case "AUG":
  6472. str = "08";
  6473. break;
  6474. case "SEP":
  6475. str = "09";
  6476. break;
  6477. case "OCT":
  6478. str = "10";
  6479. break;
  6480. case "NOV":
  6481. str = "11";
  6482. break;
  6483. case "DEC":
  6484. str = "12";
  6485. break;
  6486. case "MONDAY":
  6487. str = "星期一";
  6488. break;
  6489. case "TUESDAY":
  6490. str = "星期二";
  6491. break;
  6492. case "WEDNESDAY":
  6493. str = "星期三";
  6494. break;
  6495. case "THURSDAY":
  6496. str = "星期四";
  6497. break;
  6498. case "FRIDAY":
  6499. str = "星期五";
  6500. break;
  6501. case "SATURDAY":
  6502. str = "星期六";
  6503. break;
  6504. case "SUNDAY":
  6505. str = "星期日";
  6506. break;
  6507. case "01":
  6508. str = "JAN";
  6509. break;
  6510. case "02":
  6511. str = "FEB";
  6512. break;
  6513. case "03":
  6514. str = "MAR";
  6515. break;
  6516. case "04":
  6517. str = "APR";
  6518. break;
  6519. case "05":
  6520. str = "MAY";
  6521. break;
  6522. case "06":
  6523. str = "JUN";
  6524. break;
  6525. case "07":
  6526. str = "JUL";
  6527. break;
  6528. case "08":
  6529. str = "AUG";
  6530. break;
  6531. case "09":
  6532. str = "SEP";
  6533. break;
  6534. case "10":
  6535. str = "OCT";
  6536. break;
  6537. case "11":
  6538. str = "NOV";
  6539. break;
  6540. case "12":
  6541. str = "DEC";
  6542. break;
  6543. case "2":
  6544. str = "空客A";
  6545. break;
  6546. case "3":
  6547. str = "空客A";
  6548. break;
  6549. case "7":
  6550. str = "波音";
  6551. break;
  6552. }
  6553. return str;
  6554. }
  6555. /// <summary>
  6556. /// 根据月份返回天数
  6557. /// </summary>
  6558. /// <param name="temp"></param>
  6559. /// <returns></returns>
  6560. string GetDaysByMonth(string Month, int year)
  6561. {
  6562. string str = "";
  6563. //判断是否是闰年
  6564. if (DateTime.IsLeapYear(year) == false)
  6565. {
  6566. switch (Month.ToUpper())
  6567. {
  6568. case "JAN":
  6569. str = "31";
  6570. break;
  6571. case "FEB":
  6572. str = "28";
  6573. break;
  6574. case "MAR":
  6575. str = "31";
  6576. break;
  6577. case "APR":
  6578. str = "30";
  6579. break;
  6580. case "MAY":
  6581. str = "31";
  6582. break;
  6583. case "JUN":
  6584. str = "30";
  6585. break;
  6586. case "JUL":
  6587. str = "31";
  6588. break;
  6589. case "AUG":
  6590. str = "31";
  6591. break;
  6592. case "SEP":
  6593. str = "30";
  6594. break;
  6595. case "OCT":
  6596. str = "31";
  6597. break;
  6598. case "NOV":
  6599. str = "30";
  6600. break;
  6601. case "DEC":
  6602. str = "31";
  6603. break;
  6604. case "01":
  6605. str = "31";
  6606. break;
  6607. case "02":
  6608. str = "28";
  6609. break;
  6610. case "03":
  6611. str = "31";
  6612. break;
  6613. case "04":
  6614. str = "30";
  6615. break;
  6616. case "05":
  6617. str = "31";
  6618. break;
  6619. case "06":
  6620. str = "30";
  6621. break;
  6622. case "07":
  6623. str = "31";
  6624. break;
  6625. case "08":
  6626. str = "31";
  6627. break;
  6628. case "09":
  6629. str = "30";
  6630. break;
  6631. case "10":
  6632. str = "31";
  6633. break;
  6634. case "11":
  6635. str = "30";
  6636. break;
  6637. case "12":
  6638. str = "31";
  6639. break;
  6640. }
  6641. }
  6642. else
  6643. {
  6644. switch (Month.ToUpper())
  6645. {
  6646. case "JAN":
  6647. str = "31";
  6648. break;
  6649. case "FEB":
  6650. str = "29";
  6651. break;
  6652. case "MAR":
  6653. str = "31";
  6654. break;
  6655. case "APR":
  6656. str = "30";
  6657. break;
  6658. case "MAY":
  6659. str = "31";
  6660. break;
  6661. case "JUN":
  6662. str = "30";
  6663. break;
  6664. case "JUL":
  6665. str = "31";
  6666. break;
  6667. case "AUG":
  6668. str = "31";
  6669. break;
  6670. case "SEP":
  6671. str = "30";
  6672. break;
  6673. case "OCT":
  6674. str = "31";
  6675. break;
  6676. case "NOV":
  6677. str = "30";
  6678. break;
  6679. case "DEC":
  6680. str = "31";
  6681. break;
  6682. case "01":
  6683. str = "31";
  6684. break;
  6685. case "02":
  6686. str = "29";
  6687. break;
  6688. case "03":
  6689. str = "31";
  6690. break;
  6691. case "04":
  6692. str = "30";
  6693. break;
  6694. case "05":
  6695. str = "31";
  6696. break;
  6697. case "06":
  6698. str = "30";
  6699. break;
  6700. case "07":
  6701. str = "31";
  6702. break;
  6703. case "08":
  6704. str = "31";
  6705. break;
  6706. case "09":
  6707. str = "30";
  6708. break;
  6709. case "10":
  6710. str = "31";
  6711. break;
  6712. case "11":
  6713. str = "30";
  6714. break;
  6715. case "12":
  6716. str = "31";
  6717. break;
  6718. }
  6719. }
  6720. return str;
  6721. }
  6722. #endregion
  6723. #endregion
  6724. #region 团组成本
  6725. /// <summary>
  6726. /// 团组成本数据初始化
  6727. /// </summary>
  6728. /// <param name="dto"></param>
  6729. /// <returns></returns>
  6730. [HttpPost]
  6731. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6732. {
  6733. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6734. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6735. WHEN COUNT(*) >= 0 THEN 'True'
  6736. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6737. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6738. ").ToList(); //团组列表
  6739. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6740. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6741. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6742. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6743. if (groupinfoValue != null)
  6744. {
  6745. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6746. var spArr = new string[1] { countryArr };
  6747. if (countryArr.Contains("|"))
  6748. {
  6749. spArr = countryArr.Split("|");
  6750. }
  6751. else if (countryArr.Contains("、"))
  6752. {
  6753. spArr = countryArr.Split("、");
  6754. }
  6755. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6756. {
  6757. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6758. if (dbQueryCountry != null)
  6759. {
  6760. visaCountryInfoArr.Add(dbQueryCountry);
  6761. }
  6762. }
  6763. }
  6764. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6765. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6766. var create = _GroupCostRepository.
  6767. CreateGroupCostByBlackCode(dto.Diid);
  6768. if (groupCost.Count == 0 && create.Code == 0)
  6769. {
  6770. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6771. }
  6772. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6773. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6774. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6775. groupCostMap = groupCostMap.Select(x =>
  6776. {
  6777. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6778. {
  6779. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6780. }
  6781. return x;
  6782. }).ToList();
  6783. //GroupCostParameter.Add(new
  6784. // Grp_GroupCostParameter());
  6785. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6786. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6787. return Ok(JsonView(new
  6788. {
  6789. groupList,
  6790. groupInfo,
  6791. groupChecks,
  6792. groupCost = groupCostMap,
  6793. hotelNumber,
  6794. GroupCostParameter = GroupCostParameterMap,
  6795. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6796. {
  6797. x.VisaCountry,
  6798. x.VisaPrice,
  6799. x.Id,
  6800. }).ToList(),
  6801. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6802. blackCodeIsTrue = create.Code == 0 ? true : false,
  6803. hotelIsTrue = hotelIsTrue,
  6804. }));
  6805. }
  6806. /// <summary>
  6807. /// 团组成本信息保存
  6808. /// </summary>
  6809. /// <param name="dto"></param>
  6810. /// <returns></returns>
  6811. [HttpPost]
  6812. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6813. {
  6814. if (dto.Diid <= 0 || dto.Userid <= 0)
  6815. {
  6816. return Ok(JsonView(false));
  6817. }
  6818. JsonView jw = null;
  6819. bool isTrue = false;
  6820. #region 复制团组成本
  6821. //if (dto.Diid == 2581)
  6822. //{
  6823. // dto.Diid = 2599;
  6824. // dto.CheckBoxs.ForEach(x =>
  6825. // {
  6826. // x.Diid = 2599;
  6827. // });
  6828. // dto.GroupCosts.ForEach(x =>
  6829. // {
  6830. // x.Diid = 2599;
  6831. // });
  6832. // dto.CostTypeHotelNumbers.ForEach(x =>
  6833. // {
  6834. // x.Diid = 2599;
  6835. // });
  6836. // dto.GroupCostParameters.ForEach(x =>
  6837. // {
  6838. // x.DiId = 2599;
  6839. // });
  6840. //}
  6841. #endregion
  6842. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6843. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6844. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6845. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6846. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6847. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6848. try
  6849. {
  6850. _sqlSugar.BeginTran();
  6851. isTrue = await _GroupCostRepository.
  6852. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6853. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6854. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6855. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6856. _sqlSugar.CommitTran();
  6857. jw = JsonView(true, "保存成功!", isTrue);
  6858. }
  6859. catch (Exception)
  6860. {
  6861. _sqlSugar.RollbackTran();
  6862. jw = JsonView(false);
  6863. }
  6864. return Ok(jw);
  6865. }
  6866. /// <summary>
  6867. /// 司兼导数据
  6868. /// </summary>
  6869. /// <param name="dto"></param>
  6870. /// <returns></returns>
  6871. [HttpPost]
  6872. public IActionResult GetCarGuides(CarGuidesDto dto)
  6873. {
  6874. JsonView jw = null;
  6875. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6876. jw = JsonView(true, "获取成功!", Data);
  6877. return Ok(jw);
  6878. }
  6879. /// <summary>
  6880. /// 导游数据
  6881. /// </summary>
  6882. /// <param name="dto"></param>
  6883. /// <returns></returns>
  6884. [HttpPost]
  6885. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6886. {
  6887. JsonView jw = null;
  6888. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6889. // 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
  6890. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6891. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6892. jw = JsonView(true, "获取成功!", Data);
  6893. return Ok(jw);
  6894. }
  6895. /// <summary>
  6896. /// 成本车数据
  6897. /// </summary>
  6898. /// <param name="dto"></param>
  6899. /// <returns></returns>
  6900. [HttpPost]
  6901. public IActionResult GetCarInfo(CarGuidesDto dto)
  6902. {
  6903. JsonView jw = null;
  6904. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6905. jw = JsonView(true, "获取成功!", Data);
  6906. return Ok(jw);
  6907. }
  6908. /// <summary>
  6909. /// 景点数据
  6910. /// </summary>
  6911. /// <param name="dto"></param>
  6912. /// <returns></returns>
  6913. [HttpPost]
  6914. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6915. {
  6916. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6917. return Ok(JsonView(true, "获取成功!", Data));
  6918. }
  6919. /// <summary>
  6920. /// 成本通知
  6921. /// </summary>
  6922. /// <param name="dto"></param>
  6923. /// <returns></returns>
  6924. [HttpPost]
  6925. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6926. {
  6927. if (dto.Diid < 0)
  6928. {
  6929. return Ok(JsonView(false));
  6930. }
  6931. JsonView jw = null;
  6932. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6933. if (GroupCostParameter != null)
  6934. {
  6935. int IsShare = 0;
  6936. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6937. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6938. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6939. string msg = string.Empty;
  6940. if (isTrue)
  6941. {
  6942. if (IsShare == 0)
  6943. {
  6944. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6945. }
  6946. else
  6947. {
  6948. #region 企微通知对应岗位用户
  6949. try
  6950. {
  6951. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6952. }
  6953. catch (Exception ex)
  6954. {
  6955. }
  6956. #endregion
  6957. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6958. }
  6959. jw = JsonView(isTrue, msg, new { IsShare });
  6960. }
  6961. else
  6962. {
  6963. msg = "修改失败!";
  6964. jw = JsonView(isTrue, msg);
  6965. }
  6966. }
  6967. else
  6968. {
  6969. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6970. }
  6971. return Ok(jw);
  6972. }
  6973. /// <summary>
  6974. /// 导出收款账单
  6975. /// </summary>
  6976. /// <param name="dto"></param>
  6977. /// <returns></returns>
  6978. [HttpPost]
  6979. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6980. {
  6981. if (dto.Diid == 0)
  6982. {
  6983. return Ok(JsonView(false, "请传递团组id"));
  6984. }
  6985. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6986. if (deleInfo.Code != 0)
  6987. {
  6988. return Ok(JsonView(false, "团组信息查询失败!"));
  6989. }
  6990. var di = deleInfo.Data as DelegationInfoWebView;
  6991. if (di != null)
  6992. {
  6993. //文件名
  6994. string strFileName = di.TeamName + "-收款账单.doc";
  6995. //获取模板
  6996. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6997. //载入模板
  6998. Document doc = new Document(tmppath);
  6999. decimal TotalPrice = 0.00M;
  7000. string itemStr = string.Empty;
  7001. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  7002. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7003. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  7004. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7005. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7006. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7007. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7008. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7009. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7010. foreach (var cost in groupCostType)
  7011. {
  7012. var List = cost.ToList();
  7013. if (cost.Key == "A")
  7014. {
  7015. foreach (var ListItem in List)
  7016. {
  7017. if (ListItem.number > 0)
  7018. {
  7019. if (ListItem.code.Contains("TBR"))
  7020. {
  7021. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7022. }
  7023. else
  7024. {
  7025. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7026. }
  7027. TotalPrice += (ListItem.number * ListItem.price);
  7028. }
  7029. }
  7030. }
  7031. else
  7032. {
  7033. itemStr = itemStr.Insert(0, "A段\r\n");
  7034. itemStr += "B段\r\n";
  7035. foreach (var ListItem in List)
  7036. {
  7037. if (ListItem.number > 0)
  7038. {
  7039. if (ListItem.code.Contains("TBR"))
  7040. {
  7041. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7042. }
  7043. else
  7044. {
  7045. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7046. }
  7047. TotalPrice += (ListItem.number * ListItem.price);
  7048. }
  7049. }
  7050. }
  7051. }
  7052. #region 替换Word模板书签内容
  7053. Dictionary<string, string> marks = new Dictionary<string, string>();
  7054. marks.Add("To", di.ClientUnit);//付款方
  7055. marks.Add("ToTel", di.TellPhone);//付款方电话
  7056. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7057. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7058. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7059. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7060. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7061. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  7062. marks.Add("PayItemContent", itemStr);//详细信息
  7063. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7064. #endregion
  7065. ////注
  7066. //if (doc.Range.Bookmarks["Attention"] != null)
  7067. //{
  7068. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7069. // mark.Text = frList[0].Attention;
  7070. //}
  7071. foreach (var item in marks.Keys)
  7072. {
  7073. if (doc.Range.Bookmarks[item] != null)
  7074. {
  7075. Bookmark mark = doc.Range.Bookmarks[item];
  7076. mark.Text = marks[item];
  7077. }
  7078. }
  7079. byte[] bytes = null;
  7080. using (MemoryStream stream = new MemoryStream())
  7081. {
  7082. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7083. bytes = stream.ToArray();
  7084. }
  7085. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7086. return Ok(JsonView(true, "", new
  7087. {
  7088. Data = bytes,
  7089. strFileName,
  7090. }));
  7091. }
  7092. else
  7093. {
  7094. return Ok(JsonView(false, "团组信息不存在!"));
  7095. }
  7096. }
  7097. /// <summary>
  7098. /// 导出团组成本
  7099. /// </summary>
  7100. /// <param name="dto"></param>
  7101. /// <returns></returns>
  7102. [HttpPost]
  7103. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7104. {
  7105. var jw = JsonView(false);
  7106. if (dto.Diid == 0)
  7107. {
  7108. return Ok(JsonView(false, "请传递团组id"));
  7109. }
  7110. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7111. if (deleInfo.Code != 0)
  7112. {
  7113. return Ok(JsonView(false, "团组信息查询失败!"));
  7114. }
  7115. var di = deleInfo.Data as DelegationInfoWebView;
  7116. if (di == null)
  7117. {
  7118. return Ok(JsonView(false, "团组信息查询失败!"));
  7119. }
  7120. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7121. WorkbookDesigner designer = new WorkbookDesigner();
  7122. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7123. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7124. for (int i = 0; i < List_GC.Count; i++)
  7125. {
  7126. GroupCost_Excel gc = new GroupCost_Excel();
  7127. gc.Id = List_GC[i].Id;
  7128. gc.Diid = List_GC[i].Diid.ToString();
  7129. gc.DAY = List_GC[i].DAY;
  7130. string week = "";
  7131. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7132. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7133. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7134. gc.ITIN = List_GC[i].ITIN;
  7135. gc.CarType = List_GC[i].CarType;
  7136. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7137. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7138. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7139. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7140. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7141. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7142. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7143. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7144. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7145. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7146. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7147. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7148. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7149. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7150. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7151. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7152. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7153. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7154. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7155. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7156. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7157. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7158. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7159. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7160. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7161. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7162. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7163. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7164. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7165. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7166. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7167. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7168. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7169. List_GC1.Add(gc);
  7170. }
  7171. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7172. dt.TableName = "TB";
  7173. //报表标题等不用dt的值
  7174. designer.SetDataSource("TeamName", dto.title.TeamName);
  7175. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7176. designer.SetDataSource("Tax", dto.title.Tax);
  7177. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7178. designer.SetDataSource("Currency", dto.title.Currency);
  7179. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7180. designer.SetDataSource("Rate", dto.title.Rate);
  7181. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7182. var Aparams = hotels.Find(x => x.Type == "Default");
  7183. if (Aparams == null)
  7184. {
  7185. return Ok(jw);
  7186. }
  7187. //酒店数量
  7188. var txtSGRNumber = Aparams.SGR.ToString();
  7189. var txtTBRNumber = Aparams.TBR.ToString();
  7190. var txtJSESNumber = Aparams.JSES.ToString();
  7191. var txtSUITENumbe = Aparams.SUITE.ToString();
  7192. if (dto.costType == "B")
  7193. {
  7194. Aparams = hotels.Find(x => x.Type == "A");
  7195. var Bparams = hotels.Find(x => x.Type == "B");
  7196. if (Aparams == null || Bparams == null)
  7197. {
  7198. return Ok(jw);
  7199. }
  7200. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7201. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7202. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7203. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7204. }
  7205. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7206. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7207. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7208. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7209. var ws = designer.Workbook.Worksheets[0];
  7210. int Row = List_GC.Count;
  7211. int startIndex = 11;
  7212. int HideRows = 0;
  7213. List<int> hideRowsList = new List<int>();
  7214. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7215. #region A段left数据
  7216. var left = dto.leftInfo.Find(x => x.Type == "A");
  7217. if (left == null)
  7218. {
  7219. return Ok(jw);
  7220. }
  7221. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7222. if (leftBindData != null)
  7223. {
  7224. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7225. designer.SetDataSource("VisaRS", leftBindData.rs);
  7226. designer.SetDataSource("VisaXS", leftBindData.xs);
  7227. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7228. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7229. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7230. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7231. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7232. }
  7233. else
  7234. {
  7235. hideRowsList.Add(Row + startIndex + HideRows);
  7236. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7237. }
  7238. HideRows += 2;
  7239. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7240. if (leftBindData != null)
  7241. {
  7242. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7243. designer.SetDataSource("BXRS", leftBindData.rs);
  7244. designer.SetDataSource("BXXS", leftBindData.xs);
  7245. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7246. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7247. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7248. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7249. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7250. }
  7251. else
  7252. {
  7253. hideRowsList.Add(Row + startIndex + HideRows);
  7254. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7255. }
  7256. HideRows += 2;
  7257. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7258. if (leftBindData != null)
  7259. {
  7260. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7261. designer.SetDataSource("HSRS", leftBindData.rs);
  7262. designer.SetDataSource("HSXS", leftBindData.xs);
  7263. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7264. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7265. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7266. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7267. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7268. }
  7269. else
  7270. {
  7271. hideRowsList.Add(Row + startIndex + HideRows);
  7272. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7273. }
  7274. HideRows += 2;
  7275. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7276. if (leftBindData != null)
  7277. {
  7278. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7279. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7280. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7281. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7282. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7283. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7284. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7285. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7286. }
  7287. else
  7288. {
  7289. hideRowsList.Add(Row + startIndex + HideRows);
  7290. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7291. }
  7292. HideRows += 2;
  7293. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7294. if (leftBindData != null)
  7295. {
  7296. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7297. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7298. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7299. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7300. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7301. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7302. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7303. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7304. }
  7305. else
  7306. {
  7307. hideRowsList.Add(Row + startIndex + HideRows);
  7308. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7309. }
  7310. HideRows += 2;
  7311. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7312. if (leftBindData != null)
  7313. {
  7314. ////TBR
  7315. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7316. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7317. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7318. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7319. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7320. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7321. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7322. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7323. }
  7324. else
  7325. {
  7326. hideRowsList.Add(Row + startIndex + HideRows);
  7327. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7328. }
  7329. HideRows += 2;
  7330. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7331. if (leftBindData != null)
  7332. {
  7333. ////SGR
  7334. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7335. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7336. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7337. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7338. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7339. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7340. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7341. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7342. }
  7343. else
  7344. {
  7345. hideRowsList.Add(Row + startIndex + HideRows);
  7346. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7347. }
  7348. HideRows += 2;
  7349. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7350. if (leftBindData != null)
  7351. {
  7352. ////JS/ES
  7353. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7354. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7355. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7356. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7357. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7358. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7359. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7360. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7361. }
  7362. else
  7363. {
  7364. hideRowsList.Add(Row + startIndex + HideRows);
  7365. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7366. }
  7367. HideRows += 2;
  7368. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7369. if (leftBindData != null)
  7370. {
  7371. ////SUITE
  7372. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7373. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7374. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7375. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7376. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7377. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7378. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7379. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7380. }
  7381. else
  7382. {
  7383. hideRowsList.Add(Row + startIndex + HideRows);
  7384. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7385. }
  7386. HideRows += 2;
  7387. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7388. if (leftBindData != null)
  7389. {
  7390. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7391. designer.SetDataSource("DJRS", leftBindData.rs);
  7392. designer.SetDataSource("DJXS", leftBindData.xs);
  7393. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7394. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7395. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7396. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7397. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7398. }
  7399. else
  7400. {
  7401. hideRowsList.Add(Row + startIndex + HideRows);
  7402. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7403. }
  7404. HideRows += 2;
  7405. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7406. if (leftBindData != null)
  7407. {
  7408. designer.SetDataSource("HCPCB", leftBindData.cb);
  7409. designer.SetDataSource("HCPRS", leftBindData.rs);
  7410. designer.SetDataSource("HCPXS", leftBindData.xs);
  7411. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7412. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7413. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7414. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7415. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7416. }
  7417. else
  7418. {
  7419. hideRowsList.Add(Row + startIndex + HideRows);
  7420. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7421. }
  7422. HideRows += 2;
  7423. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7424. if (leftBindData != null)
  7425. {
  7426. designer.SetDataSource("CPCB", leftBindData.cb);
  7427. designer.SetDataSource("CPRS", leftBindData.rs);
  7428. designer.SetDataSource("CPXS", leftBindData.xs);
  7429. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7430. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7431. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7432. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7433. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7434. }
  7435. else
  7436. {
  7437. hideRowsList.Add(Row + startIndex + HideRows);
  7438. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7439. }
  7440. HideRows += 2;
  7441. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7442. if (leftBindData != null)
  7443. {
  7444. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7445. designer.SetDataSource("GWRS", leftBindData.rs);
  7446. designer.SetDataSource("GWXS", leftBindData.xs);
  7447. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7448. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7449. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7450. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7451. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7452. }
  7453. else
  7454. {
  7455. hideRowsList.Add(Row + startIndex + HideRows);
  7456. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7457. }
  7458. HideRows += 2;
  7459. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7460. if (leftBindData != null)
  7461. {
  7462. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7463. designer.SetDataSource("LYJRS", leftBindData.rs);
  7464. designer.SetDataSource("LYJXS", leftBindData.xs);
  7465. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7466. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7467. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7468. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7469. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7470. }
  7471. else
  7472. {
  7473. hideRowsList.Add(Row + startIndex + HideRows);
  7474. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7475. }
  7476. #endregion
  7477. #region A段Right信息
  7478. var right = dto.rightInfo.Find(x => x.Type == "A");
  7479. if (right == null)
  7480. {
  7481. return Ok(jw);
  7482. }
  7483. HideRows += 4;
  7484. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7485. if (rightBindData != null)
  7486. {
  7487. //经济舱 + 双人间 TBR
  7488. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7489. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7490. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7491. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7492. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7493. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7494. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7495. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7496. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7497. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7498. }
  7499. else
  7500. {
  7501. hideRowsList.Add(Row + startIndex + HideRows);
  7502. }
  7503. HideRows += 2;
  7504. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7505. if (rightBindData != null)
  7506. {
  7507. //经济舱 + 单人间 SGR
  7508. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7509. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7510. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7511. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7512. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7513. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7514. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7515. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7516. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7517. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7518. }
  7519. else
  7520. {
  7521. hideRowsList.Add(Row + startIndex + HideRows);
  7522. }
  7523. HideRows += 2;
  7524. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7525. if (rightBindData != null)
  7526. {
  7527. //公务舱 + 单人间 SGR
  7528. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7529. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7530. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7531. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7532. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7533. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7534. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7535. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7536. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7537. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7538. }
  7539. else
  7540. {
  7541. hideRowsList.Add(Row + startIndex + HideRows);
  7542. }
  7543. HideRows += 2;
  7544. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7545. if (rightBindData != null)
  7546. {
  7547. //公务舱 + 小套房 JSES
  7548. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7549. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7550. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7551. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7552. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7553. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7554. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7555. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7556. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7557. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7558. }
  7559. else
  7560. {
  7561. hideRowsList.Add(Row + startIndex + HideRows);
  7562. }
  7563. HideRows += 2;
  7564. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7565. if (rightBindData != null)
  7566. {
  7567. //公务舱 + 小套房 JSES
  7568. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7569. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7570. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7571. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7572. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7573. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7574. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7575. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7576. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7577. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7578. }
  7579. else
  7580. {
  7581. hideRowsList.Add(Row + startIndex + HideRows);
  7582. }
  7583. HideRows += 2;
  7584. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7585. if (rightBindData != null)
  7586. {
  7587. //经济舱 + 大套房
  7588. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7589. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7590. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7591. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7592. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7593. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7594. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7595. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7596. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7597. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7598. }
  7599. else
  7600. {
  7601. hideRowsList.Add(Row + startIndex + HideRows);
  7602. }
  7603. #endregion
  7604. #region B段标题清空
  7605. designer.SetDataSource("CostBDRCB", "");
  7606. designer.SetDataSource("CostBRS", "");
  7607. designer.SetDataSource("CostBXS", "");
  7608. designer.SetDataSource("CostBZCB", "");
  7609. designer.SetDataSource("CostBDRBJ", "");
  7610. designer.SetDataSource("CostBZBJ", "");
  7611. designer.SetDataSource("CostBDRLR", "");
  7612. designer.SetDataSource("CostBZLR", "");
  7613. designer.SetDataSource("CostBDRCBOM", "");
  7614. designer.SetDataSource("CostBRSOM", "");
  7615. designer.SetDataSource("CostBZCBOM", "");
  7616. designer.SetDataSource("CostBDRBJOM", "");
  7617. designer.SetDataSource("CostBZBJOM", "");
  7618. designer.SetDataSource("CostBDRLROM", "");
  7619. designer.SetDataSource("CostBZLROM", "");
  7620. #endregion
  7621. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7622. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7623. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7624. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7625. designer.SetDataSource("DJName", "地接(CNY)");
  7626. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7627. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7628. designer.SetDataSource("GWName", "公务(CNY)");
  7629. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7630. designer.SetDataSource("LYJName", "零用金(CNY)");
  7631. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7632. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7633. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7634. designer.SetDataSource("BXName", "保险(CNY)");
  7635. designer.SetDataSource("VisaName", "签证(CNY)");
  7636. #region B段基本数据
  7637. if (dto.costType == "B")
  7638. {
  7639. left = dto.leftInfo.Find(x => x.Type == "B");
  7640. if (left == null)
  7641. {
  7642. return Ok(jw);
  7643. }
  7644. #region B段left数据
  7645. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7646. if (leftBindData != null)
  7647. {
  7648. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7649. designer.SetDataSource("BHSRS", leftBindData.rs);
  7650. designer.SetDataSource("BHSXS", leftBindData.xs);
  7651. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7652. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7653. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7654. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7655. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7656. }
  7657. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7658. if (leftBindData != null)
  7659. {
  7660. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7661. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7662. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7663. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7664. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7665. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7666. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7667. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7668. }
  7669. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7670. if (leftBindData != null)
  7671. {
  7672. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7673. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7674. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7675. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7676. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7677. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7678. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7679. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7680. }
  7681. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7682. if (leftBindData != null)
  7683. {
  7684. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7685. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7686. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7687. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7688. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7689. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7690. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7691. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7692. }
  7693. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7694. if (leftBindData != null)
  7695. {
  7696. designer.SetDataSource("BCPCB", leftBindData.cb);
  7697. designer.SetDataSource("BCPRS", leftBindData.rs);
  7698. designer.SetDataSource("BCPXS", leftBindData.xs);
  7699. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7700. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7701. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7702. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7703. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7704. }
  7705. //TBR
  7706. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7707. if (leftBindData != null)
  7708. {
  7709. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7710. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7711. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7712. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7713. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7714. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7715. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7716. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7717. }
  7718. //SGR
  7719. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7720. if (leftBindData != null)
  7721. {
  7722. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7723. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7724. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7725. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7726. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7727. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7728. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7729. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7730. }
  7731. //JS/ES
  7732. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7733. if (leftBindData != null)
  7734. {
  7735. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7736. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7737. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7738. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7739. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7740. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7741. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7742. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7743. }
  7744. //SUITE
  7745. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7746. if (leftBindData != null)
  7747. {
  7748. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7749. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7750. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7751. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7752. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7753. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7754. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7755. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7756. }
  7757. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7758. if (leftBindData != null)
  7759. {
  7760. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7761. designer.SetDataSource("BDJRS", leftBindData.rs);
  7762. designer.SetDataSource("BDJXS", leftBindData.xs);
  7763. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7764. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7765. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7766. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7767. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7768. }
  7769. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7770. if (leftBindData != null)
  7771. {
  7772. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7773. designer.SetDataSource("BGWRS", leftBindData.rs);
  7774. designer.SetDataSource("BGWXS", leftBindData.xs);
  7775. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7776. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7777. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7778. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7779. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7780. }
  7781. #region 优化方案
  7782. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7783. //excelBind.Add("零用金", new {
  7784. //cb="",
  7785. //rs="",
  7786. //xs ="",
  7787. //zcb = "",
  7788. //});
  7789. #endregion
  7790. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7791. if (leftBindData != null)
  7792. {
  7793. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7794. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7795. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7796. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7797. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7798. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7799. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7800. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7801. }
  7802. #endregion
  7803. #region B段Right信息
  7804. right = dto.rightInfo.Find(x => x.Type == "B");
  7805. if (right == null)
  7806. {
  7807. return Ok(jw);
  7808. }
  7809. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7810. if (rightBindData != null)
  7811. {
  7812. //经济舱 + 双人间 TBR
  7813. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7814. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7815. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7816. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7817. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7818. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7819. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7820. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7821. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7822. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7823. }
  7824. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7825. if (rightBindData != null)
  7826. {
  7827. //经济舱 + 单人间 SGR
  7828. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7829. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7830. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7831. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7832. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7833. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7834. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7835. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7836. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7837. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7838. }
  7839. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7840. if (rightBindData != null)
  7841. {
  7842. //公务舱 + 单人间 SGR
  7843. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7844. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7845. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7846. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7847. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7848. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7849. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7850. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7851. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7852. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7853. }
  7854. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7855. if (rightBindData != null)
  7856. {
  7857. //公务舱 + 小套房 JSES
  7858. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7859. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7860. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7861. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7862. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7863. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7864. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7865. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7866. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7867. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7868. }
  7869. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7870. if (rightBindData != null)
  7871. {
  7872. //公务舱 + 小套房 JSES
  7873. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7874. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7875. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7876. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7877. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7878. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7879. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7880. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7881. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7882. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7883. }
  7884. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7885. if (rightBindData != null)
  7886. {
  7887. //经济舱 + 大套房
  7888. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7889. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7890. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7891. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7892. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7893. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7894. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7895. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7896. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7897. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7898. }
  7899. #endregion
  7900. #region 标题
  7901. designer.SetDataSource("CostBDRCB", "单人成本");
  7902. designer.SetDataSource("CostBRS", "人数");
  7903. designer.SetDataSource("CostBXS", "系数");
  7904. designer.SetDataSource("CostBZCB", "总成本");
  7905. designer.SetDataSource("CostBDRBJ", "单人报价");
  7906. designer.SetDataSource("CostBZBJ", "总报价");
  7907. designer.SetDataSource("CostBDRLR", "单人利润");
  7908. designer.SetDataSource("CostBZLR", "总利润");
  7909. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7910. designer.SetDataSource("CostBRSOM", "人数");
  7911. designer.SetDataSource("CostBZCBOM", "总成本");
  7912. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7913. designer.SetDataSource("CostBZBJOM", "总报价");
  7914. designer.SetDataSource("CostBDRLROM", "单人利润");
  7915. designer.SetDataSource("CostBZLROM", "总利润");
  7916. #endregion
  7917. }
  7918. #endregion
  7919. designer.SetDataSource("TzZCB2", TzZCB2);
  7920. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7921. designer.SetDataSource("TzZLR2", TzZLR2);
  7922. string[] dataSourceKeys = new string[]
  7923. {
  7924. "VF",
  7925. "TGS",
  7926. "TGOF",
  7927. "TGM",
  7928. "TGA",
  7929. "TGTF",
  7930. "TGEF",
  7931. "CFM",
  7932. "CFOF",
  7933. "B",
  7934. "L",
  7935. "D",
  7936. "TBR",
  7937. "SGR",
  7938. "JSES",
  7939. "Suite",
  7940. "TV",
  7941. "1L",
  7942. "IF",
  7943. "EF",
  7944. "BRF",
  7945. "TE",
  7946. "TGT",
  7947. "DRVT",
  7948. "PC",
  7949. "TLF",
  7950. "ECT"
  7951. };
  7952. foreach (var item in dataSourceKeys)
  7953. {
  7954. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7955. if (find != null)
  7956. {
  7957. designer.SetDataSource(item, find.text);
  7958. }
  7959. else
  7960. {
  7961. designer.SetDataSource(item, 0);
  7962. }
  7963. }
  7964. designer.SetDataSource(dt);
  7965. //根据数据源处理生成报表内容
  7966. designer.Process();
  7967. designer.Workbook.Worksheets[0].Name = "清单";
  7968. Worksheet sheet = designer.Workbook.Worksheets[0];
  7969. foreach (var Rowindex in hideRowsList)
  7970. {
  7971. ws.Cells.HideRows(Rowindex, 2);
  7972. }
  7973. byte[] bytes = null;
  7974. string strFileName = di.TeamName + "-团组-成本.xls";
  7975. using (MemoryStream stream = new MemoryStream())
  7976. {
  7977. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7978. bytes = stream.ToArray();
  7979. }
  7980. return Ok(JsonView(true, "", new
  7981. {
  7982. Data = bytes,
  7983. strFileName,
  7984. }));
  7985. }
  7986. /// <summary>
  7987. /// 导出客户报表
  7988. /// </summary>
  7989. /// <returns></returns>
  7990. [HttpPost]
  7991. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7992. {
  7993. var jw = JsonView(false);
  7994. if (dto.Diid == 0)
  7995. {
  7996. return Ok(JsonView(false, "请传递团组id"));
  7997. }
  7998. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7999. if (deleInfo.Code != 0)
  8000. {
  8001. return Ok(JsonView(false, "团组信息查询失败!"));
  8002. }
  8003. var di = deleInfo.Data as DelegationInfoWebView;
  8004. if (di == null)
  8005. {
  8006. return Ok(JsonView(false, "团组信息查询失败!"));
  8007. }
  8008. //文件名
  8009. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8010. //获取模板
  8011. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8012. //载入模板
  8013. Document doc = new Document(tmppath);
  8014. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8015. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8016. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8017. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8018. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8019. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8020. if (AParameter == null)
  8021. {
  8022. return Ok(JsonView(false, "系数不存在!"));
  8023. }
  8024. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8025. , TzAirDesc, TzZCost;
  8026. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8027. = TzAirDesc = TzZCost = string.Empty;
  8028. TzNumber = AParameter.CostTypenumber.ToString();
  8029. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8030. CarGuides1 = dto.CarGuides1;
  8031. Meal = dto.Meal;
  8032. SubsidizedMeals = dto.SubsidizedMeals;
  8033. NightRepair = dto.NightRepair;
  8034. AttractionsTickets = dto.AttractionsTickets;
  8035. MiscellaneousFees = dto.MiscellaneousFees;
  8036. ATip = dto.ATip;
  8037. TzHotelDesc = "";
  8038. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8039. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8040. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8041. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8042. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8043. TzAirDesc = "";
  8044. TzZCost = dto.TzZCost;
  8045. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8046. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8047. var index = 1;
  8048. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8049. foreach (var item in TzHotelDescArr)
  8050. {
  8051. if (AinfoArr != null)
  8052. {
  8053. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8054. if (Ainfo != null)
  8055. {
  8056. if (int.Parse(Ainfo.rs) <= 0)
  8057. {
  8058. continue;
  8059. }
  8060. var hotelText = string.Empty;
  8061. switch (item)
  8062. {
  8063. case "SGR":
  8064. hotelText = "单人间";
  8065. break;
  8066. case "JSES":
  8067. hotelText = "小套房";
  8068. break;
  8069. case "SUITE":
  8070. hotelText = "套房";
  8071. break;
  8072. case "TBR":
  8073. hotelText = "双人间";
  8074. break;
  8075. }
  8076. if (item != "TBR")
  8077. {
  8078. 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";
  8079. }
  8080. else
  8081. {
  8082. 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";
  8083. }
  8084. index++;
  8085. }
  8086. }
  8087. }
  8088. index = 1;
  8089. foreach (var item in TzAirDescArr)
  8090. {
  8091. if (AinfoArr != null)
  8092. {
  8093. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8094. if (Ainfo != null)
  8095. {
  8096. if (int.Parse(Ainfo.rs) <= 0)
  8097. {
  8098. continue;
  8099. }
  8100. 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";
  8101. index++;
  8102. }
  8103. }
  8104. }
  8105. if (dto.costType == "B")
  8106. {
  8107. if (BParameter == null)
  8108. {
  8109. return Ok(JsonView(false, "B段系数不存在!"));
  8110. }
  8111. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8112. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8113. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8114. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8115. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8116. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8117. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8118. foreach (var item in TzHotelDescArr)
  8119. {
  8120. if (AinfoArr != null)
  8121. {
  8122. TzHotelDesc += "B段信息 \r\n";
  8123. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8124. if (Ainfo != null)
  8125. {
  8126. if (int.Parse(Ainfo.rs) <= 0)
  8127. {
  8128. continue;
  8129. }
  8130. var hotelText = string.Empty;
  8131. switch (item)
  8132. {
  8133. case "SGR":
  8134. hotelText = "单人间";
  8135. break;
  8136. case "JSES":
  8137. hotelText = "小套房";
  8138. break;
  8139. case "SUITE":
  8140. hotelText = "套房";
  8141. break;
  8142. case "TBR":
  8143. hotelText = "双人间";
  8144. break;
  8145. }
  8146. if (item != "TBR")
  8147. {
  8148. 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";
  8149. }
  8150. else
  8151. {
  8152. 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";
  8153. }
  8154. index++;
  8155. }
  8156. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8157. }
  8158. }
  8159. index = 1;
  8160. foreach (var item in TzAirDescArr)
  8161. {
  8162. if (AinfoArr != null)
  8163. {
  8164. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8165. if (Ainfo != null)
  8166. {
  8167. if (int.Parse(Ainfo.rs) <= 0)
  8168. {
  8169. continue;
  8170. }
  8171. 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";
  8172. index++;
  8173. }
  8174. }
  8175. }
  8176. }
  8177. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8178. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8179. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8180. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8181. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8182. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8183. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8184. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8185. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8186. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8187. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8188. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8189. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8190. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8191. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8192. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8193. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8194. DickeyValue.Add("TzZCost", TzZCost);
  8195. foreach (var key in DickeyValue.Keys)
  8196. {
  8197. if (doc.Range.Bookmarks[key] != null)
  8198. {
  8199. Bookmark mark = doc.Range.Bookmarks[key];
  8200. mark.Text = DickeyValue[key];
  8201. }
  8202. }
  8203. byte[] bytes = null;
  8204. string strFileName = di.TeamName + "-客户报价.doc";
  8205. using (MemoryStream stream = new MemoryStream())
  8206. {
  8207. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8208. bytes = stream.ToArray();
  8209. }
  8210. return Ok(JsonView(true, "", new
  8211. {
  8212. Data = bytes,
  8213. strFileName,
  8214. }));
  8215. }
  8216. /// <summary>
  8217. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8218. /// </summary>
  8219. /// <param name="dto"></param>
  8220. /// <returns></returns>
  8221. [HttpPost]
  8222. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8223. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8224. {
  8225. try
  8226. {
  8227. #region 参数验证
  8228. if (dto.DiId < 0)
  8229. {
  8230. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8231. }
  8232. List<int> cTableIds = new List<int>() {
  8233. 76 ,//酒店预订
  8234. 77 ,//行程
  8235. 79 ,//车/导游地接
  8236. 80 ,//签证
  8237. 81 ,//邀请/公务活
  8238. 82 ,//团组客户保险
  8239. 85 ,//机票预订
  8240. 98 ,//其他款项
  8241. 285 ,//收款退还
  8242. 751 ,//酒店早餐
  8243. 1015 // 超支费用
  8244. };
  8245. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8246. {
  8247. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8248. }
  8249. #endregion
  8250. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8251. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8252. if (_GroupCostParameters.Count <= 0)
  8253. {
  8254. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8255. }
  8256. if (_GroupCostParameters[0].IsShare == 0)
  8257. {
  8258. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8259. }
  8260. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8261. //处理date为空问题
  8262. if (_GroupCosts.Count > 0)
  8263. {
  8264. for (int i = 0; i < _GroupCosts.Count; i++)
  8265. {
  8266. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8267. {
  8268. if (i > 0)
  8269. {
  8270. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8271. }
  8272. }
  8273. }
  8274. }
  8275. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8276. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8277. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8278. string currCode = "";
  8279. #region currCode 验证
  8280. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8281. if (isInt)
  8282. {
  8283. var currData = currDatas.Find(it => it.Id == intCurrency);
  8284. if (currData != null)
  8285. {
  8286. currCode = currData.Name;
  8287. }
  8288. }
  8289. else
  8290. {
  8291. currCode = _GroupCostParameters[0].Currency.Trim();
  8292. }
  8293. #endregion
  8294. //op,酒店单段模式存储
  8295. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8296. {
  8297. CurrencyCode = currCode,
  8298. Rate = _GroupCostParameters[0].Rate,
  8299. CostType = _GroupCostParameters[0].CostType,
  8300. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8301. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8302. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8303. };
  8304. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8305. if (_GroupCostParameters.Count == 2)
  8306. {
  8307. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8308. }
  8309. foreach (var item in _GroupCostParameters)
  8310. {
  8311. decimal _rate = 1;
  8312. decimal _rate1 = item.Rate;
  8313. decimal _scale = 1;
  8314. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8315. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8316. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8317. //if (userInfo != null)
  8318. //{
  8319. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8320. // {
  8321. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8322. // {
  8323. // _scale = 1.00M;
  8324. // }
  8325. // }
  8326. //}
  8327. #endregion
  8328. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8329. {
  8330. CurrencyCode = currCode,
  8331. Rate = _rate1,
  8332. CostType = item.CostType,
  8333. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8334. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8335. CostTypeNumber = item.CostTypenumber
  8336. };
  8337. if (_GroupCostParameters.Count > 1)
  8338. {
  8339. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8340. }
  8341. else
  8342. {
  8343. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8344. }
  8345. if (dto.CTable == 79)//
  8346. {
  8347. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8348. modulePromptInfo.TotalCost = item.DJCB;
  8349. }
  8350. List<string> costTypes = new List<string>() { "A", "B" };
  8351. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8352. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8353. if (_GroupCostsDuplicates.Count() == 1)
  8354. {
  8355. _GroupCostsTypeData = _GroupCosts;
  8356. }
  8357. else
  8358. {
  8359. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8360. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8361. }
  8362. /*
  8363. * 76 酒店预订
  8364. * 77 行程
  8365. * 79 车/导游地接
  8366. * 80 签证
  8367. * 81 邀请/公务活动
  8368. * 82 团组客户保险
  8369. * 85 机票预订
  8370. * 98 其他款项
  8371. * 285 收款退还
  8372. * 751 酒店早餐
  8373. * 1015 超支费用
  8374. */
  8375. switch (dto.CTable)
  8376. {
  8377. case 76: // 酒店预订
  8378. _ModuleSubPromptInfo.AddRange(
  8379. _GroupCostsTypeData.Select(it => new
  8380. {
  8381. it.DAY,
  8382. it.Date,
  8383. it.ACCON,
  8384. it.ITIN,
  8385. it.SGR,
  8386. it.TBR,
  8387. it.JS_ES,
  8388. it.Suite
  8389. })
  8390. );
  8391. break;
  8392. case 79: // 车/导游地接
  8393. _ModuleSubPromptInfo.AddRange(
  8394. _GroupCostsTypeData.Select(it => new
  8395. {
  8396. Date = it.Date, //日期
  8397. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8398. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8399. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8400. TicketFee = it.EF * _rate * _scale, //门票费
  8401. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8402. AirportTransferFee = 0.00M,
  8403. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8404. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8405. LeadersFee = it.TLF * _rate * _scale, //领队费
  8406. CarFee1 = it.CarCost * _rate * _scale,
  8407. CarType = it.CarType, //车型
  8408. SpentCash = it.PC * _rate * _scale, //零用金
  8409. })
  8410. );
  8411. break;
  8412. case 85: // 机票
  8413. List<dynamic> datas = new List<dynamic>();
  8414. datas.Add(
  8415. new
  8416. {
  8417. AirType = "经济舱",
  8418. AirNum = item.JJCRS,
  8419. AirDRCB = item.JJCCB,
  8420. AirZCB = (item.JJCRS * item.JJCCB)
  8421. }
  8422. );
  8423. datas.Add(
  8424. new
  8425. {
  8426. AirType = "公务舱",
  8427. AirNum = item.GWCRS,
  8428. AirDRCB = item.GWCCB,
  8429. AirZCB = (item.GWCRS * item.GWCCB)
  8430. }
  8431. );
  8432. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8433. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8434. modulePromptInfo.Data = new {
  8435. airFeeData = datas,
  8436. airInitData = initDatas
  8437. };
  8438. _ModulePromptInfos.Add(modulePromptInfo);
  8439. break;
  8440. default:
  8441. break;
  8442. }
  8443. }
  8444. if (dto.CTable != 85)
  8445. {
  8446. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8447. _ModulePromptInfos.Add(_ModulePromptInfo);
  8448. }
  8449. _view.ModulePromptInfos = _ModulePromptInfos;
  8450. return Ok(JsonView(true, "操作成功!", _view));
  8451. }
  8452. catch (Exception ex)
  8453. {
  8454. return Ok(JsonView(false, ex.Message));
  8455. }
  8456. }
  8457. /// <summary>
  8458. /// 根据黑屏代码重新生成行程
  8459. /// </summary>
  8460. /// <param name="dto"></param>
  8461. /// <returns></returns>
  8462. [HttpPost]
  8463. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8464. {
  8465. var jw = JsonView(false);
  8466. var Create = _GroupCostRepository.
  8467. CreateGroupCostByBlackCode(dto.Diid);
  8468. jw.Msg = Create.Msg;
  8469. if (Create.Code == 0)
  8470. {
  8471. jw.Code = 200;
  8472. jw.Data = new
  8473. {
  8474. groupCost = Create.Data,
  8475. blackCodeIsTrue = true
  8476. };
  8477. }
  8478. else
  8479. {
  8480. jw.Code = 400;
  8481. jw.Data = new
  8482. {
  8483. groupCost = Create.Data,
  8484. blackCodeIsTrue = false,
  8485. };
  8486. }
  8487. return Ok(jw);
  8488. }
  8489. /// <summary>
  8490. /// 成本获取OP历史车费用
  8491. /// </summary>
  8492. /// <param name="dto"></param>
  8493. /// <returns></returns>
  8494. [HttpPost]
  8495. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8496. {
  8497. var jw = JsonView(false);
  8498. try
  8499. {
  8500. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8501. //获取现有所有车的数据
  8502. if (!dto.Param.IsNullOrWhiteSpace())
  8503. {
  8504. string sql = $@"
  8505. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8506. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8507. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8508. 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
  8509. AND gctggr.ServiceEndTime is not NULL
  8510. ORDER by gctggrc.id DESC
  8511. ";
  8512. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8513. var numeberResult = await Task.Run(() =>
  8514. {
  8515. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8516. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8517. return numberArr;
  8518. });
  8519. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8520. foreach (var item in numeberResult)
  8521. {
  8522. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8523. {
  8524. Country = "数据异常!",
  8525. City = string.Empty,
  8526. };
  8527. item.Area = find.Country + " " + find.City;
  8528. }
  8529. dbResult.AddRange(numeberResult);
  8530. if (dto.Param.Contains("、"))
  8531. {
  8532. var sp = dto.Param.Split("、");
  8533. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8534. .Where(x =>
  8535. {
  8536. return System.Array.Exists(sp, e =>
  8537. {
  8538. bool where = false;
  8539. if (x.Area != null)
  8540. {
  8541. where = x.Area.Contains(e);
  8542. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8543. {
  8544. return false;
  8545. }
  8546. }
  8547. if (x.PriceName != null && !where)
  8548. {
  8549. where = x.PriceName.Contains(e);
  8550. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8551. {
  8552. return false;
  8553. }
  8554. }
  8555. return where;
  8556. });
  8557. }).ToList();
  8558. }
  8559. else
  8560. {
  8561. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8562. .Where(x =>
  8563. {
  8564. bool where = false;
  8565. if (x.Area != null)
  8566. {
  8567. where = x.Area.Contains(dto.Param);
  8568. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8569. {
  8570. return false;
  8571. }
  8572. }
  8573. if (x.PriceName != null && !where)
  8574. {
  8575. where = x.PriceName.Contains(dto.Param);
  8576. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8577. {
  8578. return false;
  8579. }
  8580. }
  8581. return where;
  8582. }
  8583. )
  8584. .ToList();
  8585. }
  8586. }
  8587. var view = dbResult.Select(x => {
  8588. decimal dp = 0.00M;
  8589. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8590. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8591. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8592. {
  8593. if (startB && endB)
  8594. {
  8595. var timesp = endD.Subtract(startD);
  8596. if ((timesp.Days + 1) != 0)
  8597. {
  8598. dp = x.Price / (timesp.Days + 1);
  8599. }
  8600. }
  8601. }
  8602. else
  8603. {
  8604. dp = x.Price;
  8605. }
  8606. return new
  8607. {
  8608. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8609. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8610. x.Area,
  8611. x.id,
  8612. price = x.Price.ToString("F2"),
  8613. x.PriceName,
  8614. x.PriceContent,
  8615. x.TeamName,
  8616. x.DatePrice,
  8617. dayPrice = dp.ToString("F2"),
  8618. };
  8619. }).OrderByDescending(x => x.id).ToList();
  8620. jw = JsonView(true, "获取成功!", view);
  8621. }
  8622. catch (Exception e)
  8623. {
  8624. jw = JsonView(false, e.Message);
  8625. }
  8626. return Ok(jw);
  8627. }
  8628. #endregion
  8629. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8630. /// <summary>
  8631. /// 酒店预订
  8632. /// 酒店费用列表 根据团组Id查询
  8633. /// </summary>
  8634. /// <param name="_dto"></param>
  8635. /// <returns></returns>
  8636. [HttpPost]
  8637. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8638. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8639. {
  8640. #region 参数验证
  8641. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8642. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8643. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8644. #region 团组操作权限验证 76 酒店预定模块
  8645. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8646. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8647. #endregion
  8648. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8649. #region 页面操作权限验证
  8650. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8651. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8652. #endregion
  8653. #endregion
  8654. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8655. }
  8656. /// <summary>
  8657. /// 酒店预订
  8658. /// 基础数据
  8659. /// </summary>
  8660. /// <param name="_dto"></param>
  8661. /// <returns></returns>
  8662. [HttpPost]
  8663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8664. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8665. {
  8666. #region 参数验证
  8667. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8668. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8669. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8670. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8671. #region 页面操作权限验证
  8672. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8673. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8674. #endregion
  8675. #region 团组操作权限验证 76 酒店预定模块
  8676. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8677. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8678. #endregion
  8679. #endregion
  8680. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8681. }
  8682. /// <summary>
  8683. /// 酒店预订
  8684. /// 创建 入住卷号码
  8685. /// </summary>
  8686. /// <param name="_dto"></param>
  8687. /// <returns></returns>
  8688. [HttpPost]
  8689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8690. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8691. {
  8692. try
  8693. {
  8694. #region 参数验证
  8695. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8696. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8697. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8699. #region 页面操作权限验证
  8700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8701. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8702. #endregion
  8703. #region 团组操作权限验证 76 酒店预定模块
  8704. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8705. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8706. #endregion
  8707. #endregion
  8708. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8709. if (data.Code != 0)
  8710. {
  8711. return Ok(JsonView(false, data.Msg));
  8712. }
  8713. return Ok(JsonView(true, data.Msg, data.Data));
  8714. }
  8715. catch (Exception ex)
  8716. {
  8717. return Ok(JsonView(false, ex.Message));
  8718. }
  8719. }
  8720. /// <summary>
  8721. /// 酒店预订
  8722. /// 详情
  8723. /// </summary>
  8724. /// <param name="_dto"></param>
  8725. /// <returns></returns>
  8726. [HttpPost]
  8727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8728. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8729. {
  8730. #region 参数验证
  8731. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8732. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8733. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8734. #region 团组操作权限验证 76 酒店预定模块
  8735. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8736. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8737. #endregion
  8738. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8739. #region 页面操作权限验证
  8740. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8741. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8742. #endregion
  8743. #endregion
  8744. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8745. }
  8746. /// <summary>
  8747. /// 酒店预订
  8748. /// Add Or Edit
  8749. /// </summary>
  8750. /// <param name="_dto"></param>
  8751. /// <returns></returns>
  8752. [HttpPost]
  8753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8754. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8755. {
  8756. #region 参数验证
  8757. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8758. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8759. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8760. #region 团组操作权限验证 76 酒店预定模块
  8761. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8762. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8763. #endregion
  8764. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8765. #region 页面操作权限验证
  8766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8767. if (_dto.Id == 0) // Add
  8768. {
  8769. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8770. }
  8771. else if (_dto.Id > 1) // Edit
  8772. {
  8773. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8774. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8775. #endregion
  8776. #endregion
  8777. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8778. if (_view.Code != 200)
  8779. {
  8780. return Ok(_view);
  8781. }
  8782. #region 应用推送
  8783. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8784. //try
  8785. //{
  8786. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8787. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8788. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8789. //}
  8790. //catch (Exception ex)
  8791. //{
  8792. //}
  8793. #endregion
  8794. return Ok(_view);
  8795. }
  8796. /// <summary>
  8797. /// 酒店预订
  8798. /// Del
  8799. /// </summary>
  8800. /// <param name="_dto"></param>
  8801. /// <returns></returns>
  8802. [HttpPost]
  8803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8804. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8805. {
  8806. #region 参数验证
  8807. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8808. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8809. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8810. #region 团组操作权限验证 76 酒店预定模块
  8811. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8812. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8813. #endregion
  8814. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8815. #region 页面操作权限验证
  8816. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8817. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8818. #endregion
  8819. #endregion
  8820. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8821. }
  8822. /// <summary>
  8823. /// 酒店预订
  8824. /// 生成VOUCHER
  8825. /// 2024.05.06 之前版本
  8826. /// </summary>
  8827. /// <param name="_dto"></param>
  8828. /// <returns></returns>
  8829. [HttpPost]
  8830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8831. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8832. {
  8833. try
  8834. {
  8835. #region 参数验证
  8836. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8837. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8838. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8839. #region 团组操作权限验证 76 酒店预定模块
  8840. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8841. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8842. #endregion
  8843. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8844. #region 页面操作权限验证
  8845. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8846. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8847. #endregion
  8848. #endregion
  8849. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8850. //判断数据是否完整
  8851. if (hr != null)
  8852. {
  8853. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8854. {
  8855. string strFileName = "HotelStatement/";
  8856. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8857. if (dele != null)
  8858. strFileName += dele.TourCode;
  8859. //载入模板
  8860. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8861. Document doc = new Document(sss);
  8862. DocumentBuilder builder = new DocumentBuilder(doc);
  8863. #region 替换Word模板书签内容
  8864. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8865. //入住卷预定号码
  8866. if (doc.Range.Bookmarks["VNO"] != null)
  8867. {
  8868. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8869. mark.Text = hr.CheckNumber;
  8870. }
  8871. //酒店时间
  8872. if (doc.Range.Bookmarks["Date"] != null)
  8873. {
  8874. Bookmark mark = doc.Range.Bookmarks["Date"];
  8875. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8876. }
  8877. //团号
  8878. if (doc.Range.Bookmarks["TNo"] != null)
  8879. {
  8880. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8881. mark.Text = dele.TourCode;
  8882. }
  8883. //预定号码
  8884. if (doc.Range.Bookmarks["BookingId"] != null)
  8885. {
  8886. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8887. mark.Text = hr.ReservationsNo;
  8888. }
  8889. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8890. {
  8891. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8892. mark.Text = hr.DetermineNo;
  8893. }
  8894. //酒店城市
  8895. if (doc.Range.Bookmarks["City"] != null)
  8896. {
  8897. Bookmark mark = doc.Range.Bookmarks["City"];
  8898. mark.Text = hr.City;
  8899. }
  8900. //酒店名称
  8901. if (doc.Range.Bookmarks["HName"] != null)
  8902. {
  8903. Bookmark mark = doc.Range.Bookmarks["HName"];
  8904. mark.Text = hr.HotelName;
  8905. }
  8906. //酒店地址
  8907. if (doc.Range.Bookmarks["Address"] != null)
  8908. {
  8909. Bookmark mark = doc.Range.Bookmarks["Address"];
  8910. mark.Text = hr.HotelAddress;
  8911. }
  8912. //酒店电话
  8913. if (doc.Range.Bookmarks["Tel"] != null)
  8914. {
  8915. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8916. mark.Text = hr.HotelTel;
  8917. }
  8918. //酒店传真
  8919. if (doc.Range.Bookmarks["Fax"] != null)
  8920. {
  8921. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8922. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8923. {
  8924. mark.Text = hr.HotelFax;
  8925. }
  8926. }
  8927. //入住时间
  8928. if (doc.Range.Bookmarks["CIn"] != null)
  8929. {
  8930. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8931. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8932. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8933. }
  8934. //退房时间
  8935. if (doc.Range.Bookmarks["COut"] != null)
  8936. {
  8937. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8938. Bookmark mark = doc.Range.Bookmarks["COut"];
  8939. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8940. }
  8941. //客户名称
  8942. if (doc.Range.Bookmarks["GName"] != null)
  8943. {
  8944. string guestName = "";
  8945. string[] clients = new string[] { };
  8946. if (hr.GuestName.Contains(","))
  8947. {
  8948. clients = hr.GuestName.Split(",");
  8949. }
  8950. else
  8951. {
  8952. clients = new string[] { hr.GuestName };
  8953. }
  8954. List<int> clientIds_int = new List<int>();
  8955. if (clients.Length > 0)
  8956. {
  8957. foreach (var item in clients)
  8958. {
  8959. if (item.IsNumeric())
  8960. {
  8961. clientIds_int.Add(int.Parse(item));
  8962. }
  8963. }
  8964. }
  8965. if (clientIds_int.Count > 0)
  8966. {
  8967. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8968. foreach (var client in _clientDatas)
  8969. {
  8970. //男
  8971. if (client.Sex == 0) guestName += $"Mr.";
  8972. //女
  8973. else if (client.Sex == 1) guestName += $"Ms.";
  8974. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8975. {
  8976. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8977. }
  8978. //guestName += $"{client.Pinyin},";
  8979. }
  8980. if (guestName.Length > 0)
  8981. {
  8982. guestName = guestName.Substring(0, guestName.Length - 1);
  8983. }
  8984. }
  8985. else
  8986. {
  8987. guestName = hr.GuestName;
  8988. }
  8989. Bookmark mark = doc.Range.Bookmarks["GName"];
  8990. mark.Text = guestName;
  8991. }
  8992. //房间介绍
  8993. if (doc.Range.Bookmarks["ROOM"] != null)
  8994. {
  8995. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8996. mark.Text = hr.RoomExplanation;
  8997. }
  8998. //报价描述
  8999. if (doc.Range.Bookmarks["NOTE"] != null)
  9000. {
  9001. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  9002. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  9003. if (ss != null)
  9004. mark.Text = ss.Name;
  9005. }
  9006. //入住时间
  9007. if (doc.Range.Bookmarks["CheckIn"] != null)
  9008. {
  9009. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9010. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9011. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9012. }
  9013. //退房时间
  9014. if (doc.Range.Bookmarks["CheckOut"] != null)
  9015. {
  9016. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9017. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9018. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9019. }
  9020. //日期
  9021. if (doc.Range.Bookmarks["DT"] != null)
  9022. {
  9023. Bookmark mark = doc.Range.Bookmarks["DT"];
  9024. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9025. }
  9026. //名称
  9027. if (doc.Range.Bookmarks["VName"] != null)
  9028. {
  9029. Bookmark mark = doc.Range.Bookmarks["VName"];
  9030. mark.Text = hr.HotelName;
  9031. }
  9032. //号码
  9033. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9034. {
  9035. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9036. mark.Text = hr.CheckNumber;
  9037. }
  9038. #endregion
  9039. strFileName += "VOUCHER.doc";
  9040. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9041. doc.Save(fileDir);
  9042. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9043. return Ok(JsonView(true, "操作成功!", Url));
  9044. }
  9045. else
  9046. {
  9047. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9048. }
  9049. }
  9050. else
  9051. {
  9052. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9053. }
  9054. }
  9055. catch (Exception ex)
  9056. {
  9057. return Ok(JsonView(false, ex.Message));
  9058. }
  9059. }
  9060. /// <summary>
  9061. /// 酒店预订
  9062. /// 生成VOUCHER
  9063. /// 2024.05.06 之后版本
  9064. /// </summary>
  9065. /// <param name="_dto"></param>
  9066. /// <returns></returns>
  9067. [HttpPost]
  9068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9069. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9070. {
  9071. #region 参数验证
  9072. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9073. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9074. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9075. #region 团组操作权限验证 76 酒店预定模块
  9076. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9077. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9078. #endregion
  9079. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9080. #region 页面操作权限验证
  9081. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9082. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9083. #endregion
  9084. #endregion
  9085. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9086. //判断数据是否完整
  9087. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9088. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9089. string strFileName = "HotelStatement/";
  9090. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9091. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9092. #region 数据处理
  9093. List<int> guestIds = new List<int>();
  9094. int index = 0;
  9095. foreach (var item in hrDtas)
  9096. {
  9097. if (item.GuestName.Contains(","))
  9098. {
  9099. string[] guestIdArr = item.GuestName.Split(',');
  9100. foreach (var guestIdStr in guestIdArr)
  9101. {
  9102. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9103. if (guestBool)
  9104. {
  9105. guestIds.Add(guestId);
  9106. }
  9107. }
  9108. }
  9109. else guestNames += item.GuestName;
  9110. var voucherInfo = new HotelVoucherInfoView()
  9111. {
  9112. HotelName = item.HotelName,
  9113. CheckInDate = item.CheckInDate,
  9114. CheckOutDate = item.CheckOutDate,
  9115. ConfirmationNumber = item.DetermineNo.Trim(),
  9116. RoomType = item.RoomExplanation
  9117. };
  9118. vouchers.Add(voucherInfo);
  9119. }
  9120. if (guestIds.Count > 0)
  9121. {
  9122. guestIds = guestIds.Distinct().ToList();
  9123. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9124. if (guestDatas.Count > 0)
  9125. {
  9126. guestNames = "";
  9127. foreach (var guest in guestDatas)
  9128. {
  9129. string guestName = "";
  9130. if (guest.Sex == 0) guestName += @"MR.";
  9131. else if (guest.Sex == 1) guestName += @"MS.";
  9132. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9133. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9134. guestNames += @$"{guestName.Trim()}、";
  9135. }
  9136. if (guestNames.Length > 0)
  9137. {
  9138. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9139. }
  9140. }
  9141. }
  9142. #endregion
  9143. //载入模板
  9144. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9145. Document doc = new Document(sss);
  9146. DocumentBuilder builder = new DocumentBuilder(doc);
  9147. if (doc.Range.Bookmarks["GuestName"] != null)
  9148. {
  9149. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9150. mark.Text = guestNames;
  9151. }
  9152. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9153. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9154. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9155. for (int i = 1; i <= vouchers.Count; i++)
  9156. {
  9157. HotelVoucherInfoView hviv = vouchers[i - 1];
  9158. builder.MoveToCell(0, i, 0, 0);
  9159. builder.Write(hviv.HotelName);
  9160. builder.MoveToCell(0, i, 1, 0);
  9161. builder.Write(hviv.CheckInDate);
  9162. builder.MoveToCell(0, i, 2, 0);
  9163. builder.Write(hviv.CheckOutDate);
  9164. builder.MoveToCell(0, i, 3, 0);
  9165. builder.Write(hviv.RoomType);
  9166. builder.MoveToCell(0, i, 4, 0);
  9167. builder.Write(hviv.ConfirmationNumber);
  9168. }
  9169. //删除多余行
  9170. int currRowIndex = vouchers.Count + 1;
  9171. int delRows = 21 - currRowIndex;
  9172. if (delRows > 0)
  9173. {
  9174. for (int i = 0; i < delRows; i++)
  9175. {
  9176. table.Rows.RemoveAt(currRowIndex);
  9177. //cultivateRowIndex++;
  9178. }
  9179. }
  9180. strFileName += "VOUCHER.docx";
  9181. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9182. doc.Save(fileDir);
  9183. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9184. return Ok(JsonView(true, "操作成功!", Url));
  9185. }
  9186. /// <summary>
  9187. /// 酒店预订
  9188. /// 生成 预定成本 Excel
  9189. /// </summary>
  9190. /// <param name="_dto"></param>
  9191. /// <returns></returns>
  9192. [HttpPost]
  9193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9194. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9195. {
  9196. #region 参数验证
  9197. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9198. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9199. if (!vadalitorRes.IsValid)
  9200. {
  9201. var errors = new StringBuilder();
  9202. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9203. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9204. }
  9205. #region 团组操作权限验证 76 酒店预定模块
  9206. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9207. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9208. #endregion
  9209. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9210. #region 页面操作权限验证
  9211. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9212. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9213. #endregion
  9214. #endregion
  9215. decimal _rate = 1.00M;
  9216. string _currency = "";
  9217. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9218. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9219. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9220. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9221. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9222. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9223. {
  9224. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9225. }
  9226. _currency = _GroupCostParameter.Currency;
  9227. bool isIntType = int.TryParse(_currency, out int currId);
  9228. if (isIntType)
  9229. {
  9230. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9231. }
  9232. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9233. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9234. if (currInfo == null)
  9235. {
  9236. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9237. }
  9238. if (!_currency.ToUpper().Equals("CNY"))
  9239. {
  9240. _rate = _GroupCostParameter.Rate;
  9241. }
  9242. _rate = currInfo.Rate;
  9243. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9244. string strFileName = "HotelStatement/";
  9245. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9246. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9247. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9248. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9249. #region 数据处理
  9250. foreach (var item in hrDtas)
  9251. {
  9252. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9253. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9254. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9255. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9256. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9257. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  9258. string singleRoomFeeStr = string.Empty,
  9259. doubleRoomFeeStr = string.Empty,
  9260. suiteRoomFeeStr = string.Empty,
  9261. otherRoomFeeStr = string.Empty,
  9262. payMoneyStr = string.Empty,
  9263. cardPriceStr = string.Empty;
  9264. if (roomCurr.Equals(_currency))
  9265. {
  9266. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9267. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9268. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9269. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9270. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9271. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9272. }
  9273. else
  9274. {
  9275. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9276. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9277. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9278. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9279. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9280. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9281. }
  9282. string breakfastPriceStr = string.Empty,
  9283. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9284. governmentRentStr = string.Empty,
  9285. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9286. cityTaxStrStr = string.Empty,
  9287. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9288. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9289. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9290. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9291. pcfds.Add(new HotelReservations_PCFD_View()
  9292. {
  9293. City = item.City,
  9294. HotelName = item.HotelName,
  9295. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9296. // SingleRoomCount = item.SingleRoomCount,
  9297. SingleRoomPrice = singleRoomFeeStr,
  9298. // DoubleRoomCount = item.DoubleRoomCount,
  9299. DoubleRoomPrice = doubleRoomFeeStr,
  9300. //SuiteRoomCount = item.SuiteRoomCount,
  9301. SuiteRoomPrice = suiteRoomFeeStr,
  9302. OtherRoomPrice = otherRoomFeeStr,
  9303. //OtherRoomCount = item.OtherRoomCount,
  9304. BreakfastPrice = breakfastPriceStr,
  9305. GovernmentRent = governmentRentStr,
  9306. CityTax = cityTaxStrStr,
  9307. RoomExplanation = item.RoomExplanation,
  9308. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  9309. PayTime = roomInfo.ConsumptionDate,
  9310. BankNo = roomInfo.BankNo,
  9311. PayMoney = payMoneyStr,
  9312. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9313. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  9314. CardPrice = cardPriceStr,
  9315. Remark = ccpInfo.Remark
  9316. });
  9317. }
  9318. #endregion
  9319. //载入模板
  9320. WorkbookDesigner designer = new WorkbookDesigner();
  9321. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9322. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9323. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9324. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9325. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9326. designer.SetDataSource("Opertor", userInfo.CnName);
  9327. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9328. dt.TableName = "ViewMyHotelReservations";
  9329. designer.SetDataSource(dt);
  9330. designer.Process();
  9331. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9332. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9333. designer.Workbook.Save(serverPath);
  9334. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9335. #region 删除指定行
  9336. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9337. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9338. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9339. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9340. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9341. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9342. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9343. cssIndex = dt.Columns["CityTax"].Ordinal,
  9344. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9345. remarkIndex = dt.Columns["Remark"].Ordinal;
  9346. //删除指定列
  9347. foreach (DataRow item in dt.Rows)
  9348. {
  9349. string singleStr = item["SingleRoomPrice"].ToString();
  9350. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9351. if (containsDigitButNotZero1) singleDel = false;
  9352. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9353. string doubleStr = item["DoubleRoomPrice"].ToString();
  9354. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9355. if (containsDigitButNotZero2) doubleDel = false;
  9356. string suiteStr = item["SuiteRoomPrice"].ToString();
  9357. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9358. if (containsDigitButNotZero3) suiteDel = false;
  9359. string otherStr = item["OtherRoomPrice"].ToString();
  9360. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9361. if (containsDigitButNotZero4) otherDel = false;
  9362. string zcStr = item["BreakfastPrice"].ToString();
  9363. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9364. if (containsDigitButNotZero5) zcDel = false;
  9365. string dsStr = item["GovernmentRent"].ToString();
  9366. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9367. if (containsDigitButNotZero6) dsDel = false;
  9368. string cssStr = item["CityTax"].ToString();
  9369. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9370. if (containsDigitButNotZero7) cssDel = false;
  9371. string cpStr = item["ConsumptionPatterns"].ToString();
  9372. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9373. string remarkStr = item["Remark"].ToString();
  9374. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9375. }
  9376. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9377. DeleteColumn(serverPath, cpIndex, cpDel);
  9378. DeleteColumn(serverPath, dsIndex, dsDel);
  9379. DeleteColumn(serverPath, cssIndex, cssDel);
  9380. DeleteColumn(serverPath, zcIndex, zcDel);
  9381. DeleteColumn(serverPath, otherIndex, otherDel);
  9382. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9383. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9384. DeleteColumn(serverPath, singleIndex, singleDel);
  9385. #endregion
  9386. //只保留第一个表格
  9387. DeleteSheet(serverPath);
  9388. return Ok(JsonView(true, "操作成功", url = rst));
  9389. }
  9390. /// <summary>
  9391. /// 删除指定列
  9392. /// </summary>
  9393. /// <param name="file"></param>
  9394. /// <param name="columnIndex"></param>
  9395. /// <param name="isDel"></param>
  9396. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9397. {
  9398. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9399. //wb.Save(file);
  9400. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9401. if (sheet1 != null)
  9402. {
  9403. if (isDel)
  9404. {
  9405. Cells cells = sheet1.Cells;
  9406. cells.DeleteColumn(columnIndex);
  9407. }
  9408. }
  9409. wb.Save(file);
  9410. }
  9411. /// <summary>
  9412. /// 删除sheet
  9413. /// </summary>
  9414. /// <param name="file"></param>
  9415. /// <param name="sheetName"></param>
  9416. private void DeleteSheet(string file, string sheetName = "")
  9417. {
  9418. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9419. //wb.Save(file);
  9420. List<string> sheets = new List<string>();
  9421. foreach (var item in wb.Worksheets)
  9422. {
  9423. sheets.Add(item.Name);
  9424. }
  9425. if (sheets.Count > 0)
  9426. {
  9427. sheets.RemoveAt(0);//不删除第一个sheet
  9428. foreach (var item in sheets)
  9429. {
  9430. wb.Worksheets.RemoveAt(item);
  9431. }
  9432. }
  9433. wb.Save(file);
  9434. }
  9435. /// <summary>
  9436. /// 酒店预订
  9437. /// 确认单
  9438. /// </summary>
  9439. /// <param name="_dto"></param>
  9440. /// <returns></returns>
  9441. [HttpPost]
  9442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9443. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9444. {
  9445. try
  9446. {
  9447. #region 参数验证
  9448. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9449. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9450. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9451. #region 团组操作权限验证 76 酒店预定模块
  9452. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9453. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9454. #endregion
  9455. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9456. #region 页面操作权限验证
  9457. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9458. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9459. #endregion
  9460. #endregion
  9461. //团组信息
  9462. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9463. //酒店数据
  9464. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9465. if (listhoteldata.Count < 0)
  9466. {
  9467. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9468. }
  9469. //利datatable存储
  9470. DataTable dt = new DataTable();
  9471. dt.Columns.Add("CheckInDate", typeof(string));
  9472. dt.Columns.Add("City", typeof(string));
  9473. dt.Columns.Add("Hotel", typeof(string));
  9474. dt.Columns.Add("Room", typeof(string));
  9475. for (int i = 0; i < listhoteldata.Count; i++)
  9476. {
  9477. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9478. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9479. while (dayStart < dayEnd)
  9480. {
  9481. string temp = "";
  9482. DataRow row = dt.NewRow();
  9483. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9484. row["City"] = listhoteldata[i].City;
  9485. row["Hotel"] = listhoteldata[i].HotelName;
  9486. if (listhoteldata[i].SingleRoomCount > 0)
  9487. {
  9488. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9489. }
  9490. if (listhoteldata[i].DoubleRoomCount > 0)
  9491. {
  9492. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9493. }
  9494. if (listhoteldata[i].SuiteRoomCount > 0)
  9495. {
  9496. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9497. }
  9498. if (listhoteldata[i].OtherRoomCount > 0)
  9499. {
  9500. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9501. }
  9502. row["Room"] = temp;
  9503. dt.Rows.Add(row);
  9504. dayStart = dayStart.AddDays(1);
  9505. }
  9506. }
  9507. Dictionary<string, string> dic = new Dictionary<string, string>();
  9508. dic.Add("Dele", di.TeamName);
  9509. dic.Add("City", di.VisitCountry);
  9510. //模板路径
  9511. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9512. //载入模板
  9513. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9514. DocumentBuilder builder = new DocumentBuilder(doc);
  9515. foreach (var key in dic.Keys)
  9516. {
  9517. builder.MoveToBookmark(key);
  9518. builder.Write(dic[key]);
  9519. }
  9520. //获取word里所有表格
  9521. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9522. //获取所填表格的序数
  9523. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9524. var rowStart = tableOne.Rows[0]; //获取第1行
  9525. //循环赋值
  9526. for (int i = 0; i < dt.Rows.Count; i++)
  9527. {
  9528. builder.MoveToCell(0, i + 1, 0, 0);
  9529. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9530. builder.MoveToCell(0, i + 1, 1, 0);
  9531. builder.Write(dt.Rows[i]["City"].ToString());
  9532. builder.MoveToCell(0, i + 1, 2, 0);
  9533. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9534. builder.MoveToCell(0, i + 1, 3, 0);
  9535. builder.Write(dt.Rows[i]["Room"].ToString());
  9536. }
  9537. //删除多余行
  9538. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9539. {
  9540. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9541. }
  9542. string strFileName = di.TeamName + "酒店确认单.doc";
  9543. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9544. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9545. return Ok(JsonView(true, "成功", url));
  9546. }
  9547. catch (Exception ex)
  9548. {
  9549. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9550. }
  9551. }
  9552. #endregion
  9553. #region 团组状态
  9554. /// <summary>
  9555. /// 团组状态列表 Page
  9556. /// </summary>
  9557. /// <param name="dto">团组列表请求dto</param>
  9558. /// <returns></returns>
  9559. [HttpPost]
  9560. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9561. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9562. {
  9563. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9564. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9565. {
  9566. string sqlWhere = string.Empty;
  9567. if (dto.IsSure == 0) //未完成
  9568. {
  9569. sqlWhere += string.Format(@" And IsSure = 0");
  9570. }
  9571. else if (dto.IsSure == 1) //已完成
  9572. {
  9573. sqlWhere += string.Format(@" And IsSure = 1");
  9574. }
  9575. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9576. {
  9577. string tj = dto.SearchCriteria;
  9578. 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}%')",
  9579. tj, tj, tj, tj, tj);
  9580. }
  9581. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9582. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9583. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9584. From (
  9585. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9586. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9587. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9588. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9589. From Grp_DelegationInfo gdi
  9590. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9591. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9592. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9593. Where gdi.IsDel = 0 {0}
  9594. ) temp ", sqlWhere);
  9595. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9596. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9597. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9598. }
  9599. else
  9600. {
  9601. return Ok(JsonView(false, "查询失败"));
  9602. }
  9603. }
  9604. /// <summary>
  9605. /// 团组状态
  9606. /// 设置操作完成
  9607. /// </summary>
  9608. /// <param name="dto">团组列表请求dto</param>
  9609. /// <returns></returns>
  9610. [HttpPost]
  9611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9612. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9613. {
  9614. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9615. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9616. {
  9617. Id = dto.Id,
  9618. IsSure = 1
  9619. };
  9620. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9621. .UpdateColumns(it => new { it.IsSure })
  9622. .WhereColumns(it => new { it.Id })
  9623. .ExecuteCommandAsync();
  9624. if (result > 0)
  9625. {
  9626. return Ok(JsonView(true, "操作完成!"));
  9627. }
  9628. return Ok(JsonView(false, "操作失败!"));
  9629. }
  9630. #endregion
  9631. #region 保险费用录入
  9632. /// <summary>
  9633. /// 根据团组Id查询保险费用列表
  9634. /// </summary>
  9635. /// <param name="dto"></param>
  9636. /// <returns></returns>
  9637. [HttpPost]
  9638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9639. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9640. {
  9641. try
  9642. {
  9643. Result groupData = await _customersRep.CustomersByDiId(dto);
  9644. if (groupData.Code != 0)
  9645. {
  9646. return Ok(JsonView(false, groupData.Msg));
  9647. }
  9648. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9649. }
  9650. catch (Exception ex)
  9651. {
  9652. return Ok(JsonView(false, ex.Message));
  9653. }
  9654. }
  9655. /// <summary>
  9656. /// 根据保险费用Id查询保险费用详细
  9657. /// </summary>
  9658. /// <param name="dto"></param>
  9659. /// <returns></returns>
  9660. [HttpPost]
  9661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9662. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9663. {
  9664. try
  9665. {
  9666. Result groupData = await _customersRep.CustomersById(dto);
  9667. if (groupData.Code != 0)
  9668. {
  9669. return Ok(JsonView(false, groupData.Msg));
  9670. }
  9671. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9672. }
  9673. catch (Exception ex)
  9674. {
  9675. return Ok(JsonView(false, ex.Message));
  9676. }
  9677. }
  9678. /// <summary>
  9679. /// 保险费用录入页面初始化绑定
  9680. /// </summary>
  9681. /// <param name="dto"></param>
  9682. /// <returns></returns>
  9683. [HttpPost]
  9684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9685. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9686. {
  9687. try
  9688. {
  9689. Result groupData = await _customersRep.CustomersInitialize(dto);
  9690. if (groupData.Code != 0)
  9691. {
  9692. return Ok(JsonView(false, groupData.Msg));
  9693. }
  9694. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9695. }
  9696. catch (Exception ex)
  9697. {
  9698. return Ok(JsonView(false, ex.Message));
  9699. }
  9700. }
  9701. /// <summary>
  9702. /// 保险费用操作(Status:1.新增,2.修改)
  9703. /// </summary>
  9704. /// <param name="dto"></param>
  9705. /// <returns></returns>
  9706. [HttpPost]
  9707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9708. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9709. {
  9710. try
  9711. {
  9712. Result groupData = await _customersRep.OpCustomers(dto);
  9713. if (groupData.Code != 0)
  9714. {
  9715. return Ok(JsonView(false, groupData.Msg));
  9716. }
  9717. #region 应用推送
  9718. try
  9719. {
  9720. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9721. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9722. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9723. }
  9724. catch (Exception ex)
  9725. {
  9726. }
  9727. #endregion
  9728. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9729. }
  9730. catch (Exception ex)
  9731. {
  9732. return Ok(JsonView(false, ex.Message));
  9733. }
  9734. }
  9735. /// <summary>
  9736. /// 保险文件上传
  9737. /// </summary>
  9738. /// <param name="file"></param>
  9739. /// <returns></returns>
  9740. [HttpPost]
  9741. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9742. public async Task<IActionResult> UploadCus(IFormFile file)
  9743. {
  9744. try
  9745. {
  9746. if (file != null)
  9747. {
  9748. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9749. //文件名称
  9750. string projectFileName = file.FileName;
  9751. //上传的文件的路径
  9752. string filePath = "";
  9753. if (!Directory.Exists(fileDir))
  9754. {
  9755. Directory.CreateDirectory(fileDir);
  9756. }
  9757. //上传的文件的路径
  9758. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9759. using (FileStream fs = System.IO.File.Create(filePath))
  9760. {
  9761. file.CopyTo(fs);
  9762. fs.Flush();
  9763. }
  9764. return Ok(JsonView(true, "上传成功!", projectFileName));
  9765. }
  9766. else
  9767. {
  9768. return Ok(JsonView(false, "上传失败!"));
  9769. }
  9770. }
  9771. catch (Exception ex)
  9772. {
  9773. return Ok(JsonView(false, "程序错误!"));
  9774. throw;
  9775. }
  9776. }
  9777. /// <summary>
  9778. /// 保险删除指定文件
  9779. /// </summary>
  9780. /// <param name="dto"></param>
  9781. /// <returns></returns>
  9782. [HttpPost]
  9783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9784. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9785. {
  9786. try
  9787. {
  9788. string filePath = "";
  9789. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9790. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9791. //int id = 0;
  9792. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9793. // 删除该文件
  9794. try
  9795. {
  9796. System.IO.File.Delete(filePath);
  9797. 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()
  9798. {
  9799. Attachment = "",
  9800. }).ExecuteCommandAsync();
  9801. if (result != 0)
  9802. {
  9803. return Ok(JsonView(true, "成功!"));
  9804. }
  9805. else
  9806. {
  9807. return Ok(JsonView(false, "失败!"));
  9808. }
  9809. }
  9810. catch (Exception)
  9811. {
  9812. 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()
  9813. {
  9814. Attachment = "",
  9815. }).ExecuteCommandAsync();
  9816. if (result != 0)
  9817. {
  9818. return Ok(JsonView(true, "成功!"));
  9819. }
  9820. else
  9821. {
  9822. return Ok(JsonView(false, "失败!"));
  9823. }
  9824. }
  9825. }
  9826. catch (Exception ex)
  9827. {
  9828. return Ok(JsonView(false, "程序错误!"));
  9829. throw;
  9830. }
  9831. }
  9832. /// <summary>
  9833. /// 保险费用操作(删除)
  9834. /// </summary>
  9835. /// <param name="dto"></param>
  9836. /// <returns></returns>
  9837. [HttpPost]
  9838. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9839. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9840. {
  9841. try
  9842. {
  9843. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9844. if (!res)
  9845. {
  9846. return Ok(JsonView(false, "删除失败"));
  9847. }
  9848. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9849. {
  9850. IsDel = 1,
  9851. DeleteUserId = dto.DeleteUserId,
  9852. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9853. }).ExecuteCommandAsync();
  9854. return Ok(JsonView(true, "删除成功!"));
  9855. }
  9856. catch (Exception ex)
  9857. {
  9858. return Ok(JsonView(false, "程序错误!"));
  9859. throw;
  9860. }
  9861. }
  9862. #endregion
  9863. #region 接团客户名单 PageId 104
  9864. /// <summary>
  9865. /// 接团客户名单
  9866. /// 迁移数据(慎用!)
  9867. /// </summary>
  9868. /// <param name="dto"></param>
  9869. /// <returns></returns>
  9870. [HttpPost]
  9871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9872. public async Task<IActionResult> PostTourClientListChange()
  9873. {
  9874. try
  9875. {
  9876. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9877. //var groupClinetData1
  9878. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9879. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9880. int updateCount = 0;
  9881. if (oldOAClientList.Count > 0)
  9882. {
  9883. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9884. _sqlSugar.BeginTran();
  9885. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9886. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9887. foreach (var item in oldOAClientList)
  9888. {
  9889. int comId = 0;
  9890. string format = "yyyy-MM-dd HH:mm:ss";
  9891. string data11 = "1990-01-01 00:00";
  9892. var data1 = IsValidDate(item.OPdate, format);
  9893. if (data1) data11 = item.OPdate;
  9894. //客户公司验证
  9895. if (!string.IsNullOrEmpty(item.Company))
  9896. {
  9897. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9898. if (clientComInfo == null) // add
  9899. {
  9900. var addInfo = new Crm_CustomerCompany()
  9901. {
  9902. CompanyAbbreviation = "",
  9903. CompanyFullName = item.Company,
  9904. Address = "",
  9905. PostCodes = "",
  9906. LastedOpUserId = item.OPer,
  9907. LastedOpDt = Convert.ToDateTime(data11),
  9908. CreateUserId = item.OPer,
  9909. CreateTime = Convert.ToDateTime(data11),
  9910. IsDel = 0
  9911. };
  9912. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9913. if (comId1 > 0) comId = comId1;
  9914. }
  9915. else comId = clientComInfo.Id;
  9916. }
  9917. //客户人员验证
  9918. int clientId = 0;
  9919. string name = item.LastName + item.Name;
  9920. if (!string.IsNullOrEmpty(name))
  9921. {
  9922. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9923. if (clientInfo == null)
  9924. {
  9925. DateTime? dateTime = null;
  9926. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9927. if (isDt) dateTime = birthDayDt;
  9928. var addInfo1 = new Crm_DeleClient()
  9929. {
  9930. CrmCompanyId = comId,
  9931. DiId = -1,
  9932. LastName = item.LastName,
  9933. FirstName = item.Name,
  9934. OldName = "",
  9935. Pinyin = item.Pinyin,
  9936. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9937. Marriage = 0,
  9938. Phone = item.Phone,
  9939. Job = item.Job,
  9940. BirthDay = dateTime
  9941. };
  9942. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9943. if (clientId1 > 0) clientId = clientId1;
  9944. }
  9945. else clientId = clientInfo.Id;
  9946. }
  9947. if (clientId < 1)
  9948. {
  9949. continue;
  9950. }
  9951. int airType = 0;
  9952. if (item.AirType == "超经舱") airType = 459;
  9953. else if (item.AirType == "公务舱") airType = 458;
  9954. else if (item.AirType == "经济舱") airType = 460;
  9955. else if (item.AirType == "其他") airType = 565;
  9956. else if (item.AirType == "头等舱") airType = 457;
  9957. var _TourClientListEntity = new Grp_TourClientList()
  9958. {
  9959. DiId = item.Diid,
  9960. ClientId = clientId,
  9961. CreateUserId = item.OPer,
  9962. CreateTime = Convert.ToDateTime(data11),
  9963. Remark = item.Remark,
  9964. IsDel = item.Isdel,
  9965. ShippingSpaceTypeId = airType,
  9966. ShippingSpaceSpecialNeeds = item.AirRemark,
  9967. HotelSpecialNeeds = item.RoomType
  9968. };
  9969. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9970. if (_TourClientList > 0)
  9971. {
  9972. updateCount++;
  9973. }
  9974. }
  9975. _sqlSugar.CommitTran();
  9976. }
  9977. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9978. }
  9979. catch (Exception ex)
  9980. {
  9981. _sqlSugar.RollbackTran();
  9982. return Ok(JsonView(false, ex.Message));
  9983. }
  9984. return Ok(JsonView(true));
  9985. }
  9986. private bool IsValidDate(string dateString, string format)
  9987. {
  9988. DateTime dateValue;
  9989. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9990. return valid;
  9991. }
  9992. /// <summary>
  9993. /// 接团客户名单
  9994. /// 根据团组Id查询List
  9995. /// </summary>
  9996. /// <param name="dto"></param>
  9997. /// <returns></returns>
  9998. [HttpPost]
  9999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10000. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  10001. {
  10002. #region 参数验证
  10003. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  10004. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10005. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10006. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10007. #region 页面操作权限验证
  10008. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10009. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10010. #endregion
  10011. #endregion
  10012. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10013. if (viewData.Code != 0)
  10014. {
  10015. return Ok(JsonView(false, viewData.Msg));
  10016. }
  10017. return Ok(JsonView(viewData.Data));
  10018. }
  10019. /// <summary>
  10020. /// 接团客户名单
  10021. /// 基础数据 Init
  10022. /// </summary>
  10023. /// <param name="_dto"></param>
  10024. /// <returns></returns>
  10025. [HttpPost]
  10026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10027. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10028. {
  10029. #region 参数验证
  10030. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10031. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10032. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10033. #region 页面操作权限验证
  10034. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10035. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10036. #endregion
  10037. #endregion
  10038. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10039. if (viewData.Code != 0)
  10040. {
  10041. return Ok(JsonView(false, viewData.Msg));
  10042. }
  10043. return Ok(JsonView(viewData.Data));
  10044. }
  10045. /// <summary>
  10046. /// 接团客户名单
  10047. /// 根据 Id查询 Details
  10048. /// </summary>
  10049. /// <param name="_dto"></param>
  10050. /// <returns></returns>
  10051. [HttpPost]
  10052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10053. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10054. {
  10055. #region 参数验证
  10056. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10057. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10058. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10060. #region 页面操作权限验证
  10061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10062. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10063. #endregion
  10064. #endregion
  10065. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10066. if (viewData.Code != 0)
  10067. {
  10068. return Ok(JsonView(false, viewData.Msg));
  10069. }
  10070. return Ok(JsonView(viewData.Data));
  10071. }
  10072. /// <summary>
  10073. /// 接团客户名单
  10074. /// Add Or Edit
  10075. /// </summary>
  10076. /// <param name="_dto"></param>
  10077. /// <returns></returns>
  10078. [HttpPost]
  10079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10080. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10081. {
  10082. #region 参数验证
  10083. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10084. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10085. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10086. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10087. #region 页面操作权限验证
  10088. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10089. if (_dto.Id == 0) //添加
  10090. {
  10091. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10092. }
  10093. else if (_dto.Id >= 0) //修改
  10094. {
  10095. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10096. }
  10097. #endregion
  10098. #endregion
  10099. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10100. if (viewData.Code != 0)
  10101. {
  10102. return Ok(JsonView(false, viewData.Msg));
  10103. }
  10104. return Ok(JsonView(true));
  10105. }
  10106. /// <summary>
  10107. /// 接团客户名单
  10108. /// AddMultiple(添加多个)
  10109. /// </summary>
  10110. /// <param name="_dto"></param>
  10111. /// <returns></returns>
  10112. [HttpPost]
  10113. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10114. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10115. {
  10116. #region 参数验证
  10117. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10118. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10119. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10120. #region 页面操作权限验证
  10121. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10122. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10123. #endregion
  10124. #endregion
  10125. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10126. if (viewData.Code != 0)
  10127. {
  10128. return Ok(JsonView(false, viewData.Msg));
  10129. }
  10130. return Ok(JsonView(true));
  10131. }
  10132. /// <summary>
  10133. /// 接团客户名单
  10134. /// Del
  10135. /// </summary>
  10136. /// <param name="_dto"></param>
  10137. /// <returns></returns>
  10138. [HttpPost]
  10139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10140. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10141. {
  10142. #region 参数验证
  10143. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10144. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10145. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10146. #region 页面操作权限验证
  10147. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10148. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10149. #endregion
  10150. #endregion
  10151. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10152. if (viewData.Code != 0)
  10153. {
  10154. return Ok(JsonView(false, viewData.Msg));
  10155. }
  10156. return Ok(JsonView(true));
  10157. }
  10158. /// <summary>
  10159. /// 接团客户名单
  10160. /// 文件下载 客户名单
  10161. /// </summary>
  10162. /// <param name="_dto"></param>
  10163. /// <returns></returns>
  10164. [HttpPost]
  10165. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10166. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10167. {
  10168. #region 参数验证
  10169. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10170. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10171. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10173. #region 页面操作权限验证
  10174. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10175. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10176. #endregion
  10177. #endregion
  10178. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10179. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10180. From Grp_TourClientList tcl
  10181. Left Join
  10182. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10183. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10184. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10185. From Crm_DeleClient dc
  10186. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10187. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10188. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10189. Where dc.IsDel = 0) temp
  10190. On temp.DcId =tcl.ClientId
  10191. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10192. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10193. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10194. //载入模板
  10195. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10196. if (_dto.Language == 1)
  10197. {
  10198. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10199. }
  10200. //载入模板
  10201. var doc = new Document(tempPath);
  10202. DocumentBuilder builder = new DocumentBuilder(doc);
  10203. //获取word里所有表格
  10204. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10205. //获取所填表格的序数
  10206. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10207. var rowStart = tableOne.Rows[0]; //获取第1行
  10208. if (_dto.Language == 0)
  10209. {
  10210. //循环赋值
  10211. for (int i = 0; i < DcList.Count; i++)
  10212. {
  10213. builder.MoveToCell(0, i + 1, 0, 0);
  10214. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10215. builder.MoveToCell(0, i + 1, 1, 0);
  10216. int sex = DcList[i].Sex;
  10217. string sexStr = string.Empty;
  10218. if (sex == 0) sexStr = "男";
  10219. else if (sex == 1) sexStr = "女";
  10220. else sexStr = "未设置";
  10221. builder.Write(sexStr);
  10222. builder.MoveToCell(0, i + 1, 2, 0);
  10223. string birthDay = DcList[i].BirthDay;
  10224. string birthDayStr = string.Empty;
  10225. if (!string.IsNullOrEmpty(birthDay))
  10226. {
  10227. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10228. }
  10229. builder.Write(birthDayStr);
  10230. builder.MoveToCell(0, i + 1, 3, 0);
  10231. string company = "";
  10232. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10233. {
  10234. company = DcList[i].CompanyFullName.ToString();
  10235. }
  10236. builder.Write(company);
  10237. builder.MoveToCell(0, i + 1, 4, 0);
  10238. builder.Write(DcList[i].Job);
  10239. }
  10240. }
  10241. else if (_dto.Language == 1)
  10242. {
  10243. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10244. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10245. //循环赋值
  10246. for (int i = 0; i < DcList.Count; i++)
  10247. {
  10248. string PYName = "";
  10249. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10250. {
  10251. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10252. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10253. PYName = PY_First + " " + PY_Last;
  10254. }
  10255. else
  10256. {
  10257. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10258. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10259. PYName = PY_First + " " + PY_Last;
  10260. }
  10261. builder.MoveToCell(0, i + 1, 0, 0);
  10262. builder.Write(PYName);
  10263. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10264. builder.MoveToCell(0, i + 1, 1, 0);
  10265. builder.Write(sex);
  10266. DateTime birthDt;
  10267. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10268. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10269. builder.MoveToCell(0, i + 1, 2, 0);
  10270. builder.Write(birthday);
  10271. string company = "";
  10272. try
  10273. {
  10274. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10275. {
  10276. //查询对照表
  10277. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10278. if (tempCec != null)
  10279. {
  10280. company = tempCec.enName;
  10281. }
  10282. //翻译
  10283. else
  10284. {
  10285. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10286. }
  10287. }
  10288. }
  10289. catch (Exception)
  10290. {
  10291. }
  10292. builder.MoveToCell(0, i + 1, 3, 0);
  10293. builder.Write(company);
  10294. string job = "";
  10295. try
  10296. {
  10297. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10298. {
  10299. //查询对照表
  10300. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10301. if (tempPec != null)
  10302. {
  10303. job = tempPec.enName;
  10304. }
  10305. //翻译
  10306. else
  10307. {
  10308. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10309. }
  10310. }
  10311. }
  10312. catch (Exception ex)
  10313. {
  10314. }
  10315. builder.MoveToCell(0, i + 1, 4, 0);
  10316. builder.Write(job);
  10317. }
  10318. }
  10319. //删除多余行
  10320. while (tableOne.Rows.Count > DcList.Count + 1)
  10321. {
  10322. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10323. }
  10324. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10325. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10326. doc.Save(fileDir);
  10327. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10328. return Ok(JsonView(true, "操作成功!", Url));
  10329. }
  10330. #endregion
  10331. #region 团组倒推表
  10332. /// <summary>
  10333. /// 倒推表基础数据
  10334. /// Init
  10335. /// </summary>
  10336. /// <param name="dto"></param>
  10337. /// <returns></returns>
  10338. [HttpPost]
  10339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10340. public async Task<IActionResult> PostInvertedListInit()
  10341. {
  10342. var viewData = await _invertedListRep._Init();
  10343. if (viewData.Code != 0)
  10344. {
  10345. return Ok(JsonView(false, viewData.Msg));
  10346. }
  10347. return Ok(JsonView(viewData.Data));
  10348. }
  10349. /// <summary>
  10350. /// 倒推表
  10351. /// Info
  10352. /// </summary>
  10353. /// <param name="dto"></param>
  10354. /// <returns></returns>
  10355. [HttpPost]
  10356. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10357. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10358. {
  10359. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10360. if (viewData.Code != 0)
  10361. {
  10362. return Ok(JsonView(false, viewData.Msg));
  10363. }
  10364. return Ok(JsonView(viewData.Data));
  10365. }
  10366. /// <summary>
  10367. /// 倒推表
  10368. /// Create
  10369. /// </summary>
  10370. /// <param name="dto"></param>
  10371. /// <returns></returns>
  10372. [HttpPost]
  10373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10374. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10375. {
  10376. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10377. if (viewData.Code != 0)
  10378. {
  10379. return Ok(JsonView(false, viewData.Msg));
  10380. }
  10381. return Ok(JsonView(viewData.Data));
  10382. }
  10383. /// <summary>
  10384. /// 倒推表
  10385. /// Update
  10386. /// </summary>
  10387. /// <param name="dto"></param>
  10388. /// <returns></returns>
  10389. [HttpPost]
  10390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10391. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10392. {
  10393. var viewData = await _invertedListRep._Update(dto);
  10394. if (viewData.Code != 0)
  10395. {
  10396. return Ok(JsonView(false, viewData.Msg));
  10397. }
  10398. return Ok(JsonView(viewData.Data));
  10399. }
  10400. /// <summary>
  10401. /// 倒推表
  10402. /// File Download
  10403. /// </summary>
  10404. /// <param name="dto"></param>
  10405. /// <returns></returns>
  10406. [HttpPost]
  10407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10408. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10409. {
  10410. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10411. if (info2.Code != 0)
  10412. {
  10413. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10414. }
  10415. var info1 = info2.Data as InvertedListInfoView;
  10416. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10417. string teamName = "";
  10418. if (info != null) teamName = info.TeamName;
  10419. //载入模板
  10420. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10421. DocumentBuilder builder = new DocumentBuilder(doc);
  10422. //利用键值对存放数据
  10423. Dictionary<string, string> dic = new Dictionary<string, string>();
  10424. dic.Add("TeamName", teamName);
  10425. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10426. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10427. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10428. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10429. dic.Add("SQRemark", info1.ApprovalRemark);
  10430. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10431. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10432. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10433. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10434. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10435. dic.Add("QZRemark", info1.VisaInformationRemark);
  10436. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10437. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10438. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10439. dic.Add("CQRemark", info1.IssueVisaRemark);
  10440. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10441. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10442. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10443. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10444. #region 填充word模板书签内容
  10445. foreach (var key in dic.Keys)
  10446. {
  10447. builder.MoveToBookmark(key);
  10448. builder.Write(dic[key]);
  10449. }
  10450. #endregion
  10451. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10452. string fileName = $"{teamName}团出行准备流程表.doc";
  10453. string filePath = fileDir + $@"InvertedList/{fileName}";
  10454. doc.Save(filePath);
  10455. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10456. return Ok(JsonView(true, "操作成功!", Url));
  10457. }
  10458. #endregion
  10459. #region 三公签证费用(签证费、代办费)
  10460. /// <summary>
  10461. /// 三公签证费用(签证费、代办费)
  10462. /// List
  10463. /// </summary>
  10464. /// <returns></returns>
  10465. [HttpPost]
  10466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10467. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10468. {
  10469. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10470. if (_view.Code != 0)
  10471. {
  10472. return Ok(JsonView(false, _view.Msg));
  10473. }
  10474. return Ok(JsonView(true, "操作成功!", _view.Data));
  10475. }
  10476. /// <summary>
  10477. /// 三公签证费用(签证费、代办费)
  10478. /// Add Or Update
  10479. /// </summary>
  10480. /// <returns></returns>
  10481. [HttpPost]
  10482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10483. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10484. {
  10485. var _view = await _visaFeeInfoRep._Update(_dto);
  10486. if (_view.Code != 0)
  10487. {
  10488. return Ok(JsonView(false, _view.Msg));
  10489. }
  10490. return Ok(JsonView(true, _view.Msg));
  10491. }
  10492. #endregion
  10493. #region 酒店询价
  10494. /// <summary>
  10495. /// 酒店询价
  10496. /// Init
  10497. /// </summary>
  10498. /// <param name="dto"></param>
  10499. /// <returns></returns>
  10500. [HttpPost]
  10501. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10502. public async Task<IActionResult> PostHotelInquiryInit()
  10503. {
  10504. var res = await _hotelInquiryRep._Init();
  10505. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10506. return Ok(JsonView(true, res.Msg, res.Data));
  10507. }
  10508. /// <summary>
  10509. /// 酒店询价
  10510. /// page Item
  10511. /// </summary>
  10512. /// <param name="_dto"></param>
  10513. /// <returns></returns>
  10514. [HttpPost]
  10515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10516. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10517. {
  10518. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10519. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10520. var view = res.Data as PageDataViewBase;
  10521. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10522. }
  10523. /// <summary>
  10524. /// 酒店询价
  10525. /// info
  10526. /// </summary>
  10527. /// <param name="_dto"></param>
  10528. /// <returns></returns>
  10529. [HttpPost]
  10530. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10531. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10532. {
  10533. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10534. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10535. return Ok(JsonView(true, res.Msg, res.Data));
  10536. }
  10537. /// <summary>
  10538. /// 酒店询价
  10539. /// Add Or Edit
  10540. /// </summary>
  10541. /// <param name="_dto"></param>
  10542. /// <returns></returns>
  10543. [HttpPost]
  10544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10545. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10546. {
  10547. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10548. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10549. return Ok(JsonView(true, res.Msg, res.Data));
  10550. }
  10551. /// <summary>
  10552. /// 酒店询价
  10553. /// Del
  10554. /// </summary>
  10555. /// <param name="_dto"></param>
  10556. /// <returns></returns>
  10557. [HttpPost]
  10558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10559. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10560. {
  10561. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10562. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10563. return Ok(JsonView(true, res.Msg, res.Data));
  10564. }
  10565. #endregion
  10566. #region 下载匹配op行程单
  10567. /// <summary>
  10568. /// 匹配op行程单
  10569. /// Init
  10570. /// </summary>
  10571. /// <param name="dto">团组列表请求dto</param>
  10572. /// <returns></returns>
  10573. [HttpPost]
  10574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10575. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10576. {
  10577. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10578. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10579. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10580. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10581. if (isDepStatus)
  10582. {
  10583. groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.JietuanOperator == dto.CurrUserId).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10584. }
  10585. else
  10586. {
  10587. groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10588. }
  10589. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10590. var diids = groupInfos.Select(it => it.Id).ToList();
  10591. List<string> countrys = new List<string>();
  10592. foreach (var item in country)
  10593. {
  10594. var data = _groupRepository.FormartTeamName(item);
  10595. var dataArray = _groupRepository.GroupSplitCountry(data);
  10596. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10597. }
  10598. countrys = countrys.Distinct().ToList();
  10599. for (int i = 0; i < countrys.Count; i++)
  10600. {
  10601. string item = countrys[i];
  10602. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10603. {
  10604. countrys.Remove(item);
  10605. i--;
  10606. }
  10607. }
  10608. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10609. foreach (var item in diids)
  10610. {
  10611. string areaStr = GeneralMethod.GetGroupCityLine(item, "-");
  10612. if (!string.IsNullOrEmpty(areaStr))
  10613. {
  10614. string[] str1 = areaStr.Split("-");
  10615. if (str1.Length > 0)
  10616. {
  10617. areaArray.AddRange(str1);
  10618. }
  10619. }
  10620. }
  10621. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10622. List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10623. string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10624. if (string.IsNullOrEmpty(countriesDataStr))
  10625. {
  10626. cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10627. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10628. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10629. }
  10630. else
  10631. {
  10632. cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10633. }
  10634. List<Sys_Cities> existCitys = new List<Sys_Cities>();
  10635. var existCitys1 = cityDatas.Where(it => areaArray.Contains(it.Name_CN)).Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN }).ToList();
  10636. List<int> countriesIds = existCitys1.Select(it => it.parentId).ToList();
  10637. var countriesDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10638. .Where(it => countriesIds.Contains(it.Id))
  10639. .Select(it => new { it.Id, Name = it.Name_CN })
  10640. .ToListAsync();
  10641. //var countryDatas = countriesDatas.Select(it => new
  10642. //{
  10643. // id = it.Id,
  10644. // name = it.Name,
  10645. // childList = existCitys.Where(it1 => it1.CountriesId == it.Id).Select(it1 => new { parentId = it1.CountriesId, id = it1.Id, name = it1.Name_CN }).ToList()
  10646. //}).ToList();
  10647. var teamNames = groupInfos.Select(it => it.TeamName).ToList();
  10648. for (int i = 0; i < teamNames.Count; i++)
  10649. {
  10650. string item = teamNames[i];
  10651. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10652. {
  10653. teamNames.Remove(item);
  10654. i--;
  10655. }
  10656. }
  10657. stopwatch.Stop();
  10658. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = existCitys1 }));
  10659. }
  10660. ///// <summary>
  10661. ///// 匹配op行程单
  10662. ///// Init 查询区域数据
  10663. ///// </summary>
  10664. ///// <param name="dto">团组列表请求dto</param>
  10665. ///// <returns></returns>
  10666. //[HttpPost]
  10667. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10668. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10669. //{
  10670. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10671. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10672. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10673. // if (string.IsNullOrEmpty(countriesDataStr))
  10674. // {
  10675. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10676. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10677. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10678. // }
  10679. // else
  10680. // {
  10681. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10682. // }
  10683. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10684. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10685. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10686. // List<dynamic> childList = new List<dynamic>();
  10687. // int parentId = dto.CountriesId;
  10688. // if (provinceData.Count > 1)
  10689. // {
  10690. // foreach (var item1 in provinceData)
  10691. // {
  10692. // List<dynamic> childList1 = new List<dynamic>();
  10693. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10694. // foreach (var item2 in citiesData1)
  10695. // {
  10696. // List<dynamic> childList2 = new List<dynamic>();
  10697. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10698. // foreach (var item3 in countiesData1)
  10699. // {
  10700. // childList2.Add(new
  10701. // {
  10702. // id = item3.Id,
  10703. // parentId = item2.Id,
  10704. // level = "district",
  10705. // name = item3.Name_CN,
  10706. // });
  10707. // }
  10708. // childList1.Add(new
  10709. // {
  10710. // id = item2.Id,
  10711. // parentId = item1.Id,
  10712. // level = "city",
  10713. // name = item2.Name_CN,
  10714. // childList = childList2
  10715. // });
  10716. // }
  10717. // childList.Add(new
  10718. // {
  10719. // id = item1.Id,
  10720. // parentId = parentId,
  10721. // level = "province",
  10722. // name = item1.Name_CN,
  10723. // childList = childList1
  10724. // });
  10725. // }
  10726. // //城市
  10727. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10728. // foreach (var item2 in citiesData2)
  10729. // {
  10730. // List<dynamic> childList22 = new List<dynamic>();
  10731. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10732. // foreach (var item3 in countiesData1)
  10733. // {
  10734. // childList22.Add(new
  10735. // {
  10736. // id = item3.Id,
  10737. // parentId = item2.Id,
  10738. // level = "district",
  10739. // name = item3.Name_CN,
  10740. // });
  10741. // }
  10742. // childList.Add(new
  10743. // {
  10744. // id = item2.Id,
  10745. // parentId = parentId,
  10746. // level = "city",
  10747. // name = item2.Name_CN,
  10748. // childList = childList22
  10749. // });
  10750. // }
  10751. // }
  10752. // else
  10753. // {
  10754. // foreach (var item2 in citiesData)
  10755. // {
  10756. // string cname = item2.Name_CN;
  10757. // List<dynamic> childList1 = new List<dynamic>();
  10758. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10759. // foreach (var item3 in countiesData1)
  10760. // {
  10761. // childList1.Add(new
  10762. // {
  10763. // Id = item3.Id,
  10764. // parentId = item2.Id,
  10765. // level = "district",
  10766. // name = item3.Name_CN
  10767. // });
  10768. // }
  10769. // childList.Add(new
  10770. // {
  10771. // id = item2.Id,
  10772. // parentId = parentId,
  10773. // level = "city",
  10774. // name = item2.Name_CN,
  10775. // childList = childList1
  10776. // });
  10777. // }
  10778. // }
  10779. // stopwatch.Stop();
  10780. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10781. //}
  10782. /// <summary>
  10783. /// 匹配op行程单
  10784. /// 接团信息列表 Page
  10785. /// </summary>
  10786. /// <param name="dto">团组列表请求dto</param>
  10787. /// <returns></returns>
  10788. [HttpPost]
  10789. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10790. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10791. {
  10792. #region 参数验证
  10793. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10794. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10795. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10796. #region 页面操作权限验证
  10797. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10798. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10799. #endregion
  10800. #endregion
  10801. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10802. {
  10803. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10804. string sqlWhere = "";
  10805. if (!string.IsNullOrEmpty(dto.Country))
  10806. {
  10807. _view = _view.Where(x => x.VisitCountry != null && x.VisitCountry.Contains(dto.Country)).ToList();
  10808. }
  10809. if (!string.IsNullOrEmpty(dto.Area))
  10810. {
  10811. _view = _view.Where(x => x.RouteCity != null && x.RouteCity.Contains(dto.Area)).ToList();
  10812. }
  10813. if (!string.IsNullOrEmpty(dto.TeamName))
  10814. {
  10815. _view = _view.Where(x => x.TeamName != null && x.TeamName.Contains(dto.TeamName)).ToList();
  10816. }
  10817. return Ok(JsonView(true, "查询成功!", _view.Skip(dto.PageIndex).Take(dto.PageSize).ToList(), _view.Count));
  10818. }
  10819. else
  10820. {
  10821. return Ok(JsonView(false, "查询失败"));
  10822. }
  10823. }
  10824. /// <summary>
  10825. /// 匹配op行程单
  10826. /// 行程单下载
  10827. /// </summary>
  10828. /// <param name="dto">团组列表请求dto</param>
  10829. /// <returns></returns>
  10830. [HttpPost]
  10831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10832. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10833. {
  10834. #region 参数验证
  10835. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10836. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10837. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10838. #region 页面操作权限验证
  10839. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10840. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10841. #endregion
  10842. #endregion
  10843. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10844. {
  10845. var res = ExportTravel(new InitOpTravelDto() { Diid = dto.diId });
  10846. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10847. }
  10848. else
  10849. {
  10850. return Ok(JsonView(false, "下载失败!"));
  10851. }
  10852. }
  10853. #endregion
  10854. #region 国家信息 数据 注释
  10855. //[HttpPost]
  10856. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10857. //{
  10858. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10859. // foreach (var item in dto)
  10860. // {
  10861. // infos.Add(new Grp_GroupsTaskAssignment()
  10862. // {
  10863. // DIId = item,
  10864. // CTId = 82,
  10865. // UId = 248,
  10866. // IsEnable = 1,
  10867. // CreateUserId = 233,
  10868. // CreateTime = DateTime.Now,
  10869. // IsDel = 0
  10870. // });
  10871. // infos.Add(new Grp_GroupsTaskAssignment()
  10872. // {
  10873. // DIId = item,
  10874. // CTId = 82,
  10875. // UId = 286,
  10876. // IsEnable = 1,
  10877. // CreateUserId = 233,
  10878. // CreateTime = DateTime.Now,
  10879. // IsDel = 0
  10880. // });
  10881. // }
  10882. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10883. // return Ok("操作成功");
  10884. //}
  10885. //public class paramJsonDto
  10886. //{
  10887. // public List<CountriesInfo> str { get; set; }
  10888. //}
  10889. //[HttpPost]
  10890. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10891. //{
  10892. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10893. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10894. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10895. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10896. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10897. // _sqlSugar.BeginTran();
  10898. // int countitiesIndex = 0;
  10899. // foreach (var item in dto.str)
  10900. // {
  10901. // dynamic data = item.c;
  10902. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10903. // if (data != null)
  10904. // {
  10905. // countitiesIndex++;
  10906. // foreach (var item1 in data)
  10907. // {
  10908. // string cnname = item1.cn;
  10909. // string enname = item1.en;
  10910. // Sys_Cities provinceInfo = new Sys_Cities()
  10911. // {
  10912. // CountriesId = countriesId,
  10913. // Name_CN = cnname,
  10914. // Name_EN = enname,
  10915. // ParentId = 0,
  10916. // IsCapital = 1,
  10917. // CreateUserId = 208,
  10918. // CreateTime = DateTime.Now,
  10919. // IsDel = 0
  10920. // };
  10921. // if (item1.lv == "province") //省份
  10922. // {
  10923. // provinceInfo.Level = 1;
  10924. // int provinceId = 0;
  10925. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10926. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10927. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10928. // var data1 = item1.c;
  10929. // foreach (var item2 in data1)
  10930. // {
  10931. // if (item2.lv == "city")
  10932. // {
  10933. // string citycnname = item2.cn;
  10934. // string cityenname = item2.en;
  10935. // Sys_Cities cityInfo = new Sys_Cities()
  10936. // {
  10937. // CountriesId = countriesId,
  10938. // ParentId = provinceId,
  10939. // Level = 2,
  10940. // Name_CN = citycnname,
  10941. // Name_EN = cityenname,
  10942. // IsCapital = 1,
  10943. // CreateUserId = 208,
  10944. // CreateTime = DateTime.Now,
  10945. // IsDel = 0
  10946. // };
  10947. // if (item2.c != null)
  10948. // {
  10949. // int cityId = 0;
  10950. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10951. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10952. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10953. // foreach (var item3 in item2.c)
  10954. // {
  10955. // if (item3.lv == "district")
  10956. // {
  10957. // var districtInfo = new Sys_Cities()
  10958. // {
  10959. // CountriesId = countriesId,
  10960. // Name_CN = item3.cn,
  10961. // Name_EN = item3.en,
  10962. // Level = 3,
  10963. // ParentId = cityId,
  10964. // IsCapital = 1,
  10965. // CreateUserId = 208,
  10966. // CreateTime = DateTime.Now,
  10967. // IsDel = 0
  10968. // };
  10969. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10970. // //{
  10971. // districts.Add(districtInfo);
  10972. // //}
  10973. // }
  10974. // }
  10975. // }
  10976. // else
  10977. // {
  10978. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10979. // //{
  10980. // cities.Add(cityInfo);
  10981. // //}
  10982. // }
  10983. // }
  10984. // }
  10985. // }
  10986. // else if (item1.lv == "city")//城市
  10987. // {
  10988. // provinceInfo.Level = 2;
  10989. // if (item1.c != null)
  10990. // {
  10991. // int cityId = 0;
  10992. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10993. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10994. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10995. // foreach (var item3 in item1.c)
  10996. // {
  10997. // if (item3.lv == "district")
  10998. // {
  10999. // var districtInfo = new Sys_Cities()
  11000. // {
  11001. // CountriesId = countriesId,
  11002. // Name_CN = item3.cn,
  11003. // Name_EN = item3.en,
  11004. // Level = 3,
  11005. // ParentId = cityId,
  11006. // IsCapital = 1,
  11007. // CreateUserId = 208,
  11008. // CreateTime = DateTime.Now,
  11009. // IsDel = 0
  11010. // };
  11011. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11012. // //{
  11013. // districts.Add(districtInfo);
  11014. // //}
  11015. // }
  11016. // }
  11017. // }
  11018. // else
  11019. // {
  11020. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11021. // //{
  11022. // cities.Add(provinceInfo);
  11023. // //}
  11024. // }
  11025. // }
  11026. // }
  11027. // }
  11028. // }
  11029. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11030. // cities = cities.Distinct().ToList();
  11031. // districts = districts.Distinct().ToList();
  11032. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11033. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11034. // cities.AddRange(districts);
  11035. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11036. // //_sqlSugar.RollbackTran();
  11037. // _sqlSugar.CommitTran();
  11038. // return Ok(JsonView(false, "操作成功!"));
  11039. //}
  11040. //[HttpPost]
  11041. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11042. //{
  11043. // List<CountitiesInfo> infos = dto.MyProperty;
  11044. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11045. // _sqlSugar.BeginTran();
  11046. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11047. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11048. // foreach (var item in infos)
  11049. // {
  11050. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11051. // if (countryInfo != null)
  11052. // {
  11053. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11054. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11055. // if (cityInfo1 != null)
  11056. // {
  11057. // cityInfo1.IsCapital = 0;
  11058. // cityInfos.Add(cityInfo1);
  11059. // }
  11060. // }
  11061. // }
  11062. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11063. // .UpdateColumns(it => it.IsCapital)
  11064. // .WhereColumns(it => it.Id)
  11065. // .ExecuteCommand();
  11066. // //_sqlSugar.RollbackTran();
  11067. // _sqlSugar.CommitTran();
  11068. // return Ok(JsonView(false, "操作成功!"));
  11069. //}
  11070. //public class CounrtiesDto
  11071. //{
  11072. // public List<CountitiesInfo> MyProperty { get; set; }
  11073. //}
  11074. //public class CountitiesInfo
  11075. //{
  11076. // /// <summary>
  11077. // /// 圣约翰
  11078. // /// </summary>
  11079. // public string capital_name_chinese { get; set; }
  11080. // /// <summary>
  11081. // ///
  11082. // /// </summary>
  11083. // public string capital_name { get; set; }
  11084. // /// <summary>
  11085. // ///
  11086. // /// </summary>
  11087. // public string country_type { get; set; }
  11088. // /// <summary>
  11089. // /// 安提瓜和巴布达
  11090. // /// </summary>
  11091. // public string country_name_chinese { get; set; }
  11092. // /// <summary>
  11093. // /// 安提瓜和巴布达
  11094. // /// </summary>
  11095. // public string country_name_chinese_short { get; set; }
  11096. // /// <summary>
  11097. // /// 安提瓜和巴布达
  11098. // /// </summary>
  11099. // public string country_name_chinese_UN { get; set; }
  11100. // /// <summary>
  11101. // ///
  11102. // /// </summary>
  11103. // public string country_name_english_abbreviation { get; set; }
  11104. // /// <summary>
  11105. // ///
  11106. // /// </summary>
  11107. // public string country_name_english_formal { get; set; }
  11108. // /// <summary>
  11109. // ///
  11110. // /// </summary>
  11111. // public string country_name_english_UN { get; set; }
  11112. // /// <summary>
  11113. // ///
  11114. // /// </summary>
  11115. // public string continent_name { get; set; }
  11116. // /// <summary>
  11117. // ///
  11118. // /// </summary>
  11119. // public string subregion_name { get; set; }
  11120. // /// <summary>
  11121. // ///
  11122. // /// </summary>
  11123. // public string country_code2 { get; set; }
  11124. // /// <summary>
  11125. // ///
  11126. // /// </summary>
  11127. // public string country_code3 { get; set; }
  11128. // /// <summary>
  11129. // ///
  11130. // /// </summary>
  11131. // public string phone_code { get; set; }
  11132. //}
  11133. //public class CountriesInfo : BasicInfo
  11134. //{
  11135. // public List<CitiesInfo> c { get; set; }
  11136. //}
  11137. //public class CitiesInfo : BasicInfo
  11138. //{
  11139. // public List<AreaInfo> c { get; set; }
  11140. //}
  11141. //public class AreaInfo : BasicInfo
  11142. //{
  11143. // public List<AreaInfo> c { get; set; }
  11144. //}
  11145. //public class BasicInfo
  11146. //{
  11147. // public string code { get; set; }
  11148. // public string cn { get; set; }
  11149. // public string lv { get; set; }
  11150. // public string en { get; set; }
  11151. //}
  11152. #endregion
  11153. #region 报批行程
  11154. /// <summary>
  11155. /// 报批行程初始化
  11156. /// </summary>
  11157. /// <param name="dto"></param>
  11158. /// <returns></returns>
  11159. [HttpPost]
  11160. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11161. {
  11162. const int chiNumber = 5;
  11163. var jw = JsonView(false);
  11164. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11165. var group = groupList.First();
  11166. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11167. group = groupList.First(x => x.Id == diid);
  11168. if (group == null)
  11169. {
  11170. jw.Msg = "暂无团组!";
  11171. return Ok(jw);
  11172. }
  11173. var resultArr = new ArrayList();
  11174. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11175. if (content.Count == 0)
  11176. {
  11177. ////黑屏代码数据
  11178. //DataTable dt = GetTableByBlackCode(group.Id);
  11179. //if (dt.Rows[0]["Day"] == null || dt.Rows[0]["Day"].ToString() == "")//判断黑屏代码数据是否正确生成
  11180. //{
  11181. //}
  11182. //else
  11183. //{
  11184. // jw.Msg = "黑屏代码有误!";
  11185. // return Ok(jw);
  11186. //}
  11187. DateTime StartDate = (group.VisitStartDate);
  11188. DateTime EndDate = (group.VisitEndDate);
  11189. TimeSpan t3 = EndDate - StartDate; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  11190. var getDay = t3.Days;
  11191. if (getDay == 0) getDay = 1;
  11192. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11193. _sqlSugar.BeginTran();
  11194. for (int i = 0; i < getDay; i++)
  11195. {
  11196. DateTime NewData = StartDate.AddDays(i);
  11197. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11198. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11199. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11200. appro.Diid = diid ?? -1;
  11201. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11202. appro.Id = thisId;
  11203. appro.CreateUserId = dto.UserId;
  11204. appro.CreateTime = DateTime.Now;
  11205. content.Add(appro);
  11206. }
  11207. _sqlSugar.CommitTran();
  11208. }
  11209. foreach (var x in content)
  11210. {
  11211. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11212. if (chiList.Count < chiNumber)
  11213. {
  11214. for (int i = chiList.Count; i < chiNumber; i++)
  11215. {
  11216. chiList.Add(new Grp_ApprovalTravelDetails());
  11217. }
  11218. }
  11219. resultArr.Add(new
  11220. {
  11221. x.Id,
  11222. x.Date,
  11223. x.Diid,
  11224. chiList = chiList.Select(x1 => new
  11225. {
  11226. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  11227. x1.Details,
  11228. x1.ParentId,
  11229. x1.Id
  11230. })
  11231. });
  11232. }
  11233. var data = new
  11234. {
  11235. groupList = groupList.Select(x => new
  11236. {
  11237. x.TeamName,
  11238. x.Id
  11239. }),
  11240. content = resultArr,
  11241. groupInfo = new
  11242. {
  11243. group.VisitDays,
  11244. group.TourCode,
  11245. group.VisitPNumber,
  11246. group.TeamName,
  11247. group.Id,
  11248. group.VisitStartDate,
  11249. group.VisitEndDate
  11250. },
  11251. };
  11252. jw = JsonView(true,"获取成功!",data);
  11253. return Ok(jw);
  11254. }
  11255. /// <summary>
  11256. /// 报批行程删除
  11257. /// </summary>
  11258. /// <param name="dto"></param>
  11259. /// <returns></returns>
  11260. [HttpPost]
  11261. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11262. {
  11263. var jw = JsonView(false);
  11264. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  11265. if (group == null)
  11266. {
  11267. jw.Msg = "团组参数有误!";
  11268. return Ok(jw);
  11269. }
  11270. try
  11271. {
  11272. _sqlSugar.BeginTran();
  11273. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  11274. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11275. {
  11276. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11277. DeleteUserId = dto.uesrId,
  11278. IsDel = 1
  11279. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11280. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11281. {
  11282. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11283. DeleteUserId = dto.uesrId,
  11284. IsDel = 1
  11285. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11286. _sqlSugar.CommitTran();
  11287. jw = JsonView(true, "删除成功");
  11288. }
  11289. catch (Exception ex)
  11290. {
  11291. jw = JsonView(false, ex.Message);
  11292. }
  11293. return Ok(jw);
  11294. }
  11295. /// <summary>
  11296. /// 报批行程保存
  11297. /// </summary>
  11298. /// <param name="dto"></param>
  11299. /// <returns></returns>
  11300. [HttpPost]
  11301. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11302. {
  11303. var jw = JsonView(false);
  11304. var Find = dto.Arr.Find(x => x.id == 0);
  11305. if (Find != null)
  11306. {
  11307. jw.Msg = "生成的ID为0!";
  11308. return Ok(jw);
  11309. }
  11310. foreach (var item in dto.Arr)
  11311. {
  11312. foreach (var chi in item.chiList)
  11313. {
  11314. if (chi.parentId == 0)
  11315. {
  11316. chi.parentId = item.id;
  11317. }
  11318. }
  11319. }
  11320. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11321. _sqlSugar.BeginTran();
  11322. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  11323. {
  11324. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11325. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  11326. {
  11327. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11328. DeleteUserId = dto.UserId,
  11329. IsDel = 1
  11330. }).ExecuteCommand();
  11331. }
  11332. try
  11333. {
  11334. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11335. {
  11336. CreateTime = DateTime.Now,
  11337. CreateUserId = dto.UserId,
  11338. Details = x.details,
  11339. ParentId = x.parentId,
  11340. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11341. Remark = "",
  11342. IsDel = 0
  11343. }).ToList()).ExecuteCommand();
  11344. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11345. {
  11346. Id = x.id,
  11347. Details = x.details,
  11348. ParentId = x.parentId,
  11349. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11350. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  11351. {
  11352. Details = x.Details,
  11353. ParentId = x.ParentId,
  11354. Time = x.Time
  11355. }).ExecuteCommand();
  11356. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11357. {
  11358. Id = x.id,
  11359. Date = x.date,
  11360. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11361. {
  11362. Date = x.Date
  11363. }).ExecuteCommand();
  11364. _sqlSugar.CommitTran();
  11365. jw = JsonView(true, "保存成功!");
  11366. }
  11367. catch (Exception ex)
  11368. {
  11369. _sqlSugar.RollbackTran();
  11370. jw = JsonView(false, "保存失败!" + ex.Message);
  11371. }
  11372. return Ok(jw);
  11373. }
  11374. /// <summary>
  11375. /// 报批行程生成
  11376. /// </summary>
  11377. /// <param name="dto"></param>
  11378. /// <returns></returns>
  11379. [HttpPost]
  11380. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11381. {
  11382. var jw = JsonView(false);
  11383. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11384. if (group == null)
  11385. {
  11386. jw.Msg = "暂无该团组!";
  11387. return Ok(jw);
  11388. }
  11389. DateTime StartDate = (group.VisitStartDate);
  11390. DateTime EndDate = (group.VisitEndDate);
  11391. TimeSpan t3 = EndDate - StartDate;
  11392. var getDay = t3.Days;
  11393. if (getDay == 0) getDay = 1;
  11394. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11395. var resultArr = new ArrayList();
  11396. if (officialActivitiesArr.Count == 0)
  11397. {
  11398. jw.Msg = "暂无公务出访信息!";
  11399. return Ok(jw);
  11400. }
  11401. try
  11402. {
  11403. _sqlSugar.BeginTran();
  11404. DeleteApprovalJourney(new
  11405. Domain.Dtos.Groups.DeleteApprovalJourney
  11406. {
  11407. Diid = dto.Diid,
  11408. uesrId = dto.Userid
  11409. });
  11410. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11411. for (int i = 0; i < getDay; i++)
  11412. {
  11413. DateTime NewData = StartDate.AddDays(i);
  11414. 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();
  11415. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11416. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11417. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11418. appro.Diid = dto.Diid;
  11419. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11420. appro.Id = thisId;
  11421. appro.CreateUserId = dto.Userid;
  11422. appro.CreateTime = DateTime.Now;
  11423. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11424. foreach (var item in gwinfo)
  11425. {
  11426. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11427. chi.Details = "拜访" + item.Client;
  11428. chi.ParentId = thisId;
  11429. chi.Time = item.Time;
  11430. chiarr.Add(chi);
  11431. }
  11432. if (chiarr.Count < 5)
  11433. {
  11434. for (int j = chiarr.Count; j < 5; j++)
  11435. {
  11436. chiarr.Add(new
  11437. Grp_ApprovalTravelDetails());
  11438. }
  11439. }
  11440. resultArr.Add(new
  11441. {
  11442. appro.Id,
  11443. appro.Date,
  11444. appro.Diid,
  11445. chiList = chiarr.Select(x1 => new
  11446. {
  11447. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11448. x1.Details,
  11449. x1.ParentId,
  11450. x1.Id
  11451. })
  11452. });
  11453. }
  11454. _sqlSugar.CommitTran();
  11455. jw = JsonView(true, "生成成功!", resultArr);
  11456. }
  11457. catch (Exception ex)
  11458. {
  11459. jw.Code = 400;
  11460. jw.Msg = "生成失败!" + ex.Message;
  11461. }
  11462. return Ok(jw);
  11463. }
  11464. /// <summary>
  11465. /// 报批行程word导出
  11466. /// </summary>
  11467. /// <param name="dto"></param>
  11468. /// <returns></returns>
  11469. [HttpPost]
  11470. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11471. {
  11472. var jw = JsonView(false);
  11473. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11474. if (group == null)
  11475. {
  11476. jw.Msg = "暂无该团组!";
  11477. return Ok(jw);
  11478. }
  11479. //模板路径
  11480. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  11481. //载入模板
  11482. Document doc = new Document(tempPath);
  11483. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11484. //获取所填表格的序数
  11485. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11486. Aspose.Words.Tables.Row titleRowClone = null;
  11487. Aspose.Words.Tables.Row CenterRowClone = null;
  11488. int index = 0;
  11489. int indexChi = 0;
  11490. int SetIndex = 0;
  11491. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11492. //获取数据,放到datatable
  11493. foreach (var item in ApprovalTravelArr)
  11494. {
  11495. if (index > 0)
  11496. {
  11497. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11498. tableOne.AppendChild(titleRowClone);
  11499. }
  11500. var textTime = item.Date;
  11501. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11502. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11503. SetIndex++;
  11504. if (ChiRep.Count > 0)
  11505. {
  11506. foreach (var itemChi in ChiRep)
  11507. {
  11508. var txtTime = itemChi.Time;
  11509. var txtDetail = itemChi.Details;
  11510. if (indexChi > 0)
  11511. {
  11512. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11513. tableOne.AppendChild(CenterRowClone);
  11514. }
  11515. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11516. {
  11517. SetCells(tableOne, doc, SetIndex, 0, "");
  11518. SetCells(tableOne, doc, SetIndex, 1, "");
  11519. indexChi++;
  11520. SetIndex++;
  11521. break;
  11522. }
  11523. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11524. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11525. indexChi++;
  11526. SetIndex++;
  11527. }
  11528. }
  11529. else
  11530. {
  11531. if (indexChi > 0)
  11532. {
  11533. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11534. tableOne.AppendChild(CenterRowClone);
  11535. }
  11536. SetCells(tableOne, doc, SetIndex, 0, "");
  11537. SetCells(tableOne, doc, SetIndex, 1, "");
  11538. indexChi++;
  11539. SetIndex++;
  11540. }
  11541. index++;
  11542. }
  11543. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11544. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11545. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11546. jw.Code = 200;
  11547. jw.Msg = "";
  11548. return Ok(jw);
  11549. }
  11550. private string intToString(int numberVal)
  11551. {
  11552. string numberval = numberVal.ToString();
  11553. Dictionary<char, string> Number = new Dictionary<char, string>();
  11554. Number.Add('1', "一");
  11555. Number.Add('2', "二");
  11556. Number.Add('3', "三");
  11557. Number.Add('4', "四");
  11558. Number.Add('5', "五");
  11559. Number.Add('6', "六");
  11560. Number.Add('7', "七");
  11561. Number.Add('8', "八");
  11562. Number.Add('9', "九");
  11563. string stringNumberVal = string.Empty;
  11564. for (int i = 0; i < numberval.Length; i++)
  11565. {
  11566. if (i == 0)
  11567. {
  11568. stringNumberVal += Number[numberval[i]];
  11569. }
  11570. else if (i >= 1)
  11571. {
  11572. if (numberval[i] == '0')
  11573. {
  11574. stringNumberVal = "十";
  11575. }
  11576. else
  11577. {
  11578. stringNumberVal += "十" + Number[numberval[i]];
  11579. }
  11580. }
  11581. }
  11582. return stringNumberVal;
  11583. }
  11584. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11585. {
  11586. //获取table中的某个单元格,从0开始
  11587. Cell lshCell = table.Rows[rows].Cells[cells];
  11588. //将单元格中的第一个段落移除
  11589. lshCell.FirstParagraph.Remove();
  11590. //新建一个段落
  11591. Paragraph p = new Paragraph(doc);
  11592. var r = new Run(doc, val);
  11593. //把设置的值赋给之前新建的段落
  11594. p.AppendChild(r);
  11595. //将此段落加到单元格内
  11596. lshCell.AppendChild(p);
  11597. }
  11598. #endregion
  11599. // /// <summary>
  11600. // ///
  11601. // /// </summary>
  11602. // /// <param name="_dto"></param>
  11603. // /// <returns></returns>
  11604. // [HttpPost]
  11605. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11606. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11607. // {
  11608. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11609. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11610. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11611. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11612. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11613. // dic_psg.Add("客人", 974);
  11614. // dic_psg.Add("司机", 975);
  11615. // dic_psg.Add("导游", 976);
  11616. // dic_psg.Add("公司内部人员", 977);
  11617. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11618. // foreach (var item in list_visa)
  11619. // {
  11620. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11621. // temp.Id = item.Id;
  11622. // temp.DIId = item.DIId;
  11623. // temp.VisaClient = item.VisaClient;
  11624. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11625. // temp.VisaCurrency = item.VisaCurrency;
  11626. // temp.IsThird = item.IsThird;
  11627. // if (dic_psg.ContainsKey(item.PassengerType))
  11628. // {
  11629. // temp.PassengerType = dic_psg[item.PassengerType];
  11630. // }
  11631. // else {
  11632. // temp.PassengerType = -1;
  11633. // }
  11634. // temp.VisaNumber = item.VisaNumber;
  11635. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11636. // temp.CreateUserId = item.Operators;
  11637. // DateTime dt_ct;
  11638. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11639. // if (b_ct)
  11640. // {
  11641. // temp.CreateTime = dt_ct;
  11642. // }
  11643. // else
  11644. // {
  11645. // temp.CreateTime = DateTime.Now;
  11646. // }
  11647. // temp.DeleteTime = "";
  11648. // temp.DeleteUserId = 0;
  11649. // temp.Remark = item.Remark;
  11650. // if (string.IsNullOrEmpty(temp.Remark)) {
  11651. // temp.Remark = "";
  11652. // }
  11653. // temp.IsDel = item.IsDel;
  11654. // temp.VisaDescription = item.VisaAttachment;
  11655. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11656. //([Id]
  11657. // ,[DIId]
  11658. // ,[VisaClient]
  11659. // ,[VisaPrice]
  11660. // ,[VisaCurrency]
  11661. // ,[IsThird]
  11662. // ,[PassengerType]
  11663. // ,[VisaNumber]
  11664. // ,[VisaFreeNumber]
  11665. // ,[CreateUserId]
  11666. // ,[CreateTime]
  11667. // ,[DeleteTime]
  11668. // ,[DeleteUserId]
  11669. // ,[Remark]
  11670. // ,[IsDel]
  11671. // ,[visaDescription])
  11672. // VALUES
  11673. // ({0},{1},'{2}',{3},{4}
  11674. //,{5},{6},{7},{8},{9}
  11675. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11676. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11677. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11678. //);
  11679. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11680. // }
  11681. // return Ok(JsonView(true, "操作成功!"));
  11682. // }
  11683. /// <summary>
  11684. /// 123132123
  11685. /// </summary>
  11686. /// <param name="_dto"></param>
  11687. /// <returns></returns>
  11688. [HttpPost]
  11689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11690. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11691. {
  11692. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11693. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11694. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11695. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11696. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11697. dicDetail.Add(789, 1034);
  11698. dicDetail.Add(790, 1035);
  11699. dicDetail.Add(791, 1036);
  11700. dicDetail.Add(792, 1037);
  11701. dicDetail.Add(793, 1038);
  11702. dicDetail.Add(794, 1039);
  11703. dicDetail.Add(795, 1040);
  11704. dicDetail.Add(796, 1041);
  11705. dicDetail.Add(797, 1042);
  11706. dicDetail.Add(798, 1043);
  11707. dicDetail.Add(801, 1044);
  11708. dicDetail.Add(802, 1045);
  11709. dicDetail.Add(803, 1046);
  11710. Dictionary<int, int> dic = new Dictionary<int, int>();
  11711. dic.Add(806, 1027);
  11712. dic.Add(807, 1028);
  11713. dic.Add(808, 1029);
  11714. dic.Add(809, 1030);
  11715. dic.Add(810, 1031);
  11716. dic.Add(811, 1032);
  11717. dic.Add(812, 1033);
  11718. foreach (var item in list_visa)
  11719. {
  11720. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11721. temp.Coefficient = item.coefficient;
  11722. DateTime dtCrt;
  11723. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11724. if (b1)
  11725. {
  11726. temp.CreateTime = dtCrt;
  11727. }
  11728. else
  11729. {
  11730. temp.CreateTime = DateTime.Now;
  11731. }
  11732. temp.CreateUserId = item.Operators;
  11733. temp.DeleteTime = "";
  11734. temp.DeleteUserId = 0;
  11735. temp.DiId = int.Parse(item.DIID);
  11736. temp.FilePath = item.FilePath;
  11737. temp.IsDel = item.IsDel;
  11738. temp.Price = item.Price;
  11739. temp.PriceCount = 1;
  11740. temp.PriceCurrency = item.Currency;
  11741. int detailId = 0;
  11742. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11743. {
  11744. detailId = dicDetail[item.PriceTypeDetail];
  11745. }
  11746. temp.PriceDetailType = detailId;
  11747. temp.PriceDt = DateTime.Now;
  11748. temp.PriceName = item.PriceName;
  11749. temp.PriceSum = item.Price;
  11750. int tid = 0;
  11751. if (dic.ContainsKey(item.PriceType))
  11752. {
  11753. tid = dic[item.PriceType];
  11754. }
  11755. temp.PriceType = tid;
  11756. temp.Remark = item.Remark;
  11757. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11758. }
  11759. return Ok(JsonView(true, "操作成功!"));
  11760. }
  11761. }
  11762. }