GroupsController.cs 607 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492
  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. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  5093. if (groupData.Code != 0)
  5094. {
  5095. return Ok(JsonView(false, groupData.Msg));
  5096. }
  5097. #region 应用推送
  5098. try
  5099. {
  5100. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5101. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5102. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5103. }
  5104. catch (Exception ex)
  5105. {
  5106. }
  5107. #endregion
  5108. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5109. }
  5110. catch (Exception ex)
  5111. {
  5112. return Ok(JsonView(false, ex.Message));
  5113. }
  5114. }
  5115. /// <summary>
  5116. /// 获取三公详细所有城市
  5117. /// </summary>
  5118. /// <returns></returns>
  5119. [HttpGet]
  5120. public IActionResult OpCarCityResult()
  5121. {
  5122. var jw = JsonView(false);
  5123. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  5124. {
  5125. x.Id,
  5126. x.Country,
  5127. x.City,
  5128. }).ToList();
  5129. if (data.Count > 0)
  5130. {
  5131. jw = JsonView(true, "获取成功!", data);
  5132. }
  5133. else
  5134. {
  5135. jw.Msg = "城市数据为空!";
  5136. jw.Data = new string[0];
  5137. }
  5138. return Ok(jw);
  5139. }
  5140. /// <summary>
  5141. /// 导出地接费用明细
  5142. /// </summary>
  5143. /// <param name="dto"></param>
  5144. /// <returns></returns>
  5145. [HttpPost]
  5146. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  5147. {
  5148. var jw = JsonView(false);
  5149. if (dto.Diid < 1)
  5150. {
  5151. jw.Msg = "请输入正确的diid!";
  5152. return Ok(jw);
  5153. }
  5154. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  5155. if (group == null)
  5156. {
  5157. jw.Msg = "未找到团组信息!";
  5158. return Ok(jw);
  5159. }
  5160. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  5161. if (localGuideArr.Count == 0)
  5162. {
  5163. jw.Msg = "该团组暂无地接信息!";
  5164. return Ok(jw);
  5165. }
  5166. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  5167. var overspendSoure = new Dictionary<int, int>
  5168. {
  5169. { 91, 982 }, //车
  5170. { 92 , 1059} ,//导游
  5171. { 994 , 1073}, //翻译
  5172. { 988 , 1074 }, //早餐
  5173. { 93 , 1075 }, //午餐
  5174. { 989 , 1076 }, //晚餐
  5175. };
  5176. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  5177. foreach (var groupArr in localGroup)
  5178. {
  5179. var keyValue = groupArr.Key;
  5180. if (int.TryParse(keyValue, out int cityid))
  5181. {
  5182. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  5183. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  5184. }
  5185. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  5186. foreach (var item in groupArr)
  5187. {
  5188. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  5189. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  5190. new Grp_CarTouristGuideGroundReservationsContentExtend
  5191. {
  5192. Count = a.Count,
  5193. CreateTime = a.CreateTime,
  5194. CreateUserId = a.CreateUserId,
  5195. CTGGRId = a.CTGGRId,
  5196. Currency = a.Currency,
  5197. DatePrice = a.DatePrice,
  5198. DeleteTime = a.DeleteTime,
  5199. DeleteUserId = a.DeleteUserId,
  5200. DiId = a.DiId,
  5201. Id = a.Id,
  5202. IsDel = a.IsDel,
  5203. Price = a.Price,
  5204. PriceContent = a.PriceContent,
  5205. Remark = a.Remark,
  5206. SId = a.SId,
  5207. SidName = b.Name,
  5208. Units = a.Units,
  5209. }
  5210. ).ToList();
  5211. if (content.Count > 0)
  5212. {
  5213. contentArr.Add(content);
  5214. }
  5215. }
  5216. //open excel
  5217. //set excel
  5218. //save excel
  5219. try
  5220. {
  5221. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  5222. IWorkbook workbook;
  5223. if (Path.GetExtension(filePath).ToLower() == ".xls")
  5224. {
  5225. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5226. }
  5227. else
  5228. {
  5229. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  5230. }
  5231. ISheet sheet = workbook.GetSheetAt(0);
  5232. var rowStartIndex = 2;
  5233. var clounmCount = 10;
  5234. var initStyleRow = sheet.GetRow(2);
  5235. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  5236. //var overspendArrDetail =
  5237. var existsId = new List<CarCompare>();
  5238. var lastElem = arr.Last();
  5239. var thisSid = -1;
  5240. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  5241. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  5242. {
  5243. Name = "未知币种!",
  5244. Remark = "未知币种!",
  5245. };
  5246. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  5247. Action cloneRowFn = () =>
  5248. {
  5249. rowStartIndex++;
  5250. var cloneRow = sheet.CreateRow(rowStartIndex);
  5251. // 复制样式
  5252. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  5253. {
  5254. ICell sourceCell = initStyleRow.GetCell(i);
  5255. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  5256. // 确保单元格存在样式
  5257. if (sourceCell.CellStyle != null)
  5258. {
  5259. targetCell.CellStyle = sourceCell.CellStyle;
  5260. }
  5261. }
  5262. };
  5263. var mergeRow = () =>
  5264. {
  5265. for (int i = 2; i < sheet.LastRowNum; i++)
  5266. {
  5267. var row = sheet.GetRow(i);
  5268. var cellFirst = row.GetCell(0);
  5269. var thisIndex = i + 1;
  5270. while (thisIndex < sheet.LastRowNum)
  5271. {
  5272. var nextRow = sheet.GetRow(thisIndex);
  5273. var nextCellFirst = nextRow.GetCell(0);
  5274. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  5275. {
  5276. thisIndex++;
  5277. }
  5278. else
  5279. {
  5280. break;
  5281. }
  5282. }
  5283. thisIndex--;
  5284. if (thisIndex != i)
  5285. {
  5286. //合并row
  5287. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5288. i, // 起始行索引(0-based)
  5289. thisIndex, // 结束行索引(0-based)
  5290. 0, // 起始列索引(0-based)
  5291. 0 // 结束列索引(0-based)
  5292. );
  5293. sheet.AddMergedRegion(cellRangeAddress);
  5294. i = thisIndex;
  5295. }
  5296. }
  5297. };
  5298. var chaoshiNumber = 0;
  5299. var totalNumber = 0.00M;
  5300. string lastStr = "";
  5301. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  5302. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  5303. {
  5304. b.IsAuditGM,
  5305. x.Id,
  5306. x.Area,
  5307. b.PayPercentage,
  5308. b.PayMoney,
  5309. }).ToList();
  5310. string yesPayment = "", noPayment = "";
  5311. foreach (var item in queryCarArrByCityAndDiid)
  5312. {
  5313. if (item.IsAuditGM == 1)
  5314. {
  5315. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5316. }
  5317. else
  5318. {
  5319. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  5320. }
  5321. }
  5322. lastStr = yesPayment + noPayment;
  5323. foreach (var item in arr)
  5324. {
  5325. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  5326. {
  5327. if (thisSid != item.SId)
  5328. {
  5329. if (thisSid == -1)
  5330. {
  5331. thisSid = item.SId;
  5332. }
  5333. else
  5334. {
  5335. //合并小计行
  5336. //创建合并区域的实例
  5337. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5338. rowStartIndex, // 起始行索引(0-based)
  5339. rowStartIndex, // 结束行索引(0-based)
  5340. 0, // 起始列索引(0-based)
  5341. 3 // 结束列索引(0-based)
  5342. );
  5343. sheet.AddMergedRegion(cellRangeAddress);
  5344. var CellStyle = workbook.CreateCellStyle();
  5345. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5346. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5347. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5348. for (int i = 0; i <= clounmCount; i++)
  5349. {
  5350. if (i > 6)
  5351. {
  5352. var CellStyle1 = workbook.CreateCellStyle();
  5353. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5354. IFont Font = workbook.CreateFont(); // 创建字体
  5355. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5356. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5357. CellStyle1.SetFont(Font);
  5358. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5359. }
  5360. else
  5361. {
  5362. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5363. }
  5364. }
  5365. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5366. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5367. //超时合计
  5368. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5369. //超时数
  5370. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5371. //超时合计费用
  5372. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5373. thisSid = item.SId;
  5374. cloneRowFn();
  5375. chaoshiNumber = 0;
  5376. totalNumber = 0;
  5377. }
  5378. }
  5379. IRow row = sheet.GetRow(rowStartIndex);
  5380. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5381. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  5382. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  5383. if (isOpenOverspendSoure)
  5384. {
  5385. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5386. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  5387. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  5388. }
  5389. for (int i = 0; i <= clounmCount; i++)
  5390. {
  5391. var cell = row.GetCell(i);
  5392. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  5393. if (cell == null)
  5394. {
  5395. cell = row.CreateCell(i);
  5396. }
  5397. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  5398. fontRed.CloneStyleFrom(cell.CellStyle);
  5399. IFont Font = workbook.CreateFont(); // 创建字体
  5400. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  5401. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5402. fontRed.SetFont(Font);
  5403. byte[] rgb = new byte[3] { 255, 242, 204 };
  5404. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  5405. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  5406. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  5407. if (workbook is XSSFWorkbook)
  5408. {
  5409. BackgroundColor255_242_204.FillForegroundColor = 0;
  5410. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  5411. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  5412. }
  5413. else
  5414. {
  5415. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  5416. }
  5417. if (i == 1 || i > 6)
  5418. {
  5419. if (i > 6)
  5420. {
  5421. fontRed.FillForegroundColor = 0;
  5422. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  5423. fontRed.FillPattern = FillPattern.SolidForeground;
  5424. }
  5425. cell.CellStyle = fontRed;
  5426. }
  5427. if (i > 2 && i < 7)
  5428. {
  5429. cell.CellStyle = BackgroundColor255_242_204;
  5430. }
  5431. cell.SetCellValue(setCellValue); //写入单元格
  5432. }
  5433. if (overspendSoure.ContainsKey(thisSid)) {
  5434. var overspendId = overspendSoure[thisSid];
  5435. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  5436. }
  5437. cloneRowFn();
  5438. existsId.Add(new CarCompare
  5439. {
  5440. DataPrice = item.DatePrice.ObjToDate(),
  5441. Sid = item.SId
  5442. });
  5443. }
  5444. if (item.Equals(lastElem))
  5445. {
  5446. //合并小计行
  5447. //创建合并区域的实例
  5448. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  5449. rowStartIndex, // 起始行索引(0-based)
  5450. rowStartIndex, // 结束行索引(0-based)
  5451. 0, // 起始列索引(0-based)
  5452. 3 // 结束列索引(0-based)
  5453. );
  5454. sheet.AddMergedRegion(cellRangeAddress);
  5455. var CellStyle = workbook.CreateCellStyle();
  5456. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5457. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  5458. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  5459. for (int i = 0; i <= clounmCount; i++)
  5460. {
  5461. if (i > 6)
  5462. {
  5463. var CellStyle1 = workbook.CreateCellStyle();
  5464. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  5465. IFont Font = workbook.CreateFont(); // 创建字体
  5466. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  5467. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  5468. CellStyle1.SetFont(Font);
  5469. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  5470. }
  5471. else
  5472. {
  5473. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  5474. }
  5475. }
  5476. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  5477. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  5478. //超时合计
  5479. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  5480. //超时数
  5481. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  5482. //超时合计费用
  5483. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  5484. cloneRowFn();
  5485. // 创建合并区域的实例
  5486. cellRangeAddress = new CellRangeAddress(
  5487. rowStartIndex, // 起始行索引(0-based)
  5488. rowStartIndex, // 结束行索引(0-based)
  5489. 0, // 起始列索引(0-based)
  5490. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  5491. );
  5492. // 添加合并区域
  5493. sheet.AddMergedRegion(cellRangeAddress);
  5494. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  5495. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  5496. }
  5497. }
  5498. mergeRow();
  5499. // 保存修改后的Excel文件到新文件
  5500. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  5501. // new FileStream(newFilePath, FileMode.CreateNew)
  5502. using (var stream = new MemoryStream())
  5503. {
  5504. workbook.Write(stream, true);
  5505. stream.Flush();
  5506. stream.Seek(0, SeekOrigin.Begin);
  5507. MemoryStream memoryStream = new MemoryStream();
  5508. stream.CopyTo(memoryStream);
  5509. memoryStream.Seek(0, SeekOrigin.Begin);
  5510. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  5511. }
  5512. workbook.Close();
  5513. workbook.Dispose();
  5514. }
  5515. catch (Exception ex)
  5516. {
  5517. jw.Msg = "出现异常!" + ex.Message;
  5518. return Ok(jw);
  5519. }
  5520. }
  5521. if (Zips.Count > 0)
  5522. {
  5523. IOOperatorHelper io = new IOOperatorHelper();
  5524. var byts = io.ConvertZipStream(Zips);
  5525. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  5526. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  5527. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  5528. }
  5529. else
  5530. {
  5531. jw.Msg = "暂无生成文件!";
  5532. }
  5533. return Ok(jw);
  5534. }
  5535. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  5536. {
  5537. string outStr = string.Empty;
  5538. switch (i)
  5539. {
  5540. case 0:
  5541. outStr = arr[0].SidName;
  5542. break;
  5543. case 1:
  5544. outStr = arr[0].DataPriceStr;
  5545. break;
  5546. case 2:
  5547. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  5548. break;
  5549. case 4:
  5550. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  5551. break;
  5552. case 7:
  5553. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5554. {
  5555. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  5556. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  5557. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  5558. }
  5559. break;
  5560. case 8:
  5561. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5562. {
  5563. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  5564. }
  5565. break;
  5566. case 9:
  5567. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5568. {
  5569. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  5570. }
  5571. break;
  5572. case 10:
  5573. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  5574. {
  5575. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  5576. }
  5577. break;
  5578. }
  5579. return outStr;
  5580. }
  5581. #region OP行程单
  5582. /// <summary>
  5583. /// OP行程单初始化
  5584. /// </summary>
  5585. /// <param name="dto"></param>
  5586. /// <returns></returns>
  5587. [HttpPost]
  5588. public IActionResult InitOpTravel(InitOpTravelDto dto)
  5589. {
  5590. var jw = JsonView(false);
  5591. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  5592. var group = groupList.First();
  5593. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  5594. if (group == null)
  5595. {
  5596. jw.Msg = "暂无团组!";
  5597. return Ok(jw);
  5598. }
  5599. group = groupList.Find(x => x.Id == diid);
  5600. if (group == null)
  5601. {
  5602. jw.Msg = "请输入正确的团组ID!";
  5603. return Ok(jw);
  5604. }
  5605. string city = string.Empty;
  5606. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  5607. if (blackCode.Count > 0)
  5608. {
  5609. var black = blackCode.First();
  5610. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  5611. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  5612. if (blackSp.Length > 0)
  5613. {
  5614. try
  5615. {
  5616. var cityArrCode = new List<string>(20);
  5617. foreach (var item in blackSp)
  5618. {
  5619. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  5620. var IndexSelect = itemSp[2];
  5621. var cityArrCodeLength = cityArrCode.Count - 1;
  5622. var startCity = IndexSelect.Substring(0, 3);
  5623. if (cityArrCodeLength > 0)
  5624. {
  5625. var arrEndCity = cityArrCode[cityArrCodeLength];
  5626. if (arrEndCity != startCity)
  5627. {
  5628. cityArrCode.Add(startCity.ToUpper());
  5629. }
  5630. }
  5631. else
  5632. {
  5633. cityArrCode.Add(startCity.ToUpper());
  5634. }
  5635. var endCity = IndexSelect.Substring(3, 3);
  5636. cityArrCode.Add(endCity.ToUpper());
  5637. }
  5638. var cityThree = string.Empty;
  5639. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  5640. cityThree = cityThree.TrimEnd(',');
  5641. if (string.IsNullOrWhiteSpace(cityThree))
  5642. {
  5643. throw new
  5644. Exception("error");
  5645. }
  5646. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  5647. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  5648. foreach (var item in cityArrCode)
  5649. {
  5650. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  5651. if (find != null)
  5652. {
  5653. city += find.City + "/";
  5654. }
  5655. else
  5656. {
  5657. city += item + "三字码未收入/";
  5658. }
  5659. }
  5660. city = city.TrimEnd('/');
  5661. }
  5662. catch (Exception e)
  5663. {
  5664. city = "黑屏代码格式不正确!";
  5665. }
  5666. }
  5667. }
  5668. else
  5669. {
  5670. city = "未录入黑屏代码";
  5671. }
  5672. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  5673. {
  5674. Date = x.Date,
  5675. Days = x.Days,
  5676. Diffgroup = x.Diffgroup,
  5677. Diid = x.Diid,
  5678. Traffic_First = x.Traffic_First,
  5679. Traffic_Second = x.Traffic_Second,
  5680. Trip = x.Trip,
  5681. WeekDay = x.WeekDay,
  5682. Id = x.Id
  5683. }).ToList();
  5684. jw.Data = new
  5685. {
  5686. groupList = groupList.Select(x => new
  5687. {
  5688. x.Id,
  5689. x.TeamName,
  5690. x.TourCode
  5691. }).ToList(),
  5692. groupInfo = new
  5693. {
  5694. group.VisitDays,
  5695. group.TourCode,
  5696. group.VisitPNumber,
  5697. group.TeamName,
  5698. city
  5699. },
  5700. OpTravelList
  5701. };
  5702. jw.Code = 200;
  5703. jw.Msg = "操作成功!";
  5704. return Ok(jw);
  5705. }
  5706. /// <summary>
  5707. /// 删除团组行程单
  5708. /// </summary>
  5709. /// <returns></returns>
  5710. [HttpPost]
  5711. public IActionResult DelTravel(DelOpTravelDto dto)
  5712. {
  5713. var jw = JsonView(false);
  5714. if (dto.UserId <= 0 || dto.Diid <= 0)
  5715. {
  5716. jw.Msg = "请输入正确的参数!";
  5717. return Ok(jw);
  5718. }
  5719. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  5720. .SetColumns(x => new Grp_TravelList
  5721. {
  5722. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  5723. DeleteUserId = dto.UserId,
  5724. IsDel = 1,
  5725. }).ExecuteCommand();
  5726. jw = JsonView(true);
  5727. return Ok(jw);
  5728. }
  5729. /// <summary>
  5730. /// 行程单保存
  5731. /// </summary>
  5732. /// <returns></returns>
  5733. [HttpPost]
  5734. public IActionResult TravelSave(TravelSaveDto dto)
  5735. {
  5736. var jw = JsonView(false);
  5737. if (dto.Arr.Count > 0)
  5738. {
  5739. try
  5740. {
  5741. _sqlSugar.BeginTran();
  5742. foreach (var item in dto.Arr)
  5743. {
  5744. if (item.Id == 0)
  5745. {
  5746. throw new Exception("请传入正确的Id");
  5747. }
  5748. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  5749. .SetColumns(x => new Grp_TravelList
  5750. {
  5751. Trip = item.Trip
  5752. }).ExecuteCommand();
  5753. }
  5754. _sqlSugar.CommitTran();
  5755. jw = JsonView(true);
  5756. }
  5757. catch (Exception ex)
  5758. {
  5759. _sqlSugar.RollbackTran();
  5760. jw.Msg = "程序异常!" + ex.Message;
  5761. }
  5762. }
  5763. else
  5764. {
  5765. jw.Msg = "请传入正确的参数!";
  5766. }
  5767. return Ok(jw);
  5768. }
  5769. /// <summary>
  5770. /// 导出行程单
  5771. /// </summary>
  5772. /// <param name="dto"></param>
  5773. /// <returns></returns>
  5774. [HttpPost]
  5775. public IActionResult ExportTravel(InitOpTravelDto dto)
  5776. {
  5777. var jw = JsonView(false);
  5778. //数据源
  5779. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  5780. int diid = 0;
  5781. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  5782. if (Find == null)
  5783. {
  5784. jw.Msg = "请选择正确的团组!";
  5785. return Ok(jw);
  5786. }
  5787. else
  5788. {
  5789. diid = Find.Id;
  5790. }
  5791. DataTable dtBlack = null;
  5792. try
  5793. {
  5794. dtBlack = GetTableByBlackCode(diid);
  5795. }
  5796. catch (Exception)
  5797. {
  5798. jw.Msg = "机票黑屏代码有误!";
  5799. return Ok(jw);
  5800. }
  5801. string CityStr1 = "";
  5802. List<string> countriesList = new List<string>();
  5803. List<string> cityList = new List<string>();
  5804. string countriesIntroduction = "";
  5805. string cityIntroduction = "";
  5806. string timeDifference = "";
  5807. string currExchangeRate = "";
  5808. string txt_itemPrepare = "";
  5809. string txt_specialReminder = "";
  5810. string txt_cGPrecautions = "";
  5811. string txt_yGCG = "";
  5812. string txt_conduct = "";
  5813. string txt_commonEnglish = "";
  5814. if (dtBlack == null && (dtBlack.Rows[0]["Day"] == null || dtBlack.Rows[0]["Day"].ToString() == ""))
  5815. {
  5816. //提示
  5817. //PublicCode.GetAlertMsg(this, GetType(), dt.Rows[dt.Rows.Count - 1]["Error"].ToString());
  5818. }
  5819. else
  5820. {
  5821. //创建三字码示例
  5822. Res_ThreeCode t = new Res_ThreeCode();
  5823. //城市缓存
  5824. string city = "";
  5825. //出访城市
  5826. for (int i = 0; i < dtBlack.Rows.Count; i++)
  5827. {
  5828. if ((i + 1) < dtBlack.Rows.Count && dtBlack.Rows[i]["Three"].ToString() == dtBlack.Rows[i + 1]["Three"].ToString())
  5829. {
  5830. continue;
  5831. }
  5832. if (dtBlack.Rows.Count > 0 && (dtBlack.Rows[i]["Three"].ToString() != null && dtBlack.Rows[i]["Three"].ToString() != ""))
  5833. {
  5834. //出发城市
  5835. string cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(0, 3);
  5836. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5837. if (t != null)
  5838. {
  5839. city = city + "/" + t.City;
  5840. }
  5841. else
  5842. {
  5843. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5844. }
  5845. if (i == dtBlack.Rows.Count - 1)
  5846. {
  5847. //抵达城市
  5848. cityTemp = dtBlack.Rows[i]["Three"].ToString().Replace("/", string.Empty).Substring(3, 3);
  5849. t = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three == cityTemp && x.IsDel == 0);
  5850. if (t != null)
  5851. {
  5852. city = city + "/" + t.City;
  5853. }
  5854. else
  5855. {
  5856. city = city + "/【" + cityTemp + "未收录,请联系机票同事录入】";
  5857. }
  5858. }
  5859. }
  5860. }
  5861. if (city != "" && city != null)
  5862. {
  5863. string[] cityStr2 = city.Split('/');
  5864. string[] strs = cityStr2.Distinct().ToArray(); ;
  5865. string str = "";
  5866. foreach (var s in strs)
  5867. {
  5868. str += s + "/";
  5869. }
  5870. str = str.TrimStart('/');
  5871. str = str.TrimEnd('/');
  5872. //lblTourCity.Text = "去重前:" + city.TrimStart('/') + "\n 去重后:" + str;
  5873. CityStr1 = city.TrimStart('/');
  5874. }
  5875. // 行程repeater
  5876. if (GetByDiid(diid).Count > 0)
  5877. {
  5878. _travelList = GetByDiid(diid).Where(x => x.Issel == 1 && x.IsDel == 0).ToList();
  5879. }
  5880. else
  5881. {
  5882. //生成该时间段日期
  5883. List<string> timeList = GetTimeListByDataTable(dtBlack);
  5884. if (timeList != null)
  5885. {
  5886. string[] str = new string[timeList.Count];
  5887. //rpData.DataSource = str;
  5888. //rpData.DataBind();
  5889. }
  5890. }
  5891. }
  5892. //创建数据源Table
  5893. DataTable dtSource = new DataTable();
  5894. dtSource.Columns.Add("Days", typeof(string));
  5895. dtSource.Columns.Add("Date", typeof(string));
  5896. dtSource.Columns.Add("Week", typeof(string));
  5897. dtSource.Columns.Add("Traffic", typeof(string));
  5898. dtSource.Columns.Add("Trip", typeof(string));
  5899. //获取数据,放到datatable
  5900. foreach (var item in _travelList)
  5901. {
  5902. DataRow dr = dtSource.NewRow();
  5903. dr["Days"] = item.Days;
  5904. dr["Date"] = item.Date;
  5905. dr["Week"] = item.WeekDay;
  5906. dr["Traffic"] = item.Traffic_First
  5907. + "\r\n"
  5908. + item.Traffic_Second;
  5909. if (item.Trip.Replace("(此地区为黄热病地区,请注意打疫苗)", "").Length < 15)
  5910. {
  5911. item.Trip += @"
  5912. 08:00 早餐于酒店;
  5913. 09:00 公务活动;
  5914. 10:30 公务活动;
  5915. 12:00 午餐于当地餐厅;
  5916. 14:00 公务活动;
  5917. 16:00 公务活动;
  5918. 18:00 晚餐于当地餐厅;
  5919. 19:00 入住酒店休息;";
  5920. }
  5921. dr["Trip"] = item.Trip;
  5922. dtSource.Rows.Add(dr);
  5923. }
  5924. //lblTeamName.Text = di.TourCode;
  5925. //lblVisitDays.Text = di.VisitDays.ToString();
  5926. //lblVisitDays2.Text = di.VisitDays.ToString();
  5927. //lblPNumber.Text = di.VisitPNumber.ToString();
  5928. //lblGroup.Text = di.TeamName.ToString();
  5929. Dictionary<string, string> dic = new Dictionary<string, string>();
  5930. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  5931. dic.Add("City", CityStr1);
  5932. dic.Add("Days", Find.VisitDays.ToString());
  5933. dic.Add("DeleCode", Find.TourCode);
  5934. dic.Add("Pnum", Find.VisitPNumber.ToString());
  5935. dic.Add("Pnum2", Find.VisitPNumber.ToString());
  5936. List<Crm_DeleClient> leader = GetByDiidClient(Find.Id);
  5937. if (leader != null && leader.Count > 0)
  5938. {
  5939. dic.Add("Leader", GetByDiidClient(Find.Id)[0].LastName + GetByDiidClient(Find.Id)[0].FirstName);
  5940. }
  5941. else
  5942. {
  5943. dic.Add("Leader", "");
  5944. }
  5945. dic.Add("Pnum3", Find.VisitPNumber.ToString());
  5946. int UserId = 253;
  5947. dic.Add("OP", "");
  5948. dic.Add("OPTel", "");
  5949. //dic.Add("OP", "OP姓名");
  5950. //dic.Add("OPTel", "OP手机号码");
  5951. string countriesStr = "";
  5952. countriesList.ForEach(s => countriesStr += s + "、");
  5953. countriesStr = countriesStr.TrimEnd('、');
  5954. string cityStr = "";
  5955. cityList.ForEach(s => cityStr += s + "、");
  5956. cityStr = cityStr.TrimEnd('、');
  5957. //下方数据
  5958. dic.Add("selCountries", countriesStr == null ? "" : countriesStr);
  5959. dic.Add("selCity", cityStr == null ? "" : cityStr);
  5960. dic.Add("countriesIntroduction", countriesIntroduction == null ? "" : countriesIntroduction);
  5961. dic.Add("CityIntroduction", cityIntroduction == null ? "" : cityIntroduction);
  5962. dic.Add("timeDifference", timeDifference == null ? "" : timeDifference);
  5963. dic.Add("currExchangeRate", currExchangeRate == null ? "" : currExchangeRate);
  5964. dic.Add("temperature", "");
  5965. dic.Add("txt_itemPrepare", txt_itemPrepare == null ? "" : txt_itemPrepare);
  5966. dic.Add("txt_specialReminder", txt_specialReminder == null ? "" : txt_specialReminder);
  5967. dic.Add("txt_cGPrecautions", txt_cGPrecautions == null ? "" : txt_cGPrecautions);
  5968. dic.Add("txt_yGCG", txt_yGCG == null ? "" : txt_yGCG);
  5969. dic.Add("txt_conduct", txt_conduct == null ? "" : txt_conduct);
  5970. dic.Add("txt_commonEnglish", txt_commonEnglish == null ? "" : txt_commonEnglish);
  5971. //模板路径
  5972. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  5973. //载入模板
  5974. Document doc = null;
  5975. DocumentBuilder builder = null;
  5976. try
  5977. {
  5978. //载入模板
  5979. doc = new Document(tempPath);
  5980. builder = new DocumentBuilder(doc);
  5981. }
  5982. catch (Exception)
  5983. {
  5984. jw.Msg = "模板位置不存在!";
  5985. return Ok(jw);
  5986. }
  5987. foreach (var key in dic.Keys)
  5988. {
  5989. Bookmark bookmark = doc.Range.Bookmarks[key];
  5990. if (bookmark != null)
  5991. {
  5992. builder.MoveToBookmark(key);
  5993. builder.Write(dic[key]);
  5994. }
  5995. }
  5996. //获取word里所有表格
  5997. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5998. //获取所填表格的序数
  5999. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6000. try
  6001. {
  6002. //循环赋值
  6003. for (int i = 0; i < dtSource.Rows.Count; i++)
  6004. {
  6005. builder.MoveToCell(0, i + 1, 0, 0);
  6006. builder.Write(dtSource.Rows[i]["Days"].ToString());
  6007. builder.MoveToCell(0, i + 1, 1, 0);
  6008. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  6009. builder.MoveToCell(0, i + 1, 2, 0);
  6010. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  6011. var trip = dtSource.Rows[i]["Trip"].ToString();
  6012. builder.MoveToCell(0, i + 1, 3, 0);
  6013. builder.Write(trip);
  6014. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  6015. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6016. // 获取特定索引的段落
  6017. Paragraph paragraph = (Paragraph)paragraphs[0];
  6018. Run run = paragraph.Runs[0];
  6019. Aspose.Words.Font font = run.Font;
  6020. font.Name = "黑体";
  6021. //设置双休红色
  6022. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  6023. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  6024. paragraph = (Paragraph)paragraphs[1];
  6025. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  6026. {
  6027. run = paragraph.Runs[0];
  6028. font = run.Font;
  6029. font.Color = Color.Red;
  6030. }
  6031. }
  6032. }
  6033. catch (Exception ex)
  6034. {
  6035. }
  6036. //删除多余行
  6037. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  6038. {
  6039. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  6040. }
  6041. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  6042. if (!Directory.Exists(savePath))
  6043. {
  6044. try
  6045. {
  6046. Directory.CreateDirectory(savePath);
  6047. }
  6048. catch
  6049. {
  6050. }
  6051. }
  6052. string path = savePath + Find.TeamName + "出访日程.docx";
  6053. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程.docx";
  6054. try
  6055. {
  6056. doc.Save(path, Aspose.Words.SaveFormat.Doc);
  6057. jw = JsonView(true, "导出成功", ftpPath);
  6058. }
  6059. catch (Exception)
  6060. {
  6061. jw = JsonView(false);
  6062. }
  6063. return Ok(jw);
  6064. }
  6065. /// <summary>
  6066. ///根据机票黑屏代码整理DataTable
  6067. /// </summary>
  6068. /// <param name="diid"></param>
  6069. /// <returns></returns>
  6070. DataTable GetTableByBlackCode(int diid)
  6071. {
  6072. //黑屏代码信息
  6073. List<Air_TicketBlackCode> listcode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.DiId == diid && x.IsDel == 0).ToList();
  6074. //测试数据为序号,航班号,起飞日期,三字码,起飞时刻,到达时刻,出发航站楼,到达航站楼,机型,飞行时间
  6075. //1.3U8391 TU17NOV CTUCAI 0220 0715 T1 T2 330 10H55M
  6076. DataTable dt = new DataTable();
  6077. dt.Columns.Add("Fliagtcode", typeof(string)); //航班号
  6078. dt.Columns.Add("Date", typeof(string));//起飞日期
  6079. dt.Columns.Add("Three", typeof(string));//三字码
  6080. dt.Columns.Add("StartTime", typeof(string));//起飞时刻
  6081. dt.Columns.Add("EndTime", typeof(string));//到达时刻
  6082. dt.Columns.Add("StartBuilding", typeof(string));//出发航站楼
  6083. dt.Columns.Add("EndBuilding", typeof(string));//到达航站楼
  6084. dt.Columns.Add("AirModel", typeof(string)); //机型
  6085. dt.Columns.Add("FlightTime", typeof(string));//飞行时间
  6086. dt.Columns.Add("Day", typeof(string));//整理的起飞日期;作为排序依据
  6087. dt.Columns.Add("ArrivedDate", typeof(string));//整理的到达日期
  6088. dt.Columns.Add("Error", typeof(string));//整理的到达日期
  6089. dt.Columns.Add("Sign", typeof(string));//标识:0表示为原生黑屏代码、1表示“+1”新增的黑屏代码
  6090. //判断是否录入黑屏代码
  6091. if (listcode.Count() == 0 || listcode == null)
  6092. {
  6093. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "黑屏代码未录入!", null);
  6094. }
  6095. else
  6096. {
  6097. //读取单段黑屏代码
  6098. for (int i = 0; i < listcode.Count; i++)
  6099. {
  6100. //去除序号
  6101. string[] CodeList = Regex.Split(listcode[i].BlackCode, "\\d+\\.", RegexOptions.IgnoreCase);
  6102. //去除多余空格,方法一Linq扩展方法
  6103. CodeList = CodeList.Where(str => str != "").ToArray();
  6104. CodeList = CodeList.Where(str => str != " ").ToArray();
  6105. //年
  6106. int year = Convert.ToInt32(DateTime.Now.Year.ToString());
  6107. //读取单条黑屏代码
  6108. for (int j = 0; j < CodeList.Count(); j++)
  6109. {
  6110. //去除多余空格,方法二使用Split()方法进行分割,分割有一个选项是RemoveEmptyEntries
  6111. CodeList[j] = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty).TrimStart().TrimEnd();
  6112. string[] Info = CodeList[j].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6113. //string[] Info = CodeList[j].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6114. // .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6115. //去除多余空格
  6116. Info = Info.Where(str => str != "").ToArray();
  6117. Info = Info.Where(str => str != " ").ToArray();
  6118. //判断黑屏代码是否正确拆分; 理应拆成9段
  6119. if (Info.Count() < 9)
  6120. {
  6121. dt.Rows.Add(null, null, null, null, null, null, null, null, null, null, null, "本团组第" + (i + 1) + "段黑屏代码中第" + (j + 1) + " 条有误,请联系机票同事核对", null);
  6122. }
  6123. else
  6124. {
  6125. try
  6126. {
  6127. //月
  6128. int month = Convert.ToInt32(GetLonger(Info[1].Substring(4, 3)));
  6129. //日
  6130. int day = Convert.ToInt32(Info[1].Substring(2, 2));
  6131. #region 逐一比较月份,判断是否翻年;逐一比较三字码顶真,判断是否跑错机场
  6132. if (j > 0)
  6133. {
  6134. string[] Temp = CodeList[j - 1].Replace("\r\n", string.Empty).Replace("\\r\\n", string.Empty)
  6135. .TrimStart().TrimEnd().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  6136. Temp = Temp.Where(str => str != "").ToArray();
  6137. Temp = Temp.Where(str => str != " ").ToArray();
  6138. int monthTemp = Convert.ToInt32(GetLonger(Temp[1].Substring(4, 3)));
  6139. // 如果相邻月份之差小于0,则证明次一条年份需+1
  6140. if (month - monthTemp < 0)
  6141. {
  6142. year = year + 1;
  6143. }
  6144. //如果相邻代码三字码不顶真,提醒
  6145. string FootThree = Temp[2].Substring(3, 3);
  6146. string HeadThree = Info[2].Substring(0, 3);
  6147. if (FootThree != HeadThree)
  6148. {
  6149. //DelegationInfoService s = new DelegationInfoService();
  6150. //UsersService us = new UsersService();
  6151. //GroupsTaskAssignmentService gts = new GroupsTaskAssignmentService();
  6152. //77 行程
  6153. List<Grp_GroupsTaskAssignment> list2 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 77 && x.DIId == diid && x.IsDel == 0).ToList();
  6154. foreach (var temp in list2)
  6155. {
  6156. //if (temp.UId != 21)
  6157. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6158. // "黑屏代码提醒",
  6159. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6160. }
  6161. //85 机票预订
  6162. List<Grp_GroupsTaskAssignment> list6 = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(x => x.CTId == 85 && x.DIId == diid && x.IsDel == 0).ToList();
  6163. foreach (var temp in list6)
  6164. {
  6165. //if (temp.UId != 21)
  6166. //SendAndReturn(us.GetUsersByID(temp.UId).Email,
  6167. // "黑屏代码提醒",
  6168. // s.GetDelegationInfoByID(diid).TeamName + "的机票黑屏代码中,相邻航段的三字码不连续,请查看!");
  6169. }
  6170. }
  6171. }
  6172. #endregion
  6173. #region 判断到达日期是否需要加1
  6174. if (Info[4].Contains("+"))
  6175. {
  6176. //日期+1
  6177. day = day + 1;
  6178. //判断是否进入下一月
  6179. if (day > Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year)))
  6180. {
  6181. day = day - Convert.ToInt32(GetDaysByMonth(Info[1].Substring(4, 3), year));
  6182. month = month + 1;
  6183. //判断是否进入下一年
  6184. if (month > 12)
  6185. {
  6186. month = month - 12;
  6187. year = year + 1;
  6188. }
  6189. }
  6190. //月份整理格式
  6191. string monthTemp = month.ToString();
  6192. if (month < 10)
  6193. {
  6194. monthTemp = "0" + monthTemp;
  6195. }
  6196. //日期整理格式
  6197. string daytemp = day.ToString();
  6198. if (day < 10)
  6199. {
  6200. daytemp = "0" + daytemp;
  6201. }
  6202. string temp = Info[4].Split('+')[0];
  6203. //添加起飞数据
  6204. dt.Rows.Add(Info[0],
  6205. Info[1],
  6206. Info[2],
  6207. Info[3],
  6208. temp,
  6209. Info[5],
  6210. Info[6],
  6211. Info[7],
  6212. Info[8],
  6213. year + "-" + GetLonger(Info[1].Substring(4, 3)) + "-" + Info[1].Substring(2, 2),
  6214. year + "-" + monthTemp + "-" + daytemp,
  6215. "",
  6216. "0");
  6217. //加1天,添加到达数据
  6218. dt.Rows.Add(Info[0],
  6219. Info[1].Replace(Info[1].Substring(2, 2), daytemp),
  6220. Info[2],
  6221. Info[3],
  6222. temp,
  6223. Info[5],
  6224. Info[6],
  6225. Info[7],
  6226. Info[8],
  6227. year + "-" + monthTemp + "-" + daytemp,
  6228. year + "-" + monthTemp + "-" + daytemp,
  6229. "",
  6230. "1");
  6231. }
  6232. else
  6233. {
  6234. //月份整理格式
  6235. string monthTemp = month.ToString();
  6236. if (month < 10)
  6237. {
  6238. monthTemp = "0" + monthTemp;
  6239. }
  6240. //日期整理格式
  6241. string daytemp = day.ToString();
  6242. if (day < 10)
  6243. {
  6244. daytemp = "0" + daytemp;
  6245. }
  6246. dt.Rows.Add(Info[0],
  6247. Info[1],
  6248. Info[2],
  6249. Info[3],
  6250. Info[4],
  6251. Info[5],
  6252. Info[6],
  6253. Info[7],
  6254. Info[8],
  6255. year + "-" + monthTemp + "-" + daytemp,
  6256. year + "-" + monthTemp + "-" + daytemp,
  6257. "",
  6258. "0");
  6259. }
  6260. #endregion
  6261. }
  6262. catch (Exception ex)
  6263. {
  6264. string exstr = ex.Message.ToString();
  6265. }
  6266. }
  6267. }
  6268. //排序
  6269. dt.DefaultView.Sort = "Day asc";
  6270. dt = dt.DefaultView.ToTable();
  6271. }
  6272. }
  6273. return dt;
  6274. }
  6275. /// <summary>
  6276. /// 根据团组编号查询信息
  6277. /// </summary>
  6278. /// <returns>返回空或者对象信息</returns>
  6279. List<Grp_TravelList> GetByDiid(int Diid)
  6280. {
  6281. //调用获取单个对象的方法
  6282. return _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == Diid && x.IsDel == 0).ToList();
  6283. }
  6284. /// <summary>
  6285. /// 20210816
  6286. /// 根据datatable生成某一时间段的日期
  6287. /// </summary>
  6288. /// <param name="dt">黑屏代码生成的datatable</param>
  6289. /// <returns></returns>
  6290. List<string> GetTimeListByDataTable(DataTable dt)
  6291. {
  6292. if (dt.Rows[0]["Day"].ToString() != "")
  6293. {
  6294. DateTime datestart = Convert.ToDateTime(dt.Rows[0]["Day"].ToString());
  6295. DateTime dateend = Convert.ToDateTime(dt.Rows[dt.Rows.Count - 1]["ArrivedDate"].ToString());
  6296. List<string> timeList = new List<string>();
  6297. while (datestart <= dateend)
  6298. {
  6299. timeList.Add(datestart.ToString("yyyy-MM-dd"));
  6300. datestart = datestart.AddDays(1);
  6301. }
  6302. return timeList;
  6303. }
  6304. return null;
  6305. }
  6306. /// <summary>
  6307. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  6308. /// </summary>
  6309. /// <param name="num"></param>
  6310. /// <returns></returns>
  6311. string GetNum(string num)
  6312. {
  6313. string str = "";
  6314. switch (num)
  6315. {
  6316. case "1":
  6317. str = "一";
  6318. break;
  6319. case "2":
  6320. str = "二";
  6321. break;
  6322. case "3":
  6323. str = "三";
  6324. break;
  6325. case "4":
  6326. str = "四";
  6327. break;
  6328. case "5":
  6329. str = "五";
  6330. break;
  6331. case "6":
  6332. str = "六";
  6333. break;
  6334. case "7":
  6335. str = "七";
  6336. break;
  6337. case "8":
  6338. str = "八";
  6339. break;
  6340. case "9":
  6341. str = "九";
  6342. break;
  6343. case "10":
  6344. str = "十";
  6345. break;
  6346. case "11":
  6347. str = "十一";
  6348. break;
  6349. case "12":
  6350. str = "十二";
  6351. break;
  6352. case "一":
  6353. str = "1";
  6354. break;
  6355. case "二":
  6356. str = "2";
  6357. break;
  6358. case "三":
  6359. str = "3";
  6360. break;
  6361. case "四":
  6362. str = "4";
  6363. break;
  6364. case "五":
  6365. str = "5";
  6366. break;
  6367. case "六":
  6368. str = "6";
  6369. break;
  6370. case "七":
  6371. str = "7";
  6372. break;
  6373. case "八":
  6374. str = "8";
  6375. break;
  6376. case "九":
  6377. str = "9";
  6378. break;
  6379. case "十":
  6380. str = "10";
  6381. break;
  6382. case "十一":
  6383. str = "11";
  6384. break;
  6385. case "十二":
  6386. str = "12";
  6387. break;
  6388. }
  6389. return str;
  6390. }
  6391. List<Crm_DeleClient> GetByDiidClient(int DIID)
  6392. {
  6393. return _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.DiId == DIID && x.IsDel == 0).ToList();
  6394. }
  6395. /// <summary>
  6396. /// 根据星期,月份的缩写,转换成数字或者全称
  6397. /// 根据币种中文名称返回币种代码
  6398. /// 根据数字返回机型型号【2、3开头的就是空客,比如空客320,7开头的就是波音,比如波音777】
  6399. /// 20210903贾文滔
  6400. /// </summary>
  6401. /// <param name="startDate"></param>
  6402. /// <param name="endDate"></param>
  6403. /// <returns></returns>
  6404. string GetLonger(string temp)
  6405. {
  6406. string str = "";
  6407. switch (temp.ToUpper())
  6408. {
  6409. case "美元":
  6410. str = "USD";
  6411. break;
  6412. case "日元":
  6413. str = "JPY";
  6414. break;
  6415. case "英镑":
  6416. str = "GBP";
  6417. break;
  6418. case "欧元":
  6419. str = "EUR";
  6420. break;
  6421. case "港币":
  6422. str = "HKD";
  6423. break;
  6424. case "MO":
  6425. str = "星期一";
  6426. break;
  6427. case "TU":
  6428. str = "星期二";
  6429. break;
  6430. case "WE":
  6431. str = "星期三";
  6432. break;
  6433. case "TH":
  6434. str = "星期四";
  6435. break;
  6436. case "FR":
  6437. str = "星期五";
  6438. break;
  6439. case "SA":
  6440. str = "星期六";
  6441. break;
  6442. case "SU":
  6443. str = "星期天";
  6444. break;
  6445. case "JAN":
  6446. str = "01";
  6447. break;
  6448. case "FEB":
  6449. str = "02";
  6450. break;
  6451. case "MAR":
  6452. str = "03";
  6453. break;
  6454. case "APR":
  6455. str = "04";
  6456. break;
  6457. case "MAY":
  6458. str = "05";
  6459. break;
  6460. case "JUN":
  6461. str = "06";
  6462. break;
  6463. case "JUL":
  6464. str = "07";
  6465. break;
  6466. case "AUG":
  6467. str = "08";
  6468. break;
  6469. case "SEP":
  6470. str = "09";
  6471. break;
  6472. case "OCT":
  6473. str = "10";
  6474. break;
  6475. case "NOV":
  6476. str = "11";
  6477. break;
  6478. case "DEC":
  6479. str = "12";
  6480. break;
  6481. case "MONDAY":
  6482. str = "星期一";
  6483. break;
  6484. case "TUESDAY":
  6485. str = "星期二";
  6486. break;
  6487. case "WEDNESDAY":
  6488. str = "星期三";
  6489. break;
  6490. case "THURSDAY":
  6491. str = "星期四";
  6492. break;
  6493. case "FRIDAY":
  6494. str = "星期五";
  6495. break;
  6496. case "SATURDAY":
  6497. str = "星期六";
  6498. break;
  6499. case "SUNDAY":
  6500. str = "星期日";
  6501. break;
  6502. case "01":
  6503. str = "JAN";
  6504. break;
  6505. case "02":
  6506. str = "FEB";
  6507. break;
  6508. case "03":
  6509. str = "MAR";
  6510. break;
  6511. case "04":
  6512. str = "APR";
  6513. break;
  6514. case "05":
  6515. str = "MAY";
  6516. break;
  6517. case "06":
  6518. str = "JUN";
  6519. break;
  6520. case "07":
  6521. str = "JUL";
  6522. break;
  6523. case "08":
  6524. str = "AUG";
  6525. break;
  6526. case "09":
  6527. str = "SEP";
  6528. break;
  6529. case "10":
  6530. str = "OCT";
  6531. break;
  6532. case "11":
  6533. str = "NOV";
  6534. break;
  6535. case "12":
  6536. str = "DEC";
  6537. break;
  6538. case "2":
  6539. str = "空客A";
  6540. break;
  6541. case "3":
  6542. str = "空客A";
  6543. break;
  6544. case "7":
  6545. str = "波音";
  6546. break;
  6547. }
  6548. return str;
  6549. }
  6550. /// <summary>
  6551. /// 根据月份返回天数
  6552. /// </summary>
  6553. /// <param name="temp"></param>
  6554. /// <returns></returns>
  6555. string GetDaysByMonth(string Month, int year)
  6556. {
  6557. string str = "";
  6558. //判断是否是闰年
  6559. if (DateTime.IsLeapYear(year) == false)
  6560. {
  6561. switch (Month.ToUpper())
  6562. {
  6563. case "JAN":
  6564. str = "31";
  6565. break;
  6566. case "FEB":
  6567. str = "28";
  6568. break;
  6569. case "MAR":
  6570. str = "31";
  6571. break;
  6572. case "APR":
  6573. str = "30";
  6574. break;
  6575. case "MAY":
  6576. str = "31";
  6577. break;
  6578. case "JUN":
  6579. str = "30";
  6580. break;
  6581. case "JUL":
  6582. str = "31";
  6583. break;
  6584. case "AUG":
  6585. str = "31";
  6586. break;
  6587. case "SEP":
  6588. str = "30";
  6589. break;
  6590. case "OCT":
  6591. str = "31";
  6592. break;
  6593. case "NOV":
  6594. str = "30";
  6595. break;
  6596. case "DEC":
  6597. str = "31";
  6598. break;
  6599. case "01":
  6600. str = "31";
  6601. break;
  6602. case "02":
  6603. str = "28";
  6604. break;
  6605. case "03":
  6606. str = "31";
  6607. break;
  6608. case "04":
  6609. str = "30";
  6610. break;
  6611. case "05":
  6612. str = "31";
  6613. break;
  6614. case "06":
  6615. str = "30";
  6616. break;
  6617. case "07":
  6618. str = "31";
  6619. break;
  6620. case "08":
  6621. str = "31";
  6622. break;
  6623. case "09":
  6624. str = "30";
  6625. break;
  6626. case "10":
  6627. str = "31";
  6628. break;
  6629. case "11":
  6630. str = "30";
  6631. break;
  6632. case "12":
  6633. str = "31";
  6634. break;
  6635. }
  6636. }
  6637. else
  6638. {
  6639. switch (Month.ToUpper())
  6640. {
  6641. case "JAN":
  6642. str = "31";
  6643. break;
  6644. case "FEB":
  6645. str = "29";
  6646. break;
  6647. case "MAR":
  6648. str = "31";
  6649. break;
  6650. case "APR":
  6651. str = "30";
  6652. break;
  6653. case "MAY":
  6654. str = "31";
  6655. break;
  6656. case "JUN":
  6657. str = "30";
  6658. break;
  6659. case "JUL":
  6660. str = "31";
  6661. break;
  6662. case "AUG":
  6663. str = "31";
  6664. break;
  6665. case "SEP":
  6666. str = "30";
  6667. break;
  6668. case "OCT":
  6669. str = "31";
  6670. break;
  6671. case "NOV":
  6672. str = "30";
  6673. break;
  6674. case "DEC":
  6675. str = "31";
  6676. break;
  6677. case "01":
  6678. str = "31";
  6679. break;
  6680. case "02":
  6681. str = "29";
  6682. break;
  6683. case "03":
  6684. str = "31";
  6685. break;
  6686. case "04":
  6687. str = "30";
  6688. break;
  6689. case "05":
  6690. str = "31";
  6691. break;
  6692. case "06":
  6693. str = "30";
  6694. break;
  6695. case "07":
  6696. str = "31";
  6697. break;
  6698. case "08":
  6699. str = "31";
  6700. break;
  6701. case "09":
  6702. str = "30";
  6703. break;
  6704. case "10":
  6705. str = "31";
  6706. break;
  6707. case "11":
  6708. str = "30";
  6709. break;
  6710. case "12":
  6711. str = "31";
  6712. break;
  6713. }
  6714. }
  6715. return str;
  6716. }
  6717. #endregion
  6718. #endregion
  6719. #region 团组成本
  6720. /// <summary>
  6721. /// 团组成本数据初始化
  6722. /// </summary>
  6723. /// <param name="dto"></param>
  6724. /// <returns></returns>
  6725. [HttpPost]
  6726. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  6727. {
  6728. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  6729. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  6730. WHEN COUNT(*) >= 0 THEN 'True'
  6731. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  6732. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  6733. ").ToList(); //团组列表
  6734. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  6735. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  6736. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  6737. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  6738. if (groupinfoValue != null)
  6739. {
  6740. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  6741. var spArr = new string[1] { countryArr };
  6742. if (countryArr.Contains("|"))
  6743. {
  6744. spArr = countryArr.Split("|");
  6745. }
  6746. else if (countryArr.Contains("、"))
  6747. {
  6748. spArr = countryArr.Split("、");
  6749. }
  6750. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  6751. {
  6752. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  6753. if (dbQueryCountry != null)
  6754. {
  6755. visaCountryInfoArr.Add(dbQueryCountry);
  6756. }
  6757. }
  6758. }
  6759. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  6760. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  6761. var create = _GroupCostRepository.
  6762. CreateGroupCostByBlackCode(dto.Diid);
  6763. if (groupCost.Count == 0 && create.Code == 0)
  6764. {
  6765. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  6766. }
  6767. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  6768. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  6769. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  6770. groupCostMap = groupCostMap.Select(x =>
  6771. {
  6772. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  6773. {
  6774. x.Date = dataForamt.ToString("yyyy-MM-dd");
  6775. }
  6776. return x;
  6777. }).ToList();
  6778. //GroupCostParameter.Add(new
  6779. // Grp_GroupCostParameter());
  6780. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  6781. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  6782. return Ok(JsonView(new
  6783. {
  6784. groupList,
  6785. groupInfo,
  6786. groupChecks,
  6787. groupCost = groupCostMap,
  6788. hotelNumber,
  6789. GroupCostParameter = GroupCostParameterMap,
  6790. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  6791. {
  6792. x.VisaCountry,
  6793. x.VisaPrice,
  6794. x.Id,
  6795. }).ToList(),
  6796. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  6797. blackCodeIsTrue = create.Code == 0 ? true : false,
  6798. hotelIsTrue = hotelIsTrue,
  6799. }));
  6800. }
  6801. /// <summary>
  6802. /// 团组成本信息保存
  6803. /// </summary>
  6804. /// <param name="dto"></param>
  6805. /// <returns></returns>
  6806. [HttpPost]
  6807. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  6808. {
  6809. if (dto.Diid <= 0 || dto.Userid <= 0)
  6810. {
  6811. return Ok(JsonView(false));
  6812. }
  6813. JsonView jw = null;
  6814. bool isTrue = false;
  6815. #region 复制团组成本
  6816. //if (dto.Diid == 2581)
  6817. //{
  6818. // dto.Diid = 2599;
  6819. // dto.CheckBoxs.ForEach(x =>
  6820. // {
  6821. // x.Diid = 2599;
  6822. // });
  6823. // dto.GroupCosts.ForEach(x =>
  6824. // {
  6825. // x.Diid = 2599;
  6826. // });
  6827. // dto.CostTypeHotelNumbers.ForEach(x =>
  6828. // {
  6829. // x.Diid = 2599;
  6830. // });
  6831. // dto.GroupCostParameters.ForEach(x =>
  6832. // {
  6833. // x.DiId = 2599;
  6834. // });
  6835. //}
  6836. #endregion
  6837. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  6838. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  6839. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  6840. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  6841. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  6842. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  6843. try
  6844. {
  6845. _sqlSugar.BeginTran();
  6846. isTrue = await _GroupCostRepository.
  6847. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  6848. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  6849. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  6850. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  6851. _sqlSugar.CommitTran();
  6852. jw = JsonView(true, "保存成功!", isTrue);
  6853. }
  6854. catch (Exception)
  6855. {
  6856. _sqlSugar.RollbackTran();
  6857. jw = JsonView(false);
  6858. }
  6859. return Ok(jw);
  6860. }
  6861. /// <summary>
  6862. /// 司兼导数据
  6863. /// </summary>
  6864. /// <param name="dto"></param>
  6865. /// <returns></returns>
  6866. [HttpPost]
  6867. public IActionResult GetCarGuides(CarGuidesDto dto)
  6868. {
  6869. JsonView jw = null;
  6870. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  6871. jw = JsonView(true, "获取成功!", Data);
  6872. return Ok(jw);
  6873. }
  6874. /// <summary>
  6875. /// 导游数据
  6876. /// </summary>
  6877. /// <param name="dto"></param>
  6878. /// <returns></returns>
  6879. [HttpPost]
  6880. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  6881. {
  6882. JsonView jw = null;
  6883. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  6884. // 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
  6885. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  6886. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  6887. jw = JsonView(true, "获取成功!", Data);
  6888. return Ok(jw);
  6889. }
  6890. /// <summary>
  6891. /// 成本车数据
  6892. /// </summary>
  6893. /// <param name="dto"></param>
  6894. /// <returns></returns>
  6895. [HttpPost]
  6896. public IActionResult GetCarInfo(CarGuidesDto dto)
  6897. {
  6898. JsonView jw = null;
  6899. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  6900. jw = JsonView(true, "获取成功!", Data);
  6901. return Ok(jw);
  6902. }
  6903. /// <summary>
  6904. /// 景点数据
  6905. /// </summary>
  6906. /// <param name="dto"></param>
  6907. /// <returns></returns>
  6908. [HttpPost]
  6909. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  6910. {
  6911. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  6912. return Ok(JsonView(true, "获取成功!", Data));
  6913. }
  6914. /// <summary>
  6915. /// 成本通知
  6916. /// </summary>
  6917. /// <param name="dto"></param>
  6918. /// <returns></returns>
  6919. [HttpPost]
  6920. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  6921. {
  6922. if (dto.Diid < 0)
  6923. {
  6924. return Ok(JsonView(false));
  6925. }
  6926. JsonView jw = null;
  6927. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  6928. if (GroupCostParameter != null)
  6929. {
  6930. int IsShare = 0;
  6931. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  6932. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  6933. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  6934. string msg = string.Empty;
  6935. if (isTrue)
  6936. {
  6937. if (IsShare == 0)
  6938. {
  6939. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  6940. }
  6941. else
  6942. {
  6943. #region 企微通知对应岗位用户
  6944. try
  6945. {
  6946. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  6947. }
  6948. catch (Exception ex)
  6949. {
  6950. }
  6951. #endregion
  6952. msg = "通知成功,其他模块操作人员可见此成本信息!";
  6953. }
  6954. jw = JsonView(isTrue, msg, new { IsShare });
  6955. }
  6956. else
  6957. {
  6958. msg = "修改失败!";
  6959. jw = JsonView(isTrue, msg);
  6960. }
  6961. }
  6962. else
  6963. {
  6964. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  6965. }
  6966. return Ok(jw);
  6967. }
  6968. /// <summary>
  6969. /// 导出收款账单
  6970. /// </summary>
  6971. /// <param name="dto"></param>
  6972. /// <returns></returns>
  6973. [HttpPost]
  6974. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  6975. {
  6976. if (dto.Diid == 0)
  6977. {
  6978. return Ok(JsonView(false, "请传递团组id"));
  6979. }
  6980. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  6981. if (deleInfo.Code != 0)
  6982. {
  6983. return Ok(JsonView(false, "团组信息查询失败!"));
  6984. }
  6985. var di = deleInfo.Data as DelegationInfoWebView;
  6986. if (di != null)
  6987. {
  6988. //文件名
  6989. string strFileName = di.TeamName + "-收款账单.doc";
  6990. //获取模板
  6991. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  6992. //载入模板
  6993. Document doc = new Document(tmppath);
  6994. decimal TotalPrice = 0.00M;
  6995. string itemStr = string.Empty;
  6996. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  6997. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6998. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  6999. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  7000. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  7001. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  7002. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  7003. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  7004. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  7005. foreach (var cost in groupCostType)
  7006. {
  7007. var List = cost.ToList();
  7008. if (cost.Key == "A")
  7009. {
  7010. foreach (var ListItem in List)
  7011. {
  7012. if (ListItem.number > 0)
  7013. {
  7014. if (ListItem.code.Contains("TBR"))
  7015. {
  7016. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7017. }
  7018. else
  7019. {
  7020. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7021. }
  7022. TotalPrice += (ListItem.number * ListItem.price);
  7023. }
  7024. }
  7025. }
  7026. else
  7027. {
  7028. itemStr = itemStr.Insert(0, "A段\r\n");
  7029. itemStr += "B段\r\n";
  7030. foreach (var ListItem in List)
  7031. {
  7032. if (ListItem.number > 0)
  7033. {
  7034. if (ListItem.code.Contains("TBR"))
  7035. {
  7036. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7037. }
  7038. else
  7039. {
  7040. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间( ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  7041. }
  7042. TotalPrice += (ListItem.number * ListItem.price);
  7043. }
  7044. }
  7045. }
  7046. }
  7047. #region 替换Word模板书签内容
  7048. Dictionary<string, string> marks = new Dictionary<string, string>();
  7049. marks.Add("To", di.ClientUnit);//付款方
  7050. marks.Add("ToTel", di.TellPhone);//付款方电话
  7051. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  7052. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  7053. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  7054. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  7055. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  7056. marks.Add("WeChat", "WeChat");//微信号 di.WeChat;
  7057. marks.Add("PayItemContent", itemStr);//详细信息
  7058. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  7059. #endregion
  7060. ////注
  7061. //if (doc.Range.Bookmarks["Attention"] != null)
  7062. //{
  7063. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  7064. // mark.Text = frList[0].Attention;
  7065. //}
  7066. foreach (var item in marks.Keys)
  7067. {
  7068. if (doc.Range.Bookmarks[item] != null)
  7069. {
  7070. Bookmark mark = doc.Range.Bookmarks[item];
  7071. mark.Text = marks[item];
  7072. }
  7073. }
  7074. byte[] bytes = null;
  7075. using (MemoryStream stream = new MemoryStream())
  7076. {
  7077. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  7078. bytes = stream.ToArray();
  7079. }
  7080. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  7081. return Ok(JsonView(true, "", new
  7082. {
  7083. Data = bytes,
  7084. strFileName,
  7085. }));
  7086. }
  7087. else
  7088. {
  7089. return Ok(JsonView(false, "团组信息不存在!"));
  7090. }
  7091. }
  7092. /// <summary>
  7093. /// 导出团组成本
  7094. /// </summary>
  7095. /// <param name="dto"></param>
  7096. /// <returns></returns>
  7097. [HttpPost]
  7098. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  7099. {
  7100. var jw = JsonView(false);
  7101. if (dto.Diid == 0)
  7102. {
  7103. return Ok(JsonView(false, "请传递团组id"));
  7104. }
  7105. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7106. if (deleInfo.Code != 0)
  7107. {
  7108. return Ok(JsonView(false, "团组信息查询失败!"));
  7109. }
  7110. var di = deleInfo.Data as DelegationInfoWebView;
  7111. if (di == null)
  7112. {
  7113. return Ok(JsonView(false, "团组信息查询失败!"));
  7114. }
  7115. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  7116. WorkbookDesigner designer = new WorkbookDesigner();
  7117. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  7118. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  7119. for (int i = 0; i < List_GC.Count; i++)
  7120. {
  7121. GroupCost_Excel gc = new GroupCost_Excel();
  7122. gc.Id = List_GC[i].Id;
  7123. gc.Diid = List_GC[i].Diid.ToString();
  7124. gc.DAY = List_GC[i].DAY;
  7125. string week = "";
  7126. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  7127. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  7128. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  7129. gc.ITIN = List_GC[i].ITIN;
  7130. gc.CarType = List_GC[i].CarType;
  7131. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  7132. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  7133. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  7134. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  7135. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  7136. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  7137. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  7138. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  7139. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  7140. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  7141. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  7142. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  7143. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7144. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  7145. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  7146. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  7147. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  7148. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  7149. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  7150. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  7151. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  7152. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  7153. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  7154. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  7155. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  7156. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  7157. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  7158. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  7159. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  7160. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  7161. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  7162. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  7163. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  7164. List_GC1.Add(gc);
  7165. }
  7166. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  7167. dt.TableName = "TB";
  7168. //报表标题等不用dt的值
  7169. designer.SetDataSource("TeamName", dto.title.TeamName);
  7170. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  7171. designer.SetDataSource("Tax", dto.title.Tax);
  7172. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  7173. designer.SetDataSource("Currency", dto.title.Currency);
  7174. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  7175. designer.SetDataSource("Rate", dto.title.Rate);
  7176. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  7177. var Aparams = hotels.Find(x => x.Type == "Default");
  7178. if (Aparams == null)
  7179. {
  7180. return Ok(jw);
  7181. }
  7182. //酒店数量
  7183. var txtSGRNumber = Aparams.SGR.ToString();
  7184. var txtTBRNumber = Aparams.TBR.ToString();
  7185. var txtJSESNumber = Aparams.JSES.ToString();
  7186. var txtSUITENumbe = Aparams.SUITE.ToString();
  7187. if (dto.costType == "B")
  7188. {
  7189. Aparams = hotels.Find(x => x.Type == "A");
  7190. var Bparams = hotels.Find(x => x.Type == "B");
  7191. if (Aparams == null || Bparams == null)
  7192. {
  7193. return Ok(jw);
  7194. }
  7195. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  7196. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  7197. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  7198. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  7199. }
  7200. designer.SetDataSource("SGRNumber", txtSGRNumber);
  7201. designer.SetDataSource("TBRNumber", txtTBRNumber);
  7202. designer.SetDataSource("JSESNumber", txtJSESNumber);
  7203. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  7204. var ws = designer.Workbook.Worksheets[0];
  7205. int Row = List_GC.Count;
  7206. int startIndex = 11;
  7207. int HideRows = 0;
  7208. List<int> hideRowsList = new List<int>();
  7209. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  7210. #region A段left数据
  7211. var left = dto.leftInfo.Find(x => x.Type == "A");
  7212. if (left == null)
  7213. {
  7214. return Ok(jw);
  7215. }
  7216. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  7217. if (leftBindData != null)
  7218. {
  7219. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  7220. designer.SetDataSource("VisaRS", leftBindData.rs);
  7221. designer.SetDataSource("VisaXS", leftBindData.xs);
  7222. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7223. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7224. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7225. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7226. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7227. }
  7228. else
  7229. {
  7230. hideRowsList.Add(Row + startIndex + HideRows);
  7231. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7232. }
  7233. HideRows += 2;
  7234. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  7235. if (leftBindData != null)
  7236. {
  7237. designer.SetDataSource("BXDRCB", leftBindData.cb);
  7238. designer.SetDataSource("BXRS", leftBindData.rs);
  7239. designer.SetDataSource("BXXS", leftBindData.xs);
  7240. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7241. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7242. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7243. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7244. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7245. }
  7246. else
  7247. {
  7248. hideRowsList.Add(Row + startIndex + HideRows);
  7249. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7250. }
  7251. HideRows += 2;
  7252. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7253. if (leftBindData != null)
  7254. {
  7255. designer.SetDataSource("HSDRCB", leftBindData.cb);
  7256. designer.SetDataSource("HSRS", leftBindData.rs);
  7257. designer.SetDataSource("HSXS", leftBindData.xs);
  7258. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7259. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7260. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7261. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7262. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7263. }
  7264. else
  7265. {
  7266. hideRowsList.Add(Row + startIndex + HideRows);
  7267. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7268. }
  7269. HideRows += 2;
  7270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7271. if (leftBindData != null)
  7272. {
  7273. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  7274. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  7275. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  7276. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7277. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7278. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7279. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7280. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7281. }
  7282. else
  7283. {
  7284. hideRowsList.Add(Row + startIndex + HideRows);
  7285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7286. }
  7287. HideRows += 2;
  7288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7289. if (leftBindData != null)
  7290. {
  7291. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  7292. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  7293. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  7294. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7295. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7296. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7297. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7298. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7299. }
  7300. else
  7301. {
  7302. hideRowsList.Add(Row + startIndex + HideRows);
  7303. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7304. }
  7305. HideRows += 2;
  7306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7307. if (leftBindData != null)
  7308. {
  7309. ////TBR
  7310. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  7311. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  7312. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  7313. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7314. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7315. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7316. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7317. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7318. }
  7319. else
  7320. {
  7321. hideRowsList.Add(Row + startIndex + HideRows);
  7322. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7323. }
  7324. HideRows += 2;
  7325. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7326. if (leftBindData != null)
  7327. {
  7328. ////SGR
  7329. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  7330. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  7331. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  7332. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7333. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7334. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7335. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7336. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7337. }
  7338. else
  7339. {
  7340. hideRowsList.Add(Row + startIndex + HideRows);
  7341. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7342. }
  7343. HideRows += 2;
  7344. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7345. if (leftBindData != null)
  7346. {
  7347. ////JS/ES
  7348. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  7349. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  7350. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  7351. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7352. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7353. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7354. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7355. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7356. }
  7357. else
  7358. {
  7359. hideRowsList.Add(Row + startIndex + HideRows);
  7360. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7361. }
  7362. HideRows += 2;
  7363. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7364. if (leftBindData != null)
  7365. {
  7366. ////SUITE
  7367. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  7368. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  7369. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  7370. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7371. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7372. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7373. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7374. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7375. }
  7376. else
  7377. {
  7378. hideRowsList.Add(Row + startIndex + HideRows);
  7379. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7380. }
  7381. HideRows += 2;
  7382. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7383. if (leftBindData != null)
  7384. {
  7385. designer.SetDataSource("DJDRCB", leftBindData.cb);
  7386. designer.SetDataSource("DJRS", leftBindData.rs);
  7387. designer.SetDataSource("DJXS", leftBindData.xs);
  7388. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7389. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7390. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7391. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7392. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7393. }
  7394. else
  7395. {
  7396. hideRowsList.Add(Row + startIndex + HideRows);
  7397. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7398. }
  7399. HideRows += 2;
  7400. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7401. if (leftBindData != null)
  7402. {
  7403. designer.SetDataSource("HCPCB", leftBindData.cb);
  7404. designer.SetDataSource("HCPRS", leftBindData.rs);
  7405. designer.SetDataSource("HCPXS", leftBindData.xs);
  7406. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7407. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7408. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7409. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7410. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7411. }
  7412. else
  7413. {
  7414. hideRowsList.Add(Row + startIndex + HideRows);
  7415. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7416. }
  7417. HideRows += 2;
  7418. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7419. if (leftBindData != null)
  7420. {
  7421. designer.SetDataSource("CPCB", leftBindData.cb);
  7422. designer.SetDataSource("CPRS", leftBindData.rs);
  7423. designer.SetDataSource("CPXS", leftBindData.xs);
  7424. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7425. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7426. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7427. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7428. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7429. }
  7430. else
  7431. {
  7432. hideRowsList.Add(Row + startIndex + HideRows);
  7433. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7434. }
  7435. HideRows += 2;
  7436. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7437. if (leftBindData != null)
  7438. {
  7439. designer.SetDataSource("GWDRCD", leftBindData.cb);
  7440. designer.SetDataSource("GWRS", leftBindData.rs);
  7441. designer.SetDataSource("GWXS", leftBindData.xs);
  7442. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7443. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7444. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7445. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7446. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7447. }
  7448. else
  7449. {
  7450. hideRowsList.Add(Row + startIndex + HideRows);
  7451. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7452. }
  7453. HideRows += 2;
  7454. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7455. if (leftBindData != null)
  7456. {
  7457. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  7458. designer.SetDataSource("LYJRS", leftBindData.rs);
  7459. designer.SetDataSource("LYJXS", leftBindData.xs);
  7460. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7461. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7462. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7463. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7464. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7465. }
  7466. else
  7467. {
  7468. hideRowsList.Add(Row + startIndex + HideRows);
  7469. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  7470. }
  7471. #endregion
  7472. #region A段Right信息
  7473. var right = dto.rightInfo.Find(x => x.Type == "A");
  7474. if (right == null)
  7475. {
  7476. return Ok(jw);
  7477. }
  7478. HideRows += 4;
  7479. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7480. if (rightBindData != null)
  7481. {
  7482. //经济舱 + 双人间 TBR
  7483. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  7484. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  7485. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7486. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  7487. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7488. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7489. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7490. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7491. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7492. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7493. }
  7494. else
  7495. {
  7496. hideRowsList.Add(Row + startIndex + HideRows);
  7497. }
  7498. HideRows += 2;
  7499. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7500. if (rightBindData != null)
  7501. {
  7502. //经济舱 + 单人间 SGR
  7503. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  7504. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  7505. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7506. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  7507. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7508. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7509. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7510. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7511. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7512. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7513. }
  7514. else
  7515. {
  7516. hideRowsList.Add(Row + startIndex + HideRows);
  7517. }
  7518. HideRows += 2;
  7519. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7520. if (rightBindData != null)
  7521. {
  7522. //公务舱 + 单人间 SGR
  7523. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  7524. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  7525. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7526. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  7527. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7528. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7529. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7530. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7531. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7532. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7533. }
  7534. else
  7535. {
  7536. hideRowsList.Add(Row + startIndex + HideRows);
  7537. }
  7538. HideRows += 2;
  7539. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7540. if (rightBindData != null)
  7541. {
  7542. //公务舱 + 小套房 JSES
  7543. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  7544. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  7545. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7546. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  7547. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7548. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7549. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7550. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7551. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7552. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7553. }
  7554. else
  7555. {
  7556. hideRowsList.Add(Row + startIndex + HideRows);
  7557. }
  7558. HideRows += 2;
  7559. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7560. if (rightBindData != null)
  7561. {
  7562. //公务舱 + 小套房 JSES
  7563. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  7564. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  7565. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7566. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  7567. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7568. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7569. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7570. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7571. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7572. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7573. }
  7574. else
  7575. {
  7576. hideRowsList.Add(Row + startIndex + HideRows);
  7577. }
  7578. HideRows += 2;
  7579. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7580. if (rightBindData != null)
  7581. {
  7582. //经济舱 + 大套房
  7583. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  7584. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  7585. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7586. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  7587. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7588. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7589. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7590. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7591. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7592. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7593. }
  7594. else
  7595. {
  7596. hideRowsList.Add(Row + startIndex + HideRows);
  7597. }
  7598. #endregion
  7599. #region B段标题清空
  7600. designer.SetDataSource("CostBDRCB", "");
  7601. designer.SetDataSource("CostBRS", "");
  7602. designer.SetDataSource("CostBXS", "");
  7603. designer.SetDataSource("CostBZCB", "");
  7604. designer.SetDataSource("CostBDRBJ", "");
  7605. designer.SetDataSource("CostBZBJ", "");
  7606. designer.SetDataSource("CostBDRLR", "");
  7607. designer.SetDataSource("CostBZLR", "");
  7608. designer.SetDataSource("CostBDRCBOM", "");
  7609. designer.SetDataSource("CostBRSOM", "");
  7610. designer.SetDataSource("CostBZCBOM", "");
  7611. designer.SetDataSource("CostBDRBJOM", "");
  7612. designer.SetDataSource("CostBZBJOM", "");
  7613. designer.SetDataSource("CostBDRLROM", "");
  7614. designer.SetDataSource("CostBZLROM", "");
  7615. #endregion
  7616. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  7617. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  7618. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  7619. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  7620. designer.SetDataSource("DJName", "地接(CNY)");
  7621. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  7622. designer.SetDataSource("CPName", "地接-船票(CNY)");
  7623. designer.SetDataSource("GWName", "公务(CNY)");
  7624. designer.SetDataSource("YQHName", "邀请函(CNY)");
  7625. designer.SetDataSource("LYJName", "零用金(CNY)");
  7626. designer.SetDataSource("HSName", "核酸检测(CNY)");
  7627. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  7628. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  7629. designer.SetDataSource("BXName", "保险(CNY)");
  7630. designer.SetDataSource("VisaName", "签证(CNY)");
  7631. #region B段基本数据
  7632. if (dto.costType == "B")
  7633. {
  7634. left = dto.leftInfo.Find(x => x.Type == "B");
  7635. if (left == null)
  7636. {
  7637. return Ok(jw);
  7638. }
  7639. #region B段left数据
  7640. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  7641. if (leftBindData != null)
  7642. {
  7643. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  7644. designer.SetDataSource("BHSRS", leftBindData.rs);
  7645. designer.SetDataSource("BHSXS", leftBindData.xs);
  7646. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7647. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7648. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7649. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7650. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7651. }
  7652. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  7653. if (leftBindData != null)
  7654. {
  7655. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  7656. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  7657. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  7658. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7659. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7660. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7661. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7662. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7663. }
  7664. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  7665. if (leftBindData != null)
  7666. {
  7667. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  7668. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  7669. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  7670. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7671. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7672. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7673. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7674. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7675. }
  7676. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  7677. if (leftBindData != null)
  7678. {
  7679. designer.SetDataSource("BHCPCB", leftBindData.cb);
  7680. designer.SetDataSource("BHCPRS", leftBindData.rs);
  7681. designer.SetDataSource("BHCPXS", leftBindData.xs);
  7682. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7683. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7684. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7685. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7686. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7687. }
  7688. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  7689. if (leftBindData != null)
  7690. {
  7691. designer.SetDataSource("BCPCB", leftBindData.cb);
  7692. designer.SetDataSource("BCPRS", leftBindData.rs);
  7693. designer.SetDataSource("BCPXS", leftBindData.xs);
  7694. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7695. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7696. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7697. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7698. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7699. }
  7700. //TBR
  7701. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  7702. if (leftBindData != null)
  7703. {
  7704. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  7705. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  7706. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  7707. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7708. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7709. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7710. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7711. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7712. }
  7713. //SGR
  7714. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  7715. if (leftBindData != null)
  7716. {
  7717. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  7718. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  7719. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  7720. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7721. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7722. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7723. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7724. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7725. }
  7726. //JS/ES
  7727. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  7728. if (leftBindData != null)
  7729. {
  7730. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  7731. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  7732. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  7733. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7734. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7735. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7736. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7737. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7738. }
  7739. //SUITE
  7740. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  7741. if (leftBindData != null)
  7742. {
  7743. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  7744. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  7745. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  7746. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7747. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7748. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7749. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7750. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7751. }
  7752. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  7753. if (leftBindData != null)
  7754. {
  7755. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  7756. designer.SetDataSource("BDJRS", leftBindData.rs);
  7757. designer.SetDataSource("BDJXS", leftBindData.xs);
  7758. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7759. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7760. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7761. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7762. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7763. }
  7764. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  7765. if (leftBindData != null)
  7766. {
  7767. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  7768. designer.SetDataSource("BGWRS", leftBindData.rs);
  7769. designer.SetDataSource("BGWXS", leftBindData.xs);
  7770. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7771. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7772. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7773. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7774. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7775. }
  7776. #region 优化方案
  7777. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  7778. //excelBind.Add("零用金", new {
  7779. //cb="",
  7780. //rs="",
  7781. //xs ="",
  7782. //zcb = "",
  7783. //});
  7784. #endregion
  7785. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  7786. if (leftBindData != null)
  7787. {
  7788. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  7789. designer.SetDataSource("BLYJRS", leftBindData.rs);
  7790. designer.SetDataSource("BLYJXS", leftBindData.xs);
  7791. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  7792. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  7793. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  7794. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  7795. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  7796. }
  7797. #endregion
  7798. #region B段Right信息
  7799. right = dto.rightInfo.Find(x => x.Type == "B");
  7800. if (right == null)
  7801. {
  7802. return Ok(jw);
  7803. }
  7804. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  7805. if (rightBindData != null)
  7806. {
  7807. //经济舱 + 双人间 TBR
  7808. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  7809. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  7810. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7811. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  7812. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7813. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7814. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7815. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7816. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7817. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7818. }
  7819. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  7820. if (rightBindData != null)
  7821. {
  7822. //经济舱 + 单人间 SGR
  7823. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  7824. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  7825. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7826. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  7827. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7828. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7829. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7830. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7831. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7832. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7833. }
  7834. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  7835. if (rightBindData != null)
  7836. {
  7837. //公务舱 + 单人间 SGR
  7838. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  7839. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  7840. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7841. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  7842. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7843. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7844. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7845. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7846. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7847. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7848. }
  7849. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  7850. if (rightBindData != null)
  7851. {
  7852. //公务舱 + 小套房 JSES
  7853. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  7854. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  7855. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7856. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  7857. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7858. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7859. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7860. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7861. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7862. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7863. }
  7864. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  7865. if (rightBindData != null)
  7866. {
  7867. //公务舱 + 小套房 JSES
  7868. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  7869. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  7870. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7871. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  7872. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7873. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7874. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7875. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7876. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7877. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7878. }
  7879. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  7880. if (rightBindData != null)
  7881. {
  7882. //经济舱 + 大套房
  7883. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  7884. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  7885. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  7886. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  7887. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  7888. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  7889. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  7890. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  7891. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  7892. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  7893. }
  7894. #endregion
  7895. #region 标题
  7896. designer.SetDataSource("CostBDRCB", "单人成本");
  7897. designer.SetDataSource("CostBRS", "人数");
  7898. designer.SetDataSource("CostBXS", "系数");
  7899. designer.SetDataSource("CostBZCB", "总成本");
  7900. designer.SetDataSource("CostBDRBJ", "单人报价");
  7901. designer.SetDataSource("CostBZBJ", "总报价");
  7902. designer.SetDataSource("CostBDRLR", "单人利润");
  7903. designer.SetDataSource("CostBZLR", "总利润");
  7904. designer.SetDataSource("CostBDRCBOM", "单人成本");
  7905. designer.SetDataSource("CostBRSOM", "人数");
  7906. designer.SetDataSource("CostBZCBOM", "总成本");
  7907. designer.SetDataSource("CostBDRBJOM", "单人报价");
  7908. designer.SetDataSource("CostBZBJOM", "总报价");
  7909. designer.SetDataSource("CostBDRLROM", "单人利润");
  7910. designer.SetDataSource("CostBZLROM", "总利润");
  7911. #endregion
  7912. }
  7913. #endregion
  7914. designer.SetDataSource("TzZCB2", TzZCB2);
  7915. designer.SetDataSource("TzZBJ2", TzZBJ2);
  7916. designer.SetDataSource("TzZLR2", TzZLR2);
  7917. string[] dataSourceKeys = new string[]
  7918. {
  7919. "VF",
  7920. "TGS",
  7921. "TGOF",
  7922. "TGM",
  7923. "TGA",
  7924. "TGTF",
  7925. "TGEF",
  7926. "CFM",
  7927. "CFOF",
  7928. "B",
  7929. "L",
  7930. "D",
  7931. "TBR",
  7932. "SGR",
  7933. "JSES",
  7934. "Suite",
  7935. "TV",
  7936. "1L",
  7937. "IF",
  7938. "EF",
  7939. "BRF",
  7940. "TE",
  7941. "TGT",
  7942. "DRVT",
  7943. "PC",
  7944. "TLF",
  7945. "ECT"
  7946. };
  7947. foreach (var item in dataSourceKeys)
  7948. {
  7949. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  7950. if (find != null)
  7951. {
  7952. designer.SetDataSource(item, find.text);
  7953. }
  7954. else
  7955. {
  7956. designer.SetDataSource(item, 0);
  7957. }
  7958. }
  7959. designer.SetDataSource(dt);
  7960. //根据数据源处理生成报表内容
  7961. designer.Process();
  7962. designer.Workbook.Worksheets[0].Name = "清单";
  7963. Worksheet sheet = designer.Workbook.Worksheets[0];
  7964. foreach (var Rowindex in hideRowsList)
  7965. {
  7966. ws.Cells.HideRows(Rowindex, 2);
  7967. }
  7968. byte[] bytes = null;
  7969. string strFileName = di.TeamName + "-团组-成本.xls";
  7970. using (MemoryStream stream = new MemoryStream())
  7971. {
  7972. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  7973. bytes = stream.ToArray();
  7974. }
  7975. return Ok(JsonView(true, "", new
  7976. {
  7977. Data = bytes,
  7978. strFileName,
  7979. }));
  7980. }
  7981. /// <summary>
  7982. /// 导出客户报表
  7983. /// </summary>
  7984. /// <returns></returns>
  7985. [HttpPost]
  7986. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  7987. {
  7988. var jw = JsonView(false);
  7989. if (dto.Diid == 0)
  7990. {
  7991. return Ok(JsonView(false, "请传递团组id"));
  7992. }
  7993. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  7994. if (deleInfo.Code != 0)
  7995. {
  7996. return Ok(JsonView(false, "团组信息查询失败!"));
  7997. }
  7998. var di = deleInfo.Data as DelegationInfoWebView;
  7999. if (di == null)
  8000. {
  8001. return Ok(JsonView(false, "团组信息查询失败!"));
  8002. }
  8003. //文件名
  8004. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  8005. //获取模板
  8006. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  8007. //载入模板
  8008. Document doc = new Document(tmppath);
  8009. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  8010. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  8011. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  8012. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  8013. var AParameter = ParameterList.Find(x => x.CostType == "A");
  8014. var BParameter = ParameterList.Find(x => x.CostType == "B");
  8015. if (AParameter == null)
  8016. {
  8017. return Ok(JsonView(false, "系数不存在!"));
  8018. }
  8019. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  8020. , TzAirDesc, TzZCost;
  8021. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  8022. = TzAirDesc = TzZCost = string.Empty;
  8023. TzNumber = AParameter.CostTypenumber.ToString();
  8024. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  8025. CarGuides1 = dto.CarGuides1;
  8026. Meal = dto.Meal;
  8027. SubsidizedMeals = dto.SubsidizedMeals;
  8028. NightRepair = dto.NightRepair;
  8029. AttractionsTickets = dto.AttractionsTickets;
  8030. MiscellaneousFees = dto.MiscellaneousFees;
  8031. ATip = dto.ATip;
  8032. TzHotelDesc = "";
  8033. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  8034. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  8035. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  8036. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  8037. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  8038. TzAirDesc = "";
  8039. TzZCost = dto.TzZCost;
  8040. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  8041. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  8042. var index = 1;
  8043. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  8044. foreach (var item in TzHotelDescArr)
  8045. {
  8046. if (AinfoArr != null)
  8047. {
  8048. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8049. if (Ainfo != null)
  8050. {
  8051. if (int.Parse(Ainfo.rs) <= 0)
  8052. {
  8053. continue;
  8054. }
  8055. var hotelText = string.Empty;
  8056. switch (item)
  8057. {
  8058. case "SGR":
  8059. hotelText = "单人间";
  8060. break;
  8061. case "JSES":
  8062. hotelText = "小套房";
  8063. break;
  8064. case "SUITE":
  8065. hotelText = "套房";
  8066. break;
  8067. case "TBR":
  8068. hotelText = "双人间";
  8069. break;
  8070. }
  8071. if (item != "TBR")
  8072. {
  8073. 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";
  8074. }
  8075. else
  8076. {
  8077. 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";
  8078. }
  8079. index++;
  8080. }
  8081. }
  8082. }
  8083. index = 1;
  8084. foreach (var item in TzAirDescArr)
  8085. {
  8086. if (AinfoArr != null)
  8087. {
  8088. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8089. if (Ainfo != null)
  8090. {
  8091. if (int.Parse(Ainfo.rs) <= 0)
  8092. {
  8093. continue;
  8094. }
  8095. 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";
  8096. index++;
  8097. }
  8098. }
  8099. }
  8100. if (dto.costType == "B")
  8101. {
  8102. if (BParameter == null)
  8103. {
  8104. return Ok(JsonView(false, "B段系数不存在!"));
  8105. }
  8106. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  8107. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  8108. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  8109. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  8110. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  8111. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  8112. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  8113. foreach (var item in TzHotelDescArr)
  8114. {
  8115. if (AinfoArr != null)
  8116. {
  8117. TzHotelDesc += "B段信息 \r\n";
  8118. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8119. if (Ainfo != null)
  8120. {
  8121. if (int.Parse(Ainfo.rs) <= 0)
  8122. {
  8123. continue;
  8124. }
  8125. var hotelText = string.Empty;
  8126. switch (item)
  8127. {
  8128. case "SGR":
  8129. hotelText = "单人间";
  8130. break;
  8131. case "JSES":
  8132. hotelText = "小套房";
  8133. break;
  8134. case "SUITE":
  8135. hotelText = "套房";
  8136. break;
  8137. case "TBR":
  8138. hotelText = "双人间";
  8139. break;
  8140. }
  8141. if (item != "TBR")
  8142. {
  8143. 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";
  8144. }
  8145. else
  8146. {
  8147. 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";
  8148. }
  8149. index++;
  8150. }
  8151. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  8152. }
  8153. }
  8154. index = 1;
  8155. foreach (var item in TzAirDescArr)
  8156. {
  8157. if (AinfoArr != null)
  8158. {
  8159. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  8160. if (Ainfo != null)
  8161. {
  8162. if (int.Parse(Ainfo.rs) <= 0)
  8163. {
  8164. continue;
  8165. }
  8166. 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";
  8167. index++;
  8168. }
  8169. }
  8170. }
  8171. }
  8172. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  8173. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  8174. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  8175. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  8176. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  8177. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  8178. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  8179. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  8180. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  8181. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  8182. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  8183. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  8184. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  8185. DickeyValue.Add("Visa", Visa); // 签证单人报价
  8186. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  8187. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  8188. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  8189. DickeyValue.Add("TzZCost", TzZCost);
  8190. foreach (var key in DickeyValue.Keys)
  8191. {
  8192. if (doc.Range.Bookmarks[key] != null)
  8193. {
  8194. Bookmark mark = doc.Range.Bookmarks[key];
  8195. mark.Text = DickeyValue[key];
  8196. }
  8197. }
  8198. byte[] bytes = null;
  8199. string strFileName = di.TeamName + "-客户报价.doc";
  8200. using (MemoryStream stream = new MemoryStream())
  8201. {
  8202. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  8203. bytes = stream.ToArray();
  8204. }
  8205. return Ok(JsonView(true, "", new
  8206. {
  8207. Data = bytes,
  8208. strFileName,
  8209. }));
  8210. }
  8211. /// <summary>
  8212. /// 团组成本 各模块(酒店,地接,机票)成本提示
  8213. /// </summary>
  8214. /// <param name="dto"></param>
  8215. /// <returns></returns>
  8216. [HttpPost]
  8217. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8218. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  8219. {
  8220. try
  8221. {
  8222. #region 参数验证
  8223. if (dto.DiId < 0)
  8224. {
  8225. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  8226. }
  8227. List<int> cTableIds = new List<int>() {
  8228. 76 ,//酒店预订
  8229. 77 ,//行程
  8230. 79 ,//车/导游地接
  8231. 80 ,//签证
  8232. 81 ,//邀请/公务活
  8233. 82 ,//团组客户保险
  8234. 85 ,//机票预订
  8235. 98 ,//其他款项
  8236. 285 ,//收款退还
  8237. 751 ,//酒店早餐
  8238. 1015 // 超支费用
  8239. };
  8240. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  8241. {
  8242. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  8243. }
  8244. #endregion
  8245. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  8246. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  8247. if (_GroupCostParameters.Count <= 0)
  8248. {
  8249. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  8250. }
  8251. if (_GroupCostParameters[0].IsShare == 0)
  8252. {
  8253. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  8254. }
  8255. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8256. //处理date为空问题
  8257. if (_GroupCosts.Count > 0)
  8258. {
  8259. for (int i = 0; i < _GroupCosts.Count; i++)
  8260. {
  8261. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  8262. {
  8263. if (i > 0)
  8264. {
  8265. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  8266. }
  8267. }
  8268. }
  8269. }
  8270. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  8271. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  8272. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  8273. string currCode = "";
  8274. #region currCode 验证
  8275. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  8276. if (isInt)
  8277. {
  8278. var currData = currDatas.Find(it => it.Id == intCurrency);
  8279. if (currData != null)
  8280. {
  8281. currCode = currData.Name;
  8282. }
  8283. }
  8284. else
  8285. {
  8286. currCode = _GroupCostParameters[0].Currency.Trim();
  8287. }
  8288. #endregion
  8289. //op,酒店单段模式存储
  8290. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  8291. {
  8292. CurrencyCode = currCode,
  8293. Rate = _GroupCostParameters[0].Rate,
  8294. CostType = _GroupCostParameters[0].CostType,
  8295. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  8296. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  8297. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  8298. };
  8299. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  8300. if (_GroupCostParameters.Count == 2)
  8301. {
  8302. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  8303. }
  8304. foreach (var item in _GroupCostParameters)
  8305. {
  8306. decimal _rate = 1;
  8307. decimal _rate1 = item.Rate;
  8308. decimal _scale = 1;
  8309. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  8310. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  8311. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  8312. //if (userInfo != null)
  8313. //{
  8314. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  8315. // {
  8316. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  8317. // {
  8318. // _scale = 1.00M;
  8319. // }
  8320. // }
  8321. //}
  8322. #endregion
  8323. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  8324. {
  8325. CurrencyCode = currCode,
  8326. Rate = _rate1,
  8327. CostType = item.CostType,
  8328. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  8329. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  8330. CostTypeNumber = item.CostTypenumber
  8331. };
  8332. if (_GroupCostParameters.Count > 1)
  8333. {
  8334. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  8335. }
  8336. else
  8337. {
  8338. modulePromptInfo.CostTypeNumber = item.LYJRS;
  8339. }
  8340. if (dto.CTable == 79)//
  8341. {
  8342. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  8343. modulePromptInfo.TotalCost = item.DJCB;
  8344. }
  8345. List<string> costTypes = new List<string>() { "A", "B" };
  8346. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  8347. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  8348. if (_GroupCostsDuplicates.Count() == 1)
  8349. {
  8350. _GroupCostsTypeData = _GroupCosts;
  8351. }
  8352. else
  8353. {
  8354. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  8355. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  8356. }
  8357. /*
  8358. * 76 酒店预订
  8359. * 77 行程
  8360. * 79 车/导游地接
  8361. * 80 签证
  8362. * 81 邀请/公务活动
  8363. * 82 团组客户保险
  8364. * 85 机票预订
  8365. * 98 其他款项
  8366. * 285 收款退还
  8367. * 751 酒店早餐
  8368. * 1015 超支费用
  8369. */
  8370. switch (dto.CTable)
  8371. {
  8372. case 76: // 酒店预订
  8373. _ModuleSubPromptInfo.AddRange(
  8374. _GroupCostsTypeData.Select(it => new
  8375. {
  8376. it.DAY,
  8377. it.Date,
  8378. it.ACCON,
  8379. it.ITIN,
  8380. it.SGR,
  8381. it.TBR,
  8382. it.JS_ES,
  8383. it.Suite
  8384. })
  8385. );
  8386. break;
  8387. case 79: // 车/导游地接
  8388. _ModuleSubPromptInfo.AddRange(
  8389. _GroupCostsTypeData.Select(it => new
  8390. {
  8391. Date = it.Date, //日期
  8392. CarFee = (it.CarCost + it.CFM + it.CFOF) * _rate * _scale, //车费用
  8393. GuideFee = (it.TGS + it.TGOF + it.TGM + it.TGA + it.TGTF + it.TGEF) * _rate * _scale, //导游费用
  8394. MealFee = (it.B + it.L + it.D) * _rate * _scale, //餐食费
  8395. TicketFee = it.EF * _rate * _scale, //门票费
  8396. TipFee = (it.TGTips + it.DRVTips) * _rate * _scale, //小费
  8397. AirportTransferFee = 0.00M,
  8398. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  8399. TravelSupplies = it.TE * _rate * _scale, //出行物资
  8400. LeadersFee = it.TLF * _rate * _scale, //领队费
  8401. CarFee1 = it.CarCost * _rate * _scale,
  8402. CarType = it.CarType, //车型
  8403. SpentCash = it.PC * _rate * _scale, //零用金
  8404. })
  8405. );
  8406. break;
  8407. case 85: // 机票
  8408. List<dynamic> datas = new List<dynamic>();
  8409. datas.Add(
  8410. new
  8411. {
  8412. AirType = "经济舱",
  8413. AirNum = item.JJCRS,
  8414. AirDRCB = item.JJCCB,
  8415. AirZCB = (item.JJCRS * item.JJCCB)
  8416. }
  8417. );
  8418. datas.Add(
  8419. new
  8420. {
  8421. AirType = "公务舱",
  8422. AirNum = item.GWCRS,
  8423. AirDRCB = item.GWCCB,
  8424. AirZCB = (item.GWCRS * item.GWCCB)
  8425. }
  8426. );
  8427. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  8428. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  8429. modulePromptInfo.Data = new {
  8430. airFeeData = datas,
  8431. airInitData = initDatas
  8432. };
  8433. _ModulePromptInfos.Add(modulePromptInfo);
  8434. break;
  8435. default:
  8436. break;
  8437. }
  8438. }
  8439. if (dto.CTable != 85)
  8440. {
  8441. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  8442. _ModulePromptInfos.Add(_ModulePromptInfo);
  8443. }
  8444. _view.ModulePromptInfos = _ModulePromptInfos;
  8445. return Ok(JsonView(true, "操作成功!", _view));
  8446. }
  8447. catch (Exception ex)
  8448. {
  8449. return Ok(JsonView(false, ex.Message));
  8450. }
  8451. }
  8452. /// <summary>
  8453. /// 根据黑屏代码重新生成行程
  8454. /// </summary>
  8455. /// <param name="dto"></param>
  8456. /// <returns></returns>
  8457. [HttpPost]
  8458. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  8459. {
  8460. var jw = JsonView(false);
  8461. var Create = _GroupCostRepository.
  8462. CreateGroupCostByBlackCode(dto.Diid);
  8463. jw.Msg = Create.Msg;
  8464. if (Create.Code == 0)
  8465. {
  8466. jw.Code = 200;
  8467. jw.Data = new
  8468. {
  8469. groupCost = Create.Data,
  8470. blackCodeIsTrue = true
  8471. };
  8472. }
  8473. else
  8474. {
  8475. jw.Code = 400;
  8476. jw.Data = new
  8477. {
  8478. groupCost = Create.Data,
  8479. blackCodeIsTrue = false,
  8480. };
  8481. }
  8482. return Ok(jw);
  8483. }
  8484. /// <summary>
  8485. /// 成本获取OP历史车费用
  8486. /// </summary>
  8487. /// <param name="dto"></param>
  8488. /// <returns></returns>
  8489. [HttpPost]
  8490. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  8491. {
  8492. var jw = JsonView(false);
  8493. try
  8494. {
  8495. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  8496. //获取现有所有车的数据
  8497. if (!dto.Param.IsNullOrWhiteSpace())
  8498. {
  8499. string sql = $@"
  8500. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  8501. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  8502. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  8503. 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
  8504. AND gctggr.ServiceEndTime is not NULL
  8505. ORDER by gctggrc.id DESC
  8506. ";
  8507. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  8508. var numeberResult = await Task.Run(() =>
  8509. {
  8510. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  8511. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  8512. return numberArr;
  8513. });
  8514. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  8515. foreach (var item in numeberResult)
  8516. {
  8517. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  8518. {
  8519. Country = "数据异常!",
  8520. City = string.Empty,
  8521. };
  8522. item.Area = find.Country + " " + find.City;
  8523. }
  8524. dbResult.AddRange(numeberResult);
  8525. if (dto.Param.Contains("、"))
  8526. {
  8527. var sp = dto.Param.Split("、");
  8528. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8529. .Where(x =>
  8530. {
  8531. return System.Array.Exists(sp, e =>
  8532. {
  8533. bool where = false;
  8534. if (x.Area != null)
  8535. {
  8536. where = x.Area.Contains(e);
  8537. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8538. {
  8539. return false;
  8540. }
  8541. }
  8542. if (x.PriceName != null && !where)
  8543. {
  8544. where = x.PriceName.Contains(e);
  8545. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8546. {
  8547. return false;
  8548. }
  8549. }
  8550. return where;
  8551. });
  8552. }).ToList();
  8553. }
  8554. else
  8555. {
  8556. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  8557. .Where(x =>
  8558. {
  8559. bool where = false;
  8560. if (x.Area != null)
  8561. {
  8562. where = x.Area.Contains(dto.Param);
  8563. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  8564. {
  8565. return false;
  8566. }
  8567. }
  8568. if (x.PriceName != null && !where)
  8569. {
  8570. where = x.PriceName.Contains(dto.Param);
  8571. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  8572. {
  8573. return false;
  8574. }
  8575. }
  8576. return where;
  8577. }
  8578. )
  8579. .ToList();
  8580. }
  8581. }
  8582. var view = dbResult.Select(x => {
  8583. decimal dp = 0.00M;
  8584. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  8585. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  8586. if (string.IsNullOrWhiteSpace(x.DatePrice))
  8587. {
  8588. if (startB && endB)
  8589. {
  8590. var timesp = endD.Subtract(startD);
  8591. if ((timesp.Days + 1) != 0)
  8592. {
  8593. dp = x.Price / (timesp.Days + 1);
  8594. }
  8595. }
  8596. }
  8597. else
  8598. {
  8599. dp = x.Price;
  8600. }
  8601. return new
  8602. {
  8603. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  8604. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  8605. x.Area,
  8606. x.id,
  8607. price = x.Price.ToString("F2"),
  8608. x.PriceName,
  8609. x.PriceContent,
  8610. x.TeamName,
  8611. x.DatePrice,
  8612. dayPrice = dp.ToString("F2"),
  8613. };
  8614. }).OrderByDescending(x => x.id).ToList();
  8615. jw = JsonView(true, "获取成功!", view);
  8616. }
  8617. catch (Exception e)
  8618. {
  8619. jw = JsonView(false, e.Message);
  8620. }
  8621. return Ok(jw);
  8622. }
  8623. #endregion
  8624. #region 酒店预订 新 雷怡 2023-12-28 17:45
  8625. /// <summary>
  8626. /// 酒店预订
  8627. /// 酒店费用列表 根据团组Id查询
  8628. /// </summary>
  8629. /// <param name="_dto"></param>
  8630. /// <returns></returns>
  8631. [HttpPost]
  8632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8633. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  8634. {
  8635. #region 参数验证
  8636. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8637. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8638. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8639. #region 团组操作权限验证 76 酒店预定模块
  8640. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8641. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8642. #endregion
  8643. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8644. #region 页面操作权限验证
  8645. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8646. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8647. #endregion
  8648. #endregion
  8649. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  8650. }
  8651. /// <summary>
  8652. /// 酒店预订
  8653. /// 基础数据
  8654. /// </summary>
  8655. /// <param name="_dto"></param>
  8656. /// <returns></returns>
  8657. [HttpPost]
  8658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8659. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  8660. {
  8661. #region 参数验证
  8662. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8663. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8664. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8665. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8666. #region 页面操作权限验证
  8667. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8668. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8669. #endregion
  8670. #region 团组操作权限验证 76 酒店预定模块
  8671. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8672. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8673. #endregion
  8674. #endregion
  8675. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  8676. }
  8677. /// <summary>
  8678. /// 酒店预订
  8679. /// 创建 入住卷号码
  8680. /// </summary>
  8681. /// <param name="_dto"></param>
  8682. /// <returns></returns>
  8683. [HttpPost]
  8684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8685. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  8686. {
  8687. try
  8688. {
  8689. #region 参数验证
  8690. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8691. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8692. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8693. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8694. #region 页面操作权限验证
  8695. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8696. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8697. #endregion
  8698. #region 团组操作权限验证 76 酒店预定模块
  8699. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8700. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8701. #endregion
  8702. #endregion
  8703. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  8704. if (data.Code != 0)
  8705. {
  8706. return Ok(JsonView(false, data.Msg));
  8707. }
  8708. return Ok(JsonView(true, data.Msg, data.Data));
  8709. }
  8710. catch (Exception ex)
  8711. {
  8712. return Ok(JsonView(false, ex.Message));
  8713. }
  8714. }
  8715. /// <summary>
  8716. /// 酒店预订
  8717. /// 详情
  8718. /// </summary>
  8719. /// <param name="_dto"></param>
  8720. /// <returns></returns>
  8721. [HttpPost]
  8722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8723. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  8724. {
  8725. #region 参数验证
  8726. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  8727. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8728. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  8729. #region 团组操作权限验证 76 酒店预定模块
  8730. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8731. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8732. #endregion
  8733. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8734. #region 页面操作权限验证
  8735. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8736. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  8737. #endregion
  8738. #endregion
  8739. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  8740. }
  8741. /// <summary>
  8742. /// 酒店预订
  8743. /// Add Or Edit
  8744. /// </summary>
  8745. /// <param name="_dto"></param>
  8746. /// <returns></returns>
  8747. [HttpPost]
  8748. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8749. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  8750. {
  8751. #region 参数验证
  8752. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8753. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8754. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8755. #region 团组操作权限验证 76 酒店预定模块
  8756. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8757. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8758. #endregion
  8759. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8760. #region 页面操作权限验证
  8761. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8762. if (_dto.Id == 0) // Add
  8763. {
  8764. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  8765. }
  8766. else if (_dto.Id > 1) // Edit
  8767. {
  8768. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  8769. } else return Ok(JsonView(false, "请输入正确的数据Id!"));
  8770. #endregion
  8771. #endregion
  8772. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  8773. if (_view.Code != 200)
  8774. {
  8775. return Ok(_view);
  8776. }
  8777. #region 应用推送
  8778. //TODO:酒店预订费用消息推送 移动端完成后取消注释
  8779. //try
  8780. //{
  8781. // int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  8782. // int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  8783. // await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8784. //}
  8785. //catch (Exception ex)
  8786. //{
  8787. //}
  8788. #endregion
  8789. return Ok(_view);
  8790. }
  8791. /// <summary>
  8792. /// 酒店预订
  8793. /// Del
  8794. /// </summary>
  8795. /// <param name="_dto"></param>
  8796. /// <returns></returns>
  8797. [HttpPost]
  8798. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8799. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  8800. {
  8801. #region 参数验证
  8802. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8803. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8804. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8805. #region 团组操作权限验证 76 酒店预定模块
  8806. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8807. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8808. #endregion
  8809. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8810. #region 页面操作权限验证
  8811. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8812. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  8813. #endregion
  8814. #endregion
  8815. return Ok(await _hotelPriceRep._Del(_dto.Id, _dto.UserId));
  8816. }
  8817. /// <summary>
  8818. /// 酒店预订
  8819. /// 生成VOUCHER
  8820. /// 2024.05.06 之前版本
  8821. /// </summary>
  8822. /// <param name="_dto"></param>
  8823. /// <returns></returns>
  8824. [HttpPost]
  8825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8826. public async Task<IActionResult> PostHotelReservationsCreateVoucher1(HotelReservationsCreateVoucherDto _dto)
  8827. {
  8828. try
  8829. {
  8830. #region 参数验证
  8831. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  8832. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  8833. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  8834. #region 团组操作权限验证 76 酒店预定模块
  8835. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  8836. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  8837. #endregion
  8838. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  8839. #region 页面操作权限验证
  8840. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  8841. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  8842. #endregion
  8843. #endregion
  8844. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  8845. //判断数据是否完整
  8846. if (hr != null)
  8847. {
  8848. if (!string.IsNullOrEmpty(hr.DetermineNo))
  8849. {
  8850. string strFileName = "HotelStatement/";
  8851. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  8852. if (dele != null)
  8853. strFileName += dele.TourCode;
  8854. //载入模板
  8855. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  8856. Document doc = new Document(sss);
  8857. DocumentBuilder builder = new DocumentBuilder(doc);
  8858. #region 替换Word模板书签内容
  8859. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  8860. //入住卷预定号码
  8861. if (doc.Range.Bookmarks["VNO"] != null)
  8862. {
  8863. Bookmark mark = doc.Range.Bookmarks["VNO"];
  8864. mark.Text = hr.CheckNumber;
  8865. }
  8866. //酒店时间
  8867. if (doc.Range.Bookmarks["Date"] != null)
  8868. {
  8869. Bookmark mark = doc.Range.Bookmarks["Date"];
  8870. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  8871. }
  8872. //团号
  8873. if (doc.Range.Bookmarks["TNo"] != null)
  8874. {
  8875. Bookmark mark = doc.Range.Bookmarks["TNo"];
  8876. mark.Text = dele.TourCode;
  8877. }
  8878. //预定号码
  8879. if (doc.Range.Bookmarks["BookingId"] != null)
  8880. {
  8881. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  8882. mark.Text = hr.ReservationsNo;
  8883. }
  8884. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  8885. {
  8886. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  8887. mark.Text = hr.DetermineNo;
  8888. }
  8889. //酒店城市
  8890. if (doc.Range.Bookmarks["City"] != null)
  8891. {
  8892. Bookmark mark = doc.Range.Bookmarks["City"];
  8893. mark.Text = hr.City;
  8894. }
  8895. //酒店名称
  8896. if (doc.Range.Bookmarks["HName"] != null)
  8897. {
  8898. Bookmark mark = doc.Range.Bookmarks["HName"];
  8899. mark.Text = hr.HotelName;
  8900. }
  8901. //酒店地址
  8902. if (doc.Range.Bookmarks["Address"] != null)
  8903. {
  8904. Bookmark mark = doc.Range.Bookmarks["Address"];
  8905. mark.Text = hr.HotelAddress;
  8906. }
  8907. //酒店电话
  8908. if (doc.Range.Bookmarks["Tel"] != null)
  8909. {
  8910. Bookmark mark = doc.Range.Bookmarks["Tel"];
  8911. mark.Text = hr.HotelTel;
  8912. }
  8913. //酒店传真
  8914. if (doc.Range.Bookmarks["Fax"] != null)
  8915. {
  8916. Bookmark mark = doc.Range.Bookmarks["Fax"];
  8917. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  8918. {
  8919. mark.Text = hr.HotelFax;
  8920. }
  8921. }
  8922. //入住时间
  8923. if (doc.Range.Bookmarks["CIn"] != null)
  8924. {
  8925. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  8926. Bookmark mark = doc.Range.Bookmarks["CIn"];
  8927. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  8928. }
  8929. //退房时间
  8930. if (doc.Range.Bookmarks["COut"] != null)
  8931. {
  8932. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  8933. Bookmark mark = doc.Range.Bookmarks["COut"];
  8934. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  8935. }
  8936. //客户名称
  8937. if (doc.Range.Bookmarks["GName"] != null)
  8938. {
  8939. string guestName = "";
  8940. string[] clients = new string[] { };
  8941. if (hr.GuestName.Contains(","))
  8942. {
  8943. clients = hr.GuestName.Split(",");
  8944. }
  8945. else
  8946. {
  8947. clients = new string[] { hr.GuestName };
  8948. }
  8949. List<int> clientIds_int = new List<int>();
  8950. if (clients.Length > 0)
  8951. {
  8952. foreach (var item in clients)
  8953. {
  8954. if (item.IsNumeric())
  8955. {
  8956. clientIds_int.Add(int.Parse(item));
  8957. }
  8958. }
  8959. }
  8960. if (clientIds_int.Count > 0)
  8961. {
  8962. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  8963. foreach (var client in _clientDatas)
  8964. {
  8965. //男
  8966. if (client.Sex == 0) guestName += $"Mr.";
  8967. //女
  8968. else if (client.Sex == 1) guestName += $"Ms.";
  8969. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  8970. {
  8971. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  8972. }
  8973. //guestName += $"{client.Pinyin},";
  8974. }
  8975. if (guestName.Length > 0)
  8976. {
  8977. guestName = guestName.Substring(0, guestName.Length - 1);
  8978. }
  8979. }
  8980. else
  8981. {
  8982. guestName = hr.GuestName;
  8983. }
  8984. Bookmark mark = doc.Range.Bookmarks["GName"];
  8985. mark.Text = guestName;
  8986. }
  8987. //房间介绍
  8988. if (doc.Range.Bookmarks["ROOM"] != null)
  8989. {
  8990. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  8991. mark.Text = hr.RoomExplanation;
  8992. }
  8993. //报价描述
  8994. if (doc.Range.Bookmarks["NOTE"] != null)
  8995. {
  8996. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  8997. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  8998. if (ss != null)
  8999. mark.Text = ss.Name;
  9000. }
  9001. //入住时间
  9002. if (doc.Range.Bookmarks["CheckIn"] != null)
  9003. {
  9004. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  9005. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  9006. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  9007. }
  9008. //退房时间
  9009. if (doc.Range.Bookmarks["CheckOut"] != null)
  9010. {
  9011. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  9012. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  9013. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  9014. }
  9015. //日期
  9016. if (doc.Range.Bookmarks["DT"] != null)
  9017. {
  9018. Bookmark mark = doc.Range.Bookmarks["DT"];
  9019. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  9020. }
  9021. //名称
  9022. if (doc.Range.Bookmarks["VName"] != null)
  9023. {
  9024. Bookmark mark = doc.Range.Bookmarks["VName"];
  9025. mark.Text = hr.HotelName;
  9026. }
  9027. //号码
  9028. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  9029. {
  9030. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  9031. mark.Text = hr.CheckNumber;
  9032. }
  9033. #endregion
  9034. strFileName += "VOUCHER.doc";
  9035. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9036. doc.Save(fileDir);
  9037. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9038. return Ok(JsonView(true, "操作成功!", Url));
  9039. }
  9040. else
  9041. {
  9042. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  9043. }
  9044. }
  9045. else
  9046. {
  9047. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  9048. }
  9049. }
  9050. catch (Exception ex)
  9051. {
  9052. return Ok(JsonView(false, ex.Message));
  9053. }
  9054. }
  9055. /// <summary>
  9056. /// 酒店预订
  9057. /// 生成VOUCHER
  9058. /// 2024.05.06 之后版本
  9059. /// </summary>
  9060. /// <param name="_dto"></param>
  9061. /// <returns></returns>
  9062. [HttpPost]
  9063. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9064. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  9065. {
  9066. #region 参数验证
  9067. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9068. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9069. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9070. #region 团组操作权限验证 76 酒店预定模块
  9071. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9072. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9073. #endregion
  9074. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9075. #region 页面操作权限验证
  9076. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9077. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9078. #endregion
  9079. #endregion
  9080. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9081. //判断数据是否完整
  9082. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  9083. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9084. string strFileName = "HotelStatement/";
  9085. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9086. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  9087. #region 数据处理
  9088. List<int> guestIds = new List<int>();
  9089. int index = 0;
  9090. foreach (var item in hrDtas)
  9091. {
  9092. if (item.GuestName.Contains(","))
  9093. {
  9094. string[] guestIdArr = item.GuestName.Split(',');
  9095. foreach (var guestIdStr in guestIdArr)
  9096. {
  9097. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  9098. if (guestBool)
  9099. {
  9100. guestIds.Add(guestId);
  9101. }
  9102. }
  9103. }
  9104. else guestNames += item.GuestName;
  9105. var voucherInfo = new HotelVoucherInfoView()
  9106. {
  9107. HotelName = item.HotelName,
  9108. CheckInDate = item.CheckInDate,
  9109. CheckOutDate = item.CheckOutDate,
  9110. ConfirmationNumber = item.DetermineNo.Trim(),
  9111. RoomType = item.RoomExplanation
  9112. };
  9113. vouchers.Add(voucherInfo);
  9114. }
  9115. if (guestIds.Count > 0)
  9116. {
  9117. guestIds = guestIds.Distinct().ToList();
  9118. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  9119. if (guestDatas.Count > 0)
  9120. {
  9121. guestNames = "";
  9122. foreach (var guest in guestDatas)
  9123. {
  9124. string guestName = "";
  9125. if (guest.Sex == 0) guestName += @"MR.";
  9126. else if (guest.Sex == 1) guestName += @"MS.";
  9127. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  9128. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  9129. guestNames += @$"{guestName.Trim()}、";
  9130. }
  9131. if (guestNames.Length > 0)
  9132. {
  9133. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  9134. }
  9135. }
  9136. }
  9137. #endregion
  9138. //载入模板
  9139. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  9140. Document doc = new Document(sss);
  9141. DocumentBuilder builder = new DocumentBuilder(doc);
  9142. if (doc.Range.Bookmarks["GuestName"] != null)
  9143. {
  9144. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  9145. mark.Text = guestNames;
  9146. }
  9147. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9148. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  9149. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  9150. for (int i = 1; i <= vouchers.Count; i++)
  9151. {
  9152. HotelVoucherInfoView hviv = vouchers[i - 1];
  9153. builder.MoveToCell(0, i, 0, 0);
  9154. builder.Write(hviv.HotelName);
  9155. builder.MoveToCell(0, i, 1, 0);
  9156. builder.Write(hviv.CheckInDate);
  9157. builder.MoveToCell(0, i, 2, 0);
  9158. builder.Write(hviv.CheckOutDate);
  9159. builder.MoveToCell(0, i, 3, 0);
  9160. builder.Write(hviv.RoomType);
  9161. builder.MoveToCell(0, i, 4, 0);
  9162. builder.Write(hviv.ConfirmationNumber);
  9163. }
  9164. //删除多余行
  9165. int currRowIndex = vouchers.Count + 1;
  9166. int delRows = 21 - currRowIndex;
  9167. if (delRows > 0)
  9168. {
  9169. for (int i = 0; i < delRows; i++)
  9170. {
  9171. table.Rows.RemoveAt(currRowIndex);
  9172. //cultivateRowIndex++;
  9173. }
  9174. }
  9175. strFileName += "VOUCHER.docx";
  9176. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  9177. doc.Save(fileDir);
  9178. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  9179. return Ok(JsonView(true, "操作成功!", Url));
  9180. }
  9181. /// <summary>
  9182. /// 酒店预订
  9183. /// 生成 预定成本 Excel
  9184. /// </summary>
  9185. /// <param name="_dto"></param>
  9186. /// <returns></returns>
  9187. [HttpPost]
  9188. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9189. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  9190. {
  9191. #region 参数验证
  9192. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  9193. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  9194. if (!vadalitorRes.IsValid)
  9195. {
  9196. var errors = new StringBuilder();
  9197. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  9198. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  9199. }
  9200. #region 团组操作权限验证 76 酒店预定模块
  9201. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9202. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  9203. #endregion
  9204. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9205. #region 页面操作权限验证
  9206. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9207. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9208. #endregion
  9209. #endregion
  9210. decimal _rate = 1.00M;
  9211. string _currency = "";
  9212. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  9213. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  9214. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  9215. Grp_GroupCostParameter _GroupCostParameter = await _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).FirstAsync();
  9216. if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  9217. if (string.IsNullOrEmpty(_GroupCostParameter.Currency))
  9218. {
  9219. return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  9220. }
  9221. _currency = _GroupCostParameter.Currency;
  9222. bool isIntType = int.TryParse(_currency, out int currId);
  9223. if (isIntType)
  9224. {
  9225. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  9226. }
  9227. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  9228. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  9229. if (currInfo == null)
  9230. {
  9231. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  9232. }
  9233. if (!_currency.ToUpper().Equals("CNY"))
  9234. {
  9235. _rate = _GroupCostParameter.Rate;
  9236. }
  9237. _rate = currInfo.Rate;
  9238. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  9239. string strFileName = "HotelStatement/";
  9240. string guestNames = ""; //格式Mr.xxx Ms.xxx
  9241. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  9242. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  9243. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  9244. #region 数据处理
  9245. foreach (var item in hrDtas)
  9246. {
  9247. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  9248. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  9249. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  9250. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  9251. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  9252. string roomCurr = currDatas.Find(it => it.Id == roomInfo.Currency)?.Name ?? "";
  9253. string singleRoomFeeStr = string.Empty,
  9254. doubleRoomFeeStr = string.Empty,
  9255. suiteRoomFeeStr = string.Empty,
  9256. otherRoomFeeStr = string.Empty,
  9257. payMoneyStr = string.Empty,
  9258. cardPriceStr = string.Empty;
  9259. if (roomCurr.Equals(_currency))
  9260. {
  9261. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  9262. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  9263. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  9264. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  9265. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  9266. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  9267. }
  9268. else
  9269. {
  9270. singleRoomFeeStr = $"{(item.SingleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  9271. doubleRoomFeeStr = $"{(item.DoubleRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  9272. suiteRoomFeeStr = $"{(item.SuiteRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  9273. otherRoomFeeStr = $"{(item.OtherRoomPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  9274. payMoneyStr = $"{(ccpInfo.PayMoney / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  9275. cardPriceStr = $"{(item.CardPrice / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  9276. }
  9277. string breakfastPriceStr = string.Empty,
  9278. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  9279. governmentRentStr = string.Empty,
  9280. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  9281. cityTaxStrStr = string.Empty,
  9282. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  9283. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  9284. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  9285. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  9286. pcfds.Add(new HotelReservations_PCFD_View()
  9287. {
  9288. City = item.City,
  9289. HotelName = item.HotelName,
  9290. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  9291. // SingleRoomCount = item.SingleRoomCount,
  9292. SingleRoomPrice = singleRoomFeeStr,
  9293. // DoubleRoomCount = item.DoubleRoomCount,
  9294. DoubleRoomPrice = doubleRoomFeeStr,
  9295. //SuiteRoomCount = item.SuiteRoomCount,
  9296. SuiteRoomPrice = suiteRoomFeeStr,
  9297. OtherRoomPrice = otherRoomFeeStr,
  9298. //OtherRoomCount = item.OtherRoomCount,
  9299. BreakfastPrice = breakfastPriceStr,
  9300. GovernmentRent = governmentRentStr,
  9301. CityTax = cityTaxStrStr,
  9302. RoomExplanation = item.RoomExplanation,
  9303. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == roomInfo.PayDId).First()?.Name ?? "",
  9304. PayTime = roomInfo.ConsumptionDate,
  9305. BankNo = roomInfo.BankNo,
  9306. PayMoney = payMoneyStr,
  9307. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  9308. ConsumptionPatterns = roomInfo.ConsumptionPatterns,
  9309. CardPrice = cardPriceStr,
  9310. Remark = ccpInfo.Remark
  9311. });
  9312. }
  9313. #endregion
  9314. //载入模板
  9315. WorkbookDesigner designer = new WorkbookDesigner();
  9316. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  9317. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  9318. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  9319. designer.SetDataSource("TourNo", groupInfo.TourCode);
  9320. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  9321. designer.SetDataSource("Opertor", userInfo.CnName);
  9322. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  9323. dt.TableName = "ViewMyHotelReservations";
  9324. designer.SetDataSource(dt);
  9325. designer.Process();
  9326. string fileName = ($"HotelReservation/{groupInfo.TeamName}_酒店预订成本_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls").Replace(":", "");
  9327. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  9328. designer.Workbook.Save(serverPath);
  9329. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  9330. #region 删除指定行
  9331. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  9332. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  9333. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  9334. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  9335. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  9336. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  9337. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  9338. cssIndex = dt.Columns["CityTax"].Ordinal,
  9339. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  9340. remarkIndex = dt.Columns["Remark"].Ordinal;
  9341. //删除指定列
  9342. foreach (DataRow item in dt.Rows)
  9343. {
  9344. string singleStr = item["SingleRoomPrice"].ToString();
  9345. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  9346. if (containsDigitButNotZero1) singleDel = false;
  9347. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  9348. string doubleStr = item["DoubleRoomPrice"].ToString();
  9349. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9350. if (containsDigitButNotZero2) doubleDel = false;
  9351. string suiteStr = item["SuiteRoomPrice"].ToString();
  9352. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  9353. if (containsDigitButNotZero3) suiteDel = false;
  9354. string otherStr = item["OtherRoomPrice"].ToString();
  9355. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  9356. if (containsDigitButNotZero4) otherDel = false;
  9357. string zcStr = item["BreakfastPrice"].ToString();
  9358. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  9359. if (containsDigitButNotZero5) zcDel = false;
  9360. string dsStr = item["GovernmentRent"].ToString();
  9361. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  9362. if (containsDigitButNotZero6) dsDel = false;
  9363. string cssStr = item["CityTax"].ToString();
  9364. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  9365. if (containsDigitButNotZero7) cssDel = false;
  9366. string cpStr = item["ConsumptionPatterns"].ToString();
  9367. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  9368. string remarkStr = item["Remark"].ToString();
  9369. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  9370. }
  9371. DeleteColumn(serverPath, remarkIndex, remarkDel);
  9372. DeleteColumn(serverPath, cpIndex, cpDel);
  9373. DeleteColumn(serverPath, dsIndex, dsDel);
  9374. DeleteColumn(serverPath, cssIndex, cssDel);
  9375. DeleteColumn(serverPath, zcIndex, zcDel);
  9376. DeleteColumn(serverPath, otherIndex, otherDel);
  9377. DeleteColumn(serverPath, suiteIndex, suiteDel);
  9378. DeleteColumn(serverPath, doubleIndex, doubleDel);
  9379. DeleteColumn(serverPath, singleIndex, singleDel);
  9380. #endregion
  9381. //只保留第一个表格
  9382. DeleteSheet(serverPath);
  9383. return Ok(JsonView(true, "操作成功", url = rst));
  9384. }
  9385. /// <summary>
  9386. /// 删除指定列
  9387. /// </summary>
  9388. /// <param name="file"></param>
  9389. /// <param name="columnIndex"></param>
  9390. /// <param name="isDel"></param>
  9391. private void DeleteColumn(string file, int columnIndex, bool isDel)
  9392. {
  9393. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9394. //wb.Save(file);
  9395. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  9396. if (sheet1 != null)
  9397. {
  9398. if (isDel)
  9399. {
  9400. Cells cells = sheet1.Cells;
  9401. cells.DeleteColumn(columnIndex);
  9402. }
  9403. }
  9404. wb.Save(file);
  9405. }
  9406. /// <summary>
  9407. /// 删除sheet
  9408. /// </summary>
  9409. /// <param name="file"></param>
  9410. /// <param name="sheetName"></param>
  9411. private void DeleteSheet(string file, string sheetName = "")
  9412. {
  9413. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  9414. //wb.Save(file);
  9415. List<string> sheets = new List<string>();
  9416. foreach (var item in wb.Worksheets)
  9417. {
  9418. sheets.Add(item.Name);
  9419. }
  9420. if (sheets.Count > 0)
  9421. {
  9422. sheets.RemoveAt(0);//不删除第一个sheet
  9423. foreach (var item in sheets)
  9424. {
  9425. wb.Worksheets.RemoveAt(item);
  9426. }
  9427. }
  9428. wb.Save(file);
  9429. }
  9430. /// <summary>
  9431. /// 酒店预订
  9432. /// 确认单
  9433. /// </summary>
  9434. /// <param name="_dto"></param>
  9435. /// <returns></returns>
  9436. [HttpPost]
  9437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9438. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  9439. {
  9440. try
  9441. {
  9442. #region 参数验证
  9443. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  9444. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  9445. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  9446. #region 团组操作权限验证 76 酒店预定模块
  9447. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  9448. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  9449. #endregion
  9450. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  9451. #region 页面操作权限验证
  9452. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  9453. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  9454. #endregion
  9455. #endregion
  9456. //团组信息
  9457. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  9458. //酒店数据
  9459. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  9460. if (listhoteldata.Count < 0)
  9461. {
  9462. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  9463. }
  9464. //利datatable存储
  9465. DataTable dt = new DataTable();
  9466. dt.Columns.Add("CheckInDate", typeof(string));
  9467. dt.Columns.Add("City", typeof(string));
  9468. dt.Columns.Add("Hotel", typeof(string));
  9469. dt.Columns.Add("Room", typeof(string));
  9470. for (int i = 0; i < listhoteldata.Count; i++)
  9471. {
  9472. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  9473. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  9474. while (dayStart < dayEnd)
  9475. {
  9476. string temp = "";
  9477. DataRow row = dt.NewRow();
  9478. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  9479. row["City"] = listhoteldata[i].City;
  9480. row["Hotel"] = listhoteldata[i].HotelName;
  9481. if (listhoteldata[i].SingleRoomCount > 0)
  9482. {
  9483. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  9484. }
  9485. if (listhoteldata[i].DoubleRoomCount > 0)
  9486. {
  9487. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  9488. }
  9489. if (listhoteldata[i].SuiteRoomCount > 0)
  9490. {
  9491. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  9492. }
  9493. if (listhoteldata[i].OtherRoomCount > 0)
  9494. {
  9495. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  9496. }
  9497. row["Room"] = temp;
  9498. dt.Rows.Add(row);
  9499. dayStart = dayStart.AddDays(1);
  9500. }
  9501. }
  9502. Dictionary<string, string> dic = new Dictionary<string, string>();
  9503. dic.Add("Dele", di.TeamName);
  9504. dic.Add("City", di.VisitCountry);
  9505. //模板路径
  9506. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  9507. //载入模板
  9508. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  9509. DocumentBuilder builder = new DocumentBuilder(doc);
  9510. foreach (var key in dic.Keys)
  9511. {
  9512. builder.MoveToBookmark(key);
  9513. builder.Write(dic[key]);
  9514. }
  9515. //获取word里所有表格
  9516. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9517. //获取所填表格的序数
  9518. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9519. var rowStart = tableOne.Rows[0]; //获取第1行
  9520. //循环赋值
  9521. for (int i = 0; i < dt.Rows.Count; i++)
  9522. {
  9523. builder.MoveToCell(0, i + 1, 0, 0);
  9524. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  9525. builder.MoveToCell(0, i + 1, 1, 0);
  9526. builder.Write(dt.Rows[i]["City"].ToString());
  9527. builder.MoveToCell(0, i + 1, 2, 0);
  9528. builder.Write(dt.Rows[i]["Hotel"].ToString());
  9529. builder.MoveToCell(0, i + 1, 3, 0);
  9530. builder.Write(dt.Rows[i]["Room"].ToString());
  9531. }
  9532. //删除多余行
  9533. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  9534. {
  9535. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  9536. }
  9537. string strFileName = di.TeamName + "酒店确认单.doc";
  9538. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  9539. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  9540. return Ok(JsonView(true, "成功", url));
  9541. }
  9542. catch (Exception ex)
  9543. {
  9544. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  9545. }
  9546. }
  9547. #endregion
  9548. #region 团组状态
  9549. /// <summary>
  9550. /// 团组状态列表 Page
  9551. /// </summary>
  9552. /// <param name="dto">团组列表请求dto</param>
  9553. /// <returns></returns>
  9554. [HttpPost]
  9555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9556. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  9557. {
  9558. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9559. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  9560. {
  9561. string sqlWhere = string.Empty;
  9562. if (dto.IsSure == 0) //未完成
  9563. {
  9564. sqlWhere += string.Format(@" And IsSure = 0");
  9565. }
  9566. else if (dto.IsSure == 1) //已完成
  9567. {
  9568. sqlWhere += string.Format(@" And IsSure = 1");
  9569. }
  9570. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  9571. {
  9572. string tj = dto.SearchCriteria;
  9573. 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}%')",
  9574. tj, tj, tj, tj, tj);
  9575. }
  9576. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  9577. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  9578. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  9579. From (
  9580. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  9581. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  9582. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  9583. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  9584. From Grp_DelegationInfo gdi
  9585. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  9586. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  9587. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  9588. Where gdi.IsDel = 0 {0}
  9589. ) temp ", sqlWhere);
  9590. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  9591. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  9592. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  9593. }
  9594. else
  9595. {
  9596. return Ok(JsonView(false, "查询失败"));
  9597. }
  9598. }
  9599. /// <summary>
  9600. /// 团组状态
  9601. /// 设置操作完成
  9602. /// </summary>
  9603. /// <param name="dto">团组列表请求dto</param>
  9604. /// <returns></returns>
  9605. [HttpPost]
  9606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9607. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  9608. {
  9609. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  9610. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  9611. {
  9612. Id = dto.Id,
  9613. IsSure = 1
  9614. };
  9615. var result = await _sqlSugar.Updateable(_DelegationInfo)
  9616. .UpdateColumns(it => new { it.IsSure })
  9617. .WhereColumns(it => new { it.Id })
  9618. .ExecuteCommandAsync();
  9619. if (result > 0)
  9620. {
  9621. return Ok(JsonView(true, "操作完成!"));
  9622. }
  9623. return Ok(JsonView(false, "操作失败!"));
  9624. }
  9625. #endregion
  9626. #region 保险费用录入
  9627. /// <summary>
  9628. /// 根据团组Id查询保险费用列表
  9629. /// </summary>
  9630. /// <param name="dto"></param>
  9631. /// <returns></returns>
  9632. [HttpPost]
  9633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9634. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  9635. {
  9636. try
  9637. {
  9638. Result groupData = await _customersRep.CustomersByDiId(dto);
  9639. if (groupData.Code != 0)
  9640. {
  9641. return Ok(JsonView(false, groupData.Msg));
  9642. }
  9643. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9644. }
  9645. catch (Exception ex)
  9646. {
  9647. return Ok(JsonView(false, ex.Message));
  9648. }
  9649. }
  9650. /// <summary>
  9651. /// 根据保险费用Id查询保险费用详细
  9652. /// </summary>
  9653. /// <param name="dto"></param>
  9654. /// <returns></returns>
  9655. [HttpPost]
  9656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9657. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  9658. {
  9659. try
  9660. {
  9661. Result groupData = await _customersRep.CustomersById(dto);
  9662. if (groupData.Code != 0)
  9663. {
  9664. return Ok(JsonView(false, groupData.Msg));
  9665. }
  9666. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9667. }
  9668. catch (Exception ex)
  9669. {
  9670. return Ok(JsonView(false, ex.Message));
  9671. }
  9672. }
  9673. /// <summary>
  9674. /// 保险费用录入页面初始化绑定
  9675. /// </summary>
  9676. /// <param name="dto"></param>
  9677. /// <returns></returns>
  9678. [HttpPost]
  9679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9680. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  9681. {
  9682. try
  9683. {
  9684. Result groupData = await _customersRep.CustomersInitialize(dto);
  9685. if (groupData.Code != 0)
  9686. {
  9687. return Ok(JsonView(false, groupData.Msg));
  9688. }
  9689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9690. }
  9691. catch (Exception ex)
  9692. {
  9693. return Ok(JsonView(false, ex.Message));
  9694. }
  9695. }
  9696. /// <summary>
  9697. /// 保险费用操作(Status:1.新增,2.修改)
  9698. /// </summary>
  9699. /// <param name="dto"></param>
  9700. /// <returns></returns>
  9701. [HttpPost]
  9702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9703. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  9704. {
  9705. try
  9706. {
  9707. Result groupData = await _customersRep.OpCustomers(dto);
  9708. if (groupData.Code != 0)
  9709. {
  9710. return Ok(JsonView(false, groupData.Msg));
  9711. }
  9712. #region 应用推送
  9713. try
  9714. {
  9715. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  9716. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  9717. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  9718. }
  9719. catch (Exception ex)
  9720. {
  9721. }
  9722. #endregion
  9723. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9724. }
  9725. catch (Exception ex)
  9726. {
  9727. return Ok(JsonView(false, ex.Message));
  9728. }
  9729. }
  9730. /// <summary>
  9731. /// 保险文件上传
  9732. /// </summary>
  9733. /// <param name="file"></param>
  9734. /// <returns></returns>
  9735. [HttpPost]
  9736. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9737. public async Task<IActionResult> UploadCus(IFormFile file)
  9738. {
  9739. try
  9740. {
  9741. if (file != null)
  9742. {
  9743. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9744. //文件名称
  9745. string projectFileName = file.FileName;
  9746. //上传的文件的路径
  9747. string filePath = "";
  9748. if (!Directory.Exists(fileDir))
  9749. {
  9750. Directory.CreateDirectory(fileDir);
  9751. }
  9752. //上传的文件的路径
  9753. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  9754. using (FileStream fs = System.IO.File.Create(filePath))
  9755. {
  9756. file.CopyTo(fs);
  9757. fs.Flush();
  9758. }
  9759. return Ok(JsonView(true, "上传成功!", projectFileName));
  9760. }
  9761. else
  9762. {
  9763. return Ok(JsonView(false, "上传失败!"));
  9764. }
  9765. }
  9766. catch (Exception ex)
  9767. {
  9768. return Ok(JsonView(false, "程序错误!"));
  9769. throw;
  9770. }
  9771. }
  9772. /// <summary>
  9773. /// 保险删除指定文件
  9774. /// </summary>
  9775. /// <param name="dto"></param>
  9776. /// <returns></returns>
  9777. [HttpPost]
  9778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9779. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  9780. {
  9781. try
  9782. {
  9783. string filePath = "";
  9784. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9785. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  9786. //int id = 0;
  9787. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  9788. // 删除该文件
  9789. try
  9790. {
  9791. System.IO.File.Delete(filePath);
  9792. 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()
  9793. {
  9794. Attachment = "",
  9795. }).ExecuteCommandAsync();
  9796. if (result != 0)
  9797. {
  9798. return Ok(JsonView(true, "成功!"));
  9799. }
  9800. else
  9801. {
  9802. return Ok(JsonView(false, "失败!"));
  9803. }
  9804. }
  9805. catch (Exception)
  9806. {
  9807. 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()
  9808. {
  9809. Attachment = "",
  9810. }).ExecuteCommandAsync();
  9811. if (result != 0)
  9812. {
  9813. return Ok(JsonView(true, "成功!"));
  9814. }
  9815. else
  9816. {
  9817. return Ok(JsonView(false, "失败!"));
  9818. }
  9819. }
  9820. }
  9821. catch (Exception ex)
  9822. {
  9823. return Ok(JsonView(false, "程序错误!"));
  9824. throw;
  9825. }
  9826. }
  9827. /// <summary>
  9828. /// 保险费用操作(删除)
  9829. /// </summary>
  9830. /// <param name="dto"></param>
  9831. /// <returns></returns>
  9832. [HttpPost]
  9833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9834. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  9835. {
  9836. try
  9837. {
  9838. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  9839. if (!res)
  9840. {
  9841. return Ok(JsonView(false, "删除失败"));
  9842. }
  9843. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  9844. {
  9845. IsDel = 1,
  9846. DeleteUserId = dto.DeleteUserId,
  9847. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  9848. }).ExecuteCommandAsync();
  9849. return Ok(JsonView(true, "删除成功!"));
  9850. }
  9851. catch (Exception ex)
  9852. {
  9853. return Ok(JsonView(false, "程序错误!"));
  9854. throw;
  9855. }
  9856. }
  9857. #endregion
  9858. #region 接团客户名单 PageId 104
  9859. /// <summary>
  9860. /// 接团客户名单
  9861. /// 迁移数据(慎用!)
  9862. /// </summary>
  9863. /// <param name="dto"></param>
  9864. /// <returns></returns>
  9865. [HttpPost]
  9866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9867. public async Task<IActionResult> PostTourClientListChange()
  9868. {
  9869. try
  9870. {
  9871. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  9872. //var groupClinetData1
  9873. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  9874. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  9875. int updateCount = 0;
  9876. if (oldOAClientList.Count > 0)
  9877. {
  9878. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  9879. _sqlSugar.BeginTran();
  9880. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  9881. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  9882. foreach (var item in oldOAClientList)
  9883. {
  9884. int comId = 0;
  9885. string format = "yyyy-MM-dd HH:mm:ss";
  9886. string data11 = "1990-01-01 00:00";
  9887. var data1 = IsValidDate(item.OPdate, format);
  9888. if (data1) data11 = item.OPdate;
  9889. //客户公司验证
  9890. if (!string.IsNullOrEmpty(item.Company))
  9891. {
  9892. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  9893. if (clientComInfo == null) // add
  9894. {
  9895. var addInfo = new Crm_CustomerCompany()
  9896. {
  9897. CompanyAbbreviation = "",
  9898. CompanyFullName = item.Company,
  9899. Address = "",
  9900. PostCodes = "",
  9901. LastedOpUserId = item.OPer,
  9902. LastedOpDt = Convert.ToDateTime(data11),
  9903. CreateUserId = item.OPer,
  9904. CreateTime = Convert.ToDateTime(data11),
  9905. IsDel = 0
  9906. };
  9907. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  9908. if (comId1 > 0) comId = comId1;
  9909. }
  9910. else comId = clientComInfo.Id;
  9911. }
  9912. //客户人员验证
  9913. int clientId = 0;
  9914. string name = item.LastName + item.Name;
  9915. if (!string.IsNullOrEmpty(name))
  9916. {
  9917. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  9918. if (clientInfo == null)
  9919. {
  9920. DateTime? dateTime = null;
  9921. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  9922. if (isDt) dateTime = birthDayDt;
  9923. var addInfo1 = new Crm_DeleClient()
  9924. {
  9925. CrmCompanyId = comId,
  9926. DiId = -1,
  9927. LastName = item.LastName,
  9928. FirstName = item.Name,
  9929. OldName = "",
  9930. Pinyin = item.Pinyin,
  9931. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  9932. Marriage = 0,
  9933. Phone = item.Phone,
  9934. Job = item.Job,
  9935. BirthDay = dateTime
  9936. };
  9937. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  9938. if (clientId1 > 0) clientId = clientId1;
  9939. }
  9940. else clientId = clientInfo.Id;
  9941. }
  9942. if (clientId < 1)
  9943. {
  9944. continue;
  9945. }
  9946. int airType = 0;
  9947. if (item.AirType == "超经舱") airType = 459;
  9948. else if (item.AirType == "公务舱") airType = 458;
  9949. else if (item.AirType == "经济舱") airType = 460;
  9950. else if (item.AirType == "其他") airType = 565;
  9951. else if (item.AirType == "头等舱") airType = 457;
  9952. var _TourClientListEntity = new Grp_TourClientList()
  9953. {
  9954. DiId = item.Diid,
  9955. ClientId = clientId,
  9956. CreateUserId = item.OPer,
  9957. CreateTime = Convert.ToDateTime(data11),
  9958. Remark = item.Remark,
  9959. IsDel = item.Isdel,
  9960. ShippingSpaceTypeId = airType,
  9961. ShippingSpaceSpecialNeeds = item.AirRemark,
  9962. HotelSpecialNeeds = item.RoomType
  9963. };
  9964. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  9965. if (_TourClientList > 0)
  9966. {
  9967. updateCount++;
  9968. }
  9969. }
  9970. _sqlSugar.CommitTran();
  9971. }
  9972. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  9973. }
  9974. catch (Exception ex)
  9975. {
  9976. _sqlSugar.RollbackTran();
  9977. return Ok(JsonView(false, ex.Message));
  9978. }
  9979. return Ok(JsonView(true));
  9980. }
  9981. private bool IsValidDate(string dateString, string format)
  9982. {
  9983. DateTime dateValue;
  9984. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  9985. return valid;
  9986. }
  9987. /// <summary>
  9988. /// 接团客户名单
  9989. /// 根据团组Id查询List
  9990. /// </summary>
  9991. /// <param name="dto"></param>
  9992. /// <returns></returns>
  9993. [HttpPost]
  9994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9995. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  9996. {
  9997. #region 参数验证
  9998. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  9999. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10000. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  10001. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10002. #region 页面操作权限验证
  10003. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10004. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10005. #endregion
  10006. #endregion
  10007. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  10008. if (viewData.Code != 0)
  10009. {
  10010. return Ok(JsonView(false, viewData.Msg));
  10011. }
  10012. return Ok(JsonView(viewData.Data));
  10013. }
  10014. /// <summary>
  10015. /// 接团客户名单
  10016. /// 基础数据 Init
  10017. /// </summary>
  10018. /// <param name="_dto"></param>
  10019. /// <returns></returns>
  10020. [HttpPost]
  10021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10022. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  10023. {
  10024. #region 参数验证
  10025. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10026. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10027. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10028. #region 页面操作权限验证
  10029. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10030. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10031. #endregion
  10032. #endregion
  10033. var viewData = await _tourClientListRep._BasicDataInit(_dto.PortType);
  10034. if (viewData.Code != 0)
  10035. {
  10036. return Ok(JsonView(false, viewData.Msg));
  10037. }
  10038. return Ok(JsonView(viewData.Data));
  10039. }
  10040. /// <summary>
  10041. /// 接团客户名单
  10042. /// 根据 Id查询 Details
  10043. /// </summary>
  10044. /// <param name="_dto"></param>
  10045. /// <returns></returns>
  10046. [HttpPost]
  10047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10048. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  10049. {
  10050. #region 参数验证
  10051. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10052. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10053. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10054. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10055. #region 页面操作权限验证
  10056. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10057. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  10058. #endregion
  10059. #endregion
  10060. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  10061. if (viewData.Code != 0)
  10062. {
  10063. return Ok(JsonView(false, viewData.Msg));
  10064. }
  10065. return Ok(JsonView(viewData.Data));
  10066. }
  10067. /// <summary>
  10068. /// 接团客户名单
  10069. /// Add Or Edit
  10070. /// </summary>
  10071. /// <param name="_dto"></param>
  10072. /// <returns></returns>
  10073. [HttpPost]
  10074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10075. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  10076. {
  10077. #region 参数验证
  10078. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10079. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10080. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  10081. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10082. #region 页面操作权限验证
  10083. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10084. if (_dto.Id == 0) //添加
  10085. {
  10086. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10087. }
  10088. else if (_dto.Id >= 0) //修改
  10089. {
  10090. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  10091. }
  10092. #endregion
  10093. #endregion
  10094. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  10095. if (viewData.Code != 0)
  10096. {
  10097. return Ok(JsonView(false, viewData.Msg));
  10098. }
  10099. return Ok(JsonView(true));
  10100. }
  10101. /// <summary>
  10102. /// 接团客户名单
  10103. /// AddMultiple(添加多个)
  10104. /// </summary>
  10105. /// <param name="_dto"></param>
  10106. /// <returns></returns>
  10107. [HttpPost]
  10108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10109. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  10110. {
  10111. #region 参数验证
  10112. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10113. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10115. #region 页面操作权限验证
  10116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10117. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  10118. #endregion
  10119. #endregion
  10120. var viewData = await _tourClientListRep._AddMultiple(_dto);
  10121. if (viewData.Code != 0)
  10122. {
  10123. return Ok(JsonView(false, viewData.Msg));
  10124. }
  10125. return Ok(JsonView(true));
  10126. }
  10127. /// <summary>
  10128. /// 接团客户名单
  10129. /// Del
  10130. /// </summary>
  10131. /// <param name="_dto"></param>
  10132. /// <returns></returns>
  10133. [HttpPost]
  10134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10135. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  10136. {
  10137. #region 参数验证
  10138. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10139. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10140. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10141. #region 页面操作权限验证
  10142. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10143. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  10144. #endregion
  10145. #endregion
  10146. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  10147. if (viewData.Code != 0)
  10148. {
  10149. return Ok(JsonView(false, viewData.Msg));
  10150. }
  10151. return Ok(JsonView(true));
  10152. }
  10153. /// <summary>
  10154. /// 接团客户名单
  10155. /// 文件下载 客户名单
  10156. /// </summary>
  10157. /// <param name="_dto"></param>
  10158. /// <returns></returns>
  10159. [HttpPost]
  10160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10161. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  10162. {
  10163. #region 参数验证
  10164. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  10165. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  10166. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  10167. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10168. #region 页面操作权限验证
  10169. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  10170. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  10171. #endregion
  10172. #endregion
  10173. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  10174. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  10175. From Grp_TourClientList tcl
  10176. Left Join
  10177. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  10178. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  10179. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  10180. From Crm_DeleClient dc
  10181. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  10182. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  10183. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  10184. Where dc.IsDel = 0) temp
  10185. On temp.DcId =tcl.ClientId
  10186. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  10187. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  10188. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  10189. //载入模板
  10190. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  10191. if (_dto.Language == 1)
  10192. {
  10193. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  10194. }
  10195. //载入模板
  10196. var doc = new Document(tempPath);
  10197. DocumentBuilder builder = new DocumentBuilder(doc);
  10198. //获取word里所有表格
  10199. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10200. //获取所填表格的序数
  10201. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10202. var rowStart = tableOne.Rows[0]; //获取第1行
  10203. if (_dto.Language == 0)
  10204. {
  10205. //循环赋值
  10206. for (int i = 0; i < DcList.Count; i++)
  10207. {
  10208. builder.MoveToCell(0, i + 1, 0, 0);
  10209. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  10210. builder.MoveToCell(0, i + 1, 1, 0);
  10211. int sex = DcList[i].Sex;
  10212. string sexStr = string.Empty;
  10213. if (sex == 0) sexStr = "男";
  10214. else if (sex == 1) sexStr = "女";
  10215. else sexStr = "未设置";
  10216. builder.Write(sexStr);
  10217. builder.MoveToCell(0, i + 1, 2, 0);
  10218. string birthDay = DcList[i].BirthDay;
  10219. string birthDayStr = string.Empty;
  10220. if (!string.IsNullOrEmpty(birthDay))
  10221. {
  10222. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  10223. }
  10224. builder.Write(birthDayStr);
  10225. builder.MoveToCell(0, i + 1, 3, 0);
  10226. string company = "";
  10227. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10228. {
  10229. company = DcList[i].CompanyFullName.ToString();
  10230. }
  10231. builder.Write(company);
  10232. builder.MoveToCell(0, i + 1, 4, 0);
  10233. builder.Write(DcList[i].Job);
  10234. }
  10235. }
  10236. else if (_dto.Language == 1)
  10237. {
  10238. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  10239. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  10240. //循环赋值
  10241. for (int i = 0; i < DcList.Count; i++)
  10242. {
  10243. string PYName = "";
  10244. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  10245. {
  10246. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  10247. string PY_First = DcList[i].Pinyin.Split('/')[1];
  10248. PYName = PY_First + " " + PY_Last;
  10249. }
  10250. else
  10251. {
  10252. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  10253. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  10254. PYName = PY_First + " " + PY_Last;
  10255. }
  10256. builder.MoveToCell(0, i + 1, 0, 0);
  10257. builder.Write(PYName);
  10258. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  10259. builder.MoveToCell(0, i + 1, 1, 0);
  10260. builder.Write(sex);
  10261. DateTime birthDt;
  10262. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  10263. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : "";
  10264. builder.MoveToCell(0, i + 1, 2, 0);
  10265. builder.Write(birthday);
  10266. string company = "";
  10267. try
  10268. {
  10269. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  10270. {
  10271. //查询对照表
  10272. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  10273. if (tempCec != null)
  10274. {
  10275. company = tempCec.enName;
  10276. }
  10277. //翻译
  10278. else
  10279. {
  10280. company = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].CompanyFullName.ToString().Trim());
  10281. }
  10282. }
  10283. }
  10284. catch (Exception)
  10285. {
  10286. }
  10287. builder.MoveToCell(0, i + 1, 3, 0);
  10288. builder.Write(company);
  10289. string job = "";
  10290. try
  10291. {
  10292. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  10293. {
  10294. //查询对照表
  10295. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  10296. if (tempPec != null)
  10297. {
  10298. job = tempPec.enName;
  10299. }
  10300. //翻译
  10301. else
  10302. {
  10303. job = await YouDaoApiTools.GetOCR_ReTrans(DcList[i].Job.ToString().Trim());
  10304. }
  10305. }
  10306. }
  10307. catch (Exception ex)
  10308. {
  10309. }
  10310. builder.MoveToCell(0, i + 1, 4, 0);
  10311. builder.Write(job);
  10312. }
  10313. }
  10314. //删除多余行
  10315. while (tableOne.Rows.Count > DcList.Count + 1)
  10316. {
  10317. tableOne.Rows.RemoveAt(DcList.Count + 1);
  10318. }
  10319. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  10320. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  10321. doc.Save(fileDir);
  10322. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  10323. return Ok(JsonView(true, "操作成功!", Url));
  10324. }
  10325. #endregion
  10326. #region 团组倒推表
  10327. /// <summary>
  10328. /// 倒推表基础数据
  10329. /// Init
  10330. /// </summary>
  10331. /// <param name="dto"></param>
  10332. /// <returns></returns>
  10333. [HttpPost]
  10334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10335. public async Task<IActionResult> PostInvertedListInit()
  10336. {
  10337. var viewData = await _invertedListRep._Init();
  10338. if (viewData.Code != 0)
  10339. {
  10340. return Ok(JsonView(false, viewData.Msg));
  10341. }
  10342. return Ok(JsonView(viewData.Data));
  10343. }
  10344. /// <summary>
  10345. /// 倒推表
  10346. /// Info
  10347. /// </summary>
  10348. /// <param name="dto"></param>
  10349. /// <returns></returns>
  10350. [HttpPost]
  10351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10352. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  10353. {
  10354. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  10355. if (viewData.Code != 0)
  10356. {
  10357. return Ok(JsonView(false, viewData.Msg));
  10358. }
  10359. return Ok(JsonView(viewData.Data));
  10360. }
  10361. /// <summary>
  10362. /// 倒推表
  10363. /// Create
  10364. /// </summary>
  10365. /// <param name="dto"></param>
  10366. /// <returns></returns>
  10367. [HttpPost]
  10368. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10369. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  10370. {
  10371. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  10372. if (viewData.Code != 0)
  10373. {
  10374. return Ok(JsonView(false, viewData.Msg));
  10375. }
  10376. return Ok(JsonView(viewData.Data));
  10377. }
  10378. /// <summary>
  10379. /// 倒推表
  10380. /// Update
  10381. /// </summary>
  10382. /// <param name="dto"></param>
  10383. /// <returns></returns>
  10384. [HttpPost]
  10385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10386. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  10387. {
  10388. var viewData = await _invertedListRep._Update(dto);
  10389. if (viewData.Code != 0)
  10390. {
  10391. return Ok(JsonView(false, viewData.Msg));
  10392. }
  10393. return Ok(JsonView(viewData.Data));
  10394. }
  10395. /// <summary>
  10396. /// 倒推表
  10397. /// File Download
  10398. /// </summary>
  10399. /// <param name="dto"></param>
  10400. /// <returns></returns>
  10401. [HttpPost]
  10402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10403. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  10404. {
  10405. var info2 = await _invertedListRep._Info(1, dto.DiId);
  10406. if (info2.Code != 0)
  10407. {
  10408. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  10409. }
  10410. var info1 = info2.Data as InvertedListInfoView;
  10411. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  10412. string teamName = "";
  10413. if (info != null) teamName = info.TeamName;
  10414. //载入模板
  10415. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  10416. DocumentBuilder builder = new DocumentBuilder(doc);
  10417. //利用键值对存放数据
  10418. Dictionary<string, string> dic = new Dictionary<string, string>();
  10419. dic.Add("TeamName", teamName);
  10420. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  10421. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  10422. dic.Add("BPRemark", info1.ApprovalDataRemark);
  10423. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  10424. dic.Add("SQRemark", info1.ApprovalRemark);
  10425. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  10426. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  10427. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  10428. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  10429. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  10430. dic.Add("QZRemark", info1.VisaInformationRemark);
  10431. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  10432. dic.Add("SQQZRemark", info1.SendVisaRemark);
  10433. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  10434. dic.Add("CQRemark", info1.IssueVisaRemark);
  10435. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  10436. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  10437. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  10438. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  10439. #region 填充word模板书签内容
  10440. foreach (var key in dic.Keys)
  10441. {
  10442. builder.MoveToBookmark(key);
  10443. builder.Write(dic[key]);
  10444. }
  10445. #endregion
  10446. var fileDir = AppSettingsHelper.Get("WordBasePath");
  10447. string fileName = $"{teamName}团出行准备流程表.doc";
  10448. string filePath = fileDir + $@"InvertedList/{fileName}";
  10449. doc.Save(filePath);
  10450. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  10451. return Ok(JsonView(true, "操作成功!", Url));
  10452. }
  10453. #endregion
  10454. #region 三公签证费用(签证费、代办费)
  10455. /// <summary>
  10456. /// 三公签证费用(签证费、代办费)
  10457. /// List
  10458. /// </summary>
  10459. /// <returns></returns>
  10460. [HttpPost]
  10461. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10462. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  10463. {
  10464. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  10465. if (_view.Code != 0)
  10466. {
  10467. return Ok(JsonView(false, _view.Msg));
  10468. }
  10469. return Ok(JsonView(true, "操作成功!", _view.Data));
  10470. }
  10471. /// <summary>
  10472. /// 三公签证费用(签证费、代办费)
  10473. /// Add Or Update
  10474. /// </summary>
  10475. /// <returns></returns>
  10476. [HttpPost]
  10477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10478. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  10479. {
  10480. var _view = await _visaFeeInfoRep._Update(_dto);
  10481. if (_view.Code != 0)
  10482. {
  10483. return Ok(JsonView(false, _view.Msg));
  10484. }
  10485. return Ok(JsonView(true, _view.Msg));
  10486. }
  10487. #endregion
  10488. #region 酒店询价
  10489. /// <summary>
  10490. /// 酒店询价
  10491. /// Init
  10492. /// </summary>
  10493. /// <param name="dto"></param>
  10494. /// <returns></returns>
  10495. [HttpPost]
  10496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10497. public async Task<IActionResult> PostHotelInquiryInit()
  10498. {
  10499. var res = await _hotelInquiryRep._Init();
  10500. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10501. return Ok(JsonView(true, res.Msg, res.Data));
  10502. }
  10503. /// <summary>
  10504. /// 酒店询价
  10505. /// page Item
  10506. /// </summary>
  10507. /// <param name="_dto"></param>
  10508. /// <returns></returns>
  10509. [HttpPost]
  10510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10511. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  10512. {
  10513. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  10514. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10515. var view = res.Data as PageDataViewBase;
  10516. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  10517. }
  10518. /// <summary>
  10519. /// 酒店询价
  10520. /// info
  10521. /// </summary>
  10522. /// <param name="_dto"></param>
  10523. /// <returns></returns>
  10524. [HttpPost]
  10525. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10526. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  10527. {
  10528. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  10529. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10530. return Ok(JsonView(true, res.Msg, res.Data));
  10531. }
  10532. /// <summary>
  10533. /// 酒店询价
  10534. /// Add Or Edit
  10535. /// </summary>
  10536. /// <param name="_dto"></param>
  10537. /// <returns></returns>
  10538. [HttpPost]
  10539. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10540. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  10541. {
  10542. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  10543. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10544. return Ok(JsonView(true, res.Msg, res.Data));
  10545. }
  10546. /// <summary>
  10547. /// 酒店询价
  10548. /// Del
  10549. /// </summary>
  10550. /// <param name="_dto"></param>
  10551. /// <returns></returns>
  10552. [HttpPost]
  10553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10554. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  10555. {
  10556. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  10557. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  10558. return Ok(JsonView(true, res.Msg, res.Data));
  10559. }
  10560. #endregion
  10561. #region 下载匹配op行程单
  10562. /// <summary>
  10563. /// 匹配op行程单
  10564. /// Init
  10565. /// </summary>
  10566. /// <param name="dto">团组列表请求dto</param>
  10567. /// <returns></returns>
  10568. [HttpPost]
  10569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10570. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  10571. {
  10572. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10573. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10574. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  10575. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  10576. if (isDepStatus)
  10577. {
  10578. groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.JietuanOperator == dto.CurrUserId).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10579. }
  10580. else
  10581. {
  10582. groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  10583. }
  10584. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  10585. var diids = groupInfos.Select(it => it.Id).ToList();
  10586. List<string> countrys = new List<string>();
  10587. foreach (var item in country)
  10588. {
  10589. var data = _groupRepository.FormartTeamName(item);
  10590. var dataArray = _groupRepository.GroupSplitCountry(data);
  10591. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  10592. }
  10593. countrys = countrys.Distinct().ToList();
  10594. for (int i = 0; i < countrys.Count; i++)
  10595. {
  10596. string item = countrys[i];
  10597. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10598. {
  10599. countrys.Remove(item);
  10600. i--;
  10601. }
  10602. }
  10603. List<string> areaArray = new List<string>(); //GetGroupCityLine
  10604. foreach (var item in diids)
  10605. {
  10606. string areaStr = GeneralMethod.GetGroupCityLine(item, "-");
  10607. if (!string.IsNullOrEmpty(areaStr))
  10608. {
  10609. string[] str1 = areaStr.Split("-");
  10610. if (str1.Length > 0)
  10611. {
  10612. areaArray.AddRange(str1);
  10613. }
  10614. }
  10615. }
  10616. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  10617. List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10618. string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10619. if (string.IsNullOrEmpty(countriesDataStr))
  10620. {
  10621. cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10622. TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10623. await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10624. }
  10625. else
  10626. {
  10627. cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10628. }
  10629. List<Sys_Cities> existCitys = new List<Sys_Cities>();
  10630. var existCitys1 = cityDatas.Where(it => areaArray.Contains(it.Name_CN)).Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN }).ToList();
  10631. List<int> countriesIds = existCitys1.Select(it => it.parentId).ToList();
  10632. var countriesDatas = await _sqlSugar.Queryable<Sys_Countries>()
  10633. .Where(it => countriesIds.Contains(it.Id))
  10634. .Select(it => new { it.Id, Name = it.Name_CN })
  10635. .ToListAsync();
  10636. //var countryDatas = countriesDatas.Select(it => new
  10637. //{
  10638. // id = it.Id,
  10639. // name = it.Name,
  10640. // childList = existCitys.Where(it1 => it1.CountriesId == it.Id).Select(it1 => new { parentId = it1.CountriesId, id = it1.Id, name = it1.Name_CN }).ToList()
  10641. //}).ToList();
  10642. var teamNames = groupInfos.Select(it => it.TeamName).ToList();
  10643. for (int i = 0; i < teamNames.Count; i++)
  10644. {
  10645. string item = teamNames[i];
  10646. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  10647. {
  10648. teamNames.Remove(item);
  10649. i--;
  10650. }
  10651. }
  10652. stopwatch.Stop();
  10653. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames,countriesDatas, citiesDatas = existCitys1 }));
  10654. }
  10655. ///// <summary>
  10656. ///// 匹配op行程单
  10657. ///// Init 查询区域数据
  10658. ///// </summary>
  10659. ///// <param name="dto">团组列表请求dto</param>
  10660. ///// <returns></returns>
  10661. //[HttpPost]
  10662. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10663. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  10664. //{
  10665. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  10666. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  10667. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  10668. // if (string.IsNullOrEmpty(countriesDataStr))
  10669. // {
  10670. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  10671. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  10672. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  10673. // }
  10674. // else
  10675. // {
  10676. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  10677. // }
  10678. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  10679. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  10680. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  10681. // List<dynamic> childList = new List<dynamic>();
  10682. // int parentId = dto.CountriesId;
  10683. // if (provinceData.Count > 1)
  10684. // {
  10685. // foreach (var item1 in provinceData)
  10686. // {
  10687. // List<dynamic> childList1 = new List<dynamic>();
  10688. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  10689. // foreach (var item2 in citiesData1)
  10690. // {
  10691. // List<dynamic> childList2 = new List<dynamic>();
  10692. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10693. // foreach (var item3 in countiesData1)
  10694. // {
  10695. // childList2.Add(new
  10696. // {
  10697. // id = item3.Id,
  10698. // parentId = item2.Id,
  10699. // level = "district",
  10700. // name = item3.Name_CN,
  10701. // });
  10702. // }
  10703. // childList1.Add(new
  10704. // {
  10705. // id = item2.Id,
  10706. // parentId = item1.Id,
  10707. // level = "city",
  10708. // name = item2.Name_CN,
  10709. // childList = childList2
  10710. // });
  10711. // }
  10712. // childList.Add(new
  10713. // {
  10714. // id = item1.Id,
  10715. // parentId = parentId,
  10716. // level = "province",
  10717. // name = item1.Name_CN,
  10718. // childList = childList1
  10719. // });
  10720. // }
  10721. // //城市
  10722. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  10723. // foreach (var item2 in citiesData2)
  10724. // {
  10725. // List<dynamic> childList22 = new List<dynamic>();
  10726. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10727. // foreach (var item3 in countiesData1)
  10728. // {
  10729. // childList22.Add(new
  10730. // {
  10731. // id = item3.Id,
  10732. // parentId = item2.Id,
  10733. // level = "district",
  10734. // name = item3.Name_CN,
  10735. // });
  10736. // }
  10737. // childList.Add(new
  10738. // {
  10739. // id = item2.Id,
  10740. // parentId = parentId,
  10741. // level = "city",
  10742. // name = item2.Name_CN,
  10743. // childList = childList22
  10744. // });
  10745. // }
  10746. // }
  10747. // else
  10748. // {
  10749. // foreach (var item2 in citiesData)
  10750. // {
  10751. // string cname = item2.Name_CN;
  10752. // List<dynamic> childList1 = new List<dynamic>();
  10753. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  10754. // foreach (var item3 in countiesData1)
  10755. // {
  10756. // childList1.Add(new
  10757. // {
  10758. // Id = item3.Id,
  10759. // parentId = item2.Id,
  10760. // level = "district",
  10761. // name = item3.Name_CN
  10762. // });
  10763. // }
  10764. // childList.Add(new
  10765. // {
  10766. // id = item2.Id,
  10767. // parentId = parentId,
  10768. // level = "city",
  10769. // name = item2.Name_CN,
  10770. // childList = childList1
  10771. // });
  10772. // }
  10773. // }
  10774. // stopwatch.Stop();
  10775. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  10776. //}
  10777. /// <summary>
  10778. /// 匹配op行程单
  10779. /// 接团信息列表 Page
  10780. /// </summary>
  10781. /// <param name="dto">团组列表请求dto</param>
  10782. /// <returns></returns>
  10783. [HttpPost]
  10784. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10785. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  10786. {
  10787. #region 参数验证
  10788. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10789. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10790. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10791. #region 页面操作权限验证
  10792. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10793. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  10794. #endregion
  10795. #endregion
  10796. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10797. {
  10798. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  10799. string sqlWhere = "";
  10800. if (!string.IsNullOrEmpty(dto.Country))
  10801. {
  10802. _view = _view.Where(x => x.VisitCountry != null && x.VisitCountry.Contains(dto.Country)).ToList();
  10803. }
  10804. if (!string.IsNullOrEmpty(dto.Area))
  10805. {
  10806. _view = _view.Where(x => x.RouteCity != null && x.RouteCity.Contains(dto.Area)).ToList();
  10807. }
  10808. if (!string.IsNullOrEmpty(dto.TeamName))
  10809. {
  10810. _view = _view.Where(x => x.TeamName != null && x.TeamName.Contains(dto.TeamName)).ToList();
  10811. }
  10812. return Ok(JsonView(true, "查询成功!", _view.Skip(dto.PageIndex).Take(dto.PageSize).ToList(), _view.Count));
  10813. }
  10814. else
  10815. {
  10816. return Ok(JsonView(false, "查询失败"));
  10817. }
  10818. }
  10819. /// <summary>
  10820. /// 匹配op行程单
  10821. /// 行程单下载
  10822. /// </summary>
  10823. /// <param name="dto">团组列表请求dto</param>
  10824. /// <returns></returns>
  10825. [HttpPost]
  10826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10827. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  10828. {
  10829. #region 参数验证
  10830. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  10831. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  10832. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  10833. #region 页面操作权限验证
  10834. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  10835. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  10836. #endregion
  10837. #endregion
  10838. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  10839. {
  10840. var res = ExportTravel(new InitOpTravelDto() { Diid = dto.diId });
  10841. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  10842. }
  10843. else
  10844. {
  10845. return Ok(JsonView(false, "下载失败!"));
  10846. }
  10847. }
  10848. #endregion
  10849. #region 国家信息 数据 注释
  10850. //[HttpPost]
  10851. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  10852. //{
  10853. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  10854. // foreach (var item in dto)
  10855. // {
  10856. // infos.Add(new Grp_GroupsTaskAssignment()
  10857. // {
  10858. // DIId = item,
  10859. // CTId = 82,
  10860. // UId = 248,
  10861. // IsEnable = 1,
  10862. // CreateUserId = 233,
  10863. // CreateTime = DateTime.Now,
  10864. // IsDel = 0
  10865. // });
  10866. // infos.Add(new Grp_GroupsTaskAssignment()
  10867. // {
  10868. // DIId = item,
  10869. // CTId = 82,
  10870. // UId = 286,
  10871. // IsEnable = 1,
  10872. // CreateUserId = 233,
  10873. // CreateTime = DateTime.Now,
  10874. // IsDel = 0
  10875. // });
  10876. // }
  10877. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  10878. // return Ok("操作成功");
  10879. //}
  10880. //public class paramJsonDto
  10881. //{
  10882. // public List<CountriesInfo> str { get; set; }
  10883. //}
  10884. //[HttpPost]
  10885. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  10886. //{
  10887. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  10888. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  10889. // List<Sys_Cities> cities = new List<Sys_Cities>();
  10890. // List<Sys_Cities> districts = new List<Sys_Cities>();
  10891. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  10892. // _sqlSugar.BeginTran();
  10893. // int countitiesIndex = 0;
  10894. // foreach (var item in dto.str)
  10895. // {
  10896. // dynamic data = item.c;
  10897. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  10898. // if (data != null)
  10899. // {
  10900. // countitiesIndex++;
  10901. // foreach (var item1 in data)
  10902. // {
  10903. // string cnname = item1.cn;
  10904. // string enname = item1.en;
  10905. // Sys_Cities provinceInfo = new Sys_Cities()
  10906. // {
  10907. // CountriesId = countriesId,
  10908. // Name_CN = cnname,
  10909. // Name_EN = enname,
  10910. // ParentId = 0,
  10911. // IsCapital = 1,
  10912. // CreateUserId = 208,
  10913. // CreateTime = DateTime.Now,
  10914. // IsDel = 0
  10915. // };
  10916. // if (item1.lv == "province") //省份
  10917. // {
  10918. // provinceInfo.Level = 1;
  10919. // int provinceId = 0;
  10920. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  10921. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  10922. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10923. // var data1 = item1.c;
  10924. // foreach (var item2 in data1)
  10925. // {
  10926. // if (item2.lv == "city")
  10927. // {
  10928. // string citycnname = item2.cn;
  10929. // string cityenname = item2.en;
  10930. // Sys_Cities cityInfo = new Sys_Cities()
  10931. // {
  10932. // CountriesId = countriesId,
  10933. // ParentId = provinceId,
  10934. // Level = 2,
  10935. // Name_CN = citycnname,
  10936. // Name_EN = cityenname,
  10937. // IsCapital = 1,
  10938. // CreateUserId = 208,
  10939. // CreateTime = DateTime.Now,
  10940. // IsDel = 0
  10941. // };
  10942. // if (item2.c != null)
  10943. // {
  10944. // int cityId = 0;
  10945. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  10946. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10947. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  10948. // foreach (var item3 in item2.c)
  10949. // {
  10950. // if (item3.lv == "district")
  10951. // {
  10952. // var districtInfo = new Sys_Cities()
  10953. // {
  10954. // CountriesId = countriesId,
  10955. // Name_CN = item3.cn,
  10956. // Name_EN = item3.en,
  10957. // Level = 3,
  10958. // ParentId = cityId,
  10959. // IsCapital = 1,
  10960. // CreateUserId = 208,
  10961. // CreateTime = DateTime.Now,
  10962. // IsDel = 0
  10963. // };
  10964. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  10965. // //{
  10966. // districts.Add(districtInfo);
  10967. // //}
  10968. // }
  10969. // }
  10970. // }
  10971. // else
  10972. // {
  10973. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  10974. // //{
  10975. // cities.Add(cityInfo);
  10976. // //}
  10977. // }
  10978. // }
  10979. // }
  10980. // }
  10981. // else if (item1.lv == "city")//城市
  10982. // {
  10983. // provinceInfo.Level = 2;
  10984. // if (item1.c != null)
  10985. // {
  10986. // int cityId = 0;
  10987. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  10988. // if (citiesInfo != null) cityId = citiesInfo.Id;
  10989. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  10990. // foreach (var item3 in item1.c)
  10991. // {
  10992. // if (item3.lv == "district")
  10993. // {
  10994. // var districtInfo = new Sys_Cities()
  10995. // {
  10996. // CountriesId = countriesId,
  10997. // Name_CN = item3.cn,
  10998. // Name_EN = item3.en,
  10999. // Level = 3,
  11000. // ParentId = cityId,
  11001. // IsCapital = 1,
  11002. // CreateUserId = 208,
  11003. // CreateTime = DateTime.Now,
  11004. // IsDel = 0
  11005. // };
  11006. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  11007. // //{
  11008. // districts.Add(districtInfo);
  11009. // //}
  11010. // }
  11011. // }
  11012. // }
  11013. // else
  11014. // {
  11015. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  11016. // //{
  11017. // cities.Add(provinceInfo);
  11018. // //}
  11019. // }
  11020. // }
  11021. // }
  11022. // }
  11023. // }
  11024. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  11025. // cities = cities.Distinct().ToList();
  11026. // districts = districts.Distinct().ToList();
  11027. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  11028. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  11029. // cities.AddRange(districts);
  11030. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  11031. // //_sqlSugar.RollbackTran();
  11032. // _sqlSugar.CommitTran();
  11033. // return Ok(JsonView(false, "操作成功!"));
  11034. //}
  11035. //[HttpPost]
  11036. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  11037. //{
  11038. // List<CountitiesInfo> infos = dto.MyProperty;
  11039. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  11040. // _sqlSugar.BeginTran();
  11041. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  11042. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  11043. // foreach (var item in infos)
  11044. // {
  11045. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  11046. // if (countryInfo != null)
  11047. // {
  11048. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  11049. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  11050. // if (cityInfo1 != null)
  11051. // {
  11052. // cityInfo1.IsCapital = 0;
  11053. // cityInfos.Add(cityInfo1);
  11054. // }
  11055. // }
  11056. // }
  11057. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  11058. // .UpdateColumns(it => it.IsCapital)
  11059. // .WhereColumns(it => it.Id)
  11060. // .ExecuteCommand();
  11061. // //_sqlSugar.RollbackTran();
  11062. // _sqlSugar.CommitTran();
  11063. // return Ok(JsonView(false, "操作成功!"));
  11064. //}
  11065. //public class CounrtiesDto
  11066. //{
  11067. // public List<CountitiesInfo> MyProperty { get; set; }
  11068. //}
  11069. //public class CountitiesInfo
  11070. //{
  11071. // /// <summary>
  11072. // /// 圣约翰
  11073. // /// </summary>
  11074. // public string capital_name_chinese { get; set; }
  11075. // /// <summary>
  11076. // ///
  11077. // /// </summary>
  11078. // public string capital_name { get; set; }
  11079. // /// <summary>
  11080. // ///
  11081. // /// </summary>
  11082. // public string country_type { get; set; }
  11083. // /// <summary>
  11084. // /// 安提瓜和巴布达
  11085. // /// </summary>
  11086. // public string country_name_chinese { get; set; }
  11087. // /// <summary>
  11088. // /// 安提瓜和巴布达
  11089. // /// </summary>
  11090. // public string country_name_chinese_short { get; set; }
  11091. // /// <summary>
  11092. // /// 安提瓜和巴布达
  11093. // /// </summary>
  11094. // public string country_name_chinese_UN { get; set; }
  11095. // /// <summary>
  11096. // ///
  11097. // /// </summary>
  11098. // public string country_name_english_abbreviation { get; set; }
  11099. // /// <summary>
  11100. // ///
  11101. // /// </summary>
  11102. // public string country_name_english_formal { get; set; }
  11103. // /// <summary>
  11104. // ///
  11105. // /// </summary>
  11106. // public string country_name_english_UN { get; set; }
  11107. // /// <summary>
  11108. // ///
  11109. // /// </summary>
  11110. // public string continent_name { get; set; }
  11111. // /// <summary>
  11112. // ///
  11113. // /// </summary>
  11114. // public string subregion_name { get; set; }
  11115. // /// <summary>
  11116. // ///
  11117. // /// </summary>
  11118. // public string country_code2 { get; set; }
  11119. // /// <summary>
  11120. // ///
  11121. // /// </summary>
  11122. // public string country_code3 { get; set; }
  11123. // /// <summary>
  11124. // ///
  11125. // /// </summary>
  11126. // public string phone_code { get; set; }
  11127. //}
  11128. //public class CountriesInfo : BasicInfo
  11129. //{
  11130. // public List<CitiesInfo> c { get; set; }
  11131. //}
  11132. //public class CitiesInfo : BasicInfo
  11133. //{
  11134. // public List<AreaInfo> c { get; set; }
  11135. //}
  11136. //public class AreaInfo : BasicInfo
  11137. //{
  11138. // public List<AreaInfo> c { get; set; }
  11139. //}
  11140. //public class BasicInfo
  11141. //{
  11142. // public string code { get; set; }
  11143. // public string cn { get; set; }
  11144. // public string lv { get; set; }
  11145. // public string en { get; set; }
  11146. //}
  11147. #endregion
  11148. #region 报批行程
  11149. /// <summary>
  11150. /// 报批行程初始化
  11151. /// </summary>
  11152. /// <param name="dto"></param>
  11153. /// <returns></returns>
  11154. [HttpPost]
  11155. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  11156. {
  11157. const int chiNumber = 5;
  11158. var jw = JsonView(false);
  11159. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11160. var group = groupList.First();
  11161. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11162. group = groupList.First(x => x.Id == diid);
  11163. if (group == null)
  11164. {
  11165. jw.Msg = "暂无团组!";
  11166. return Ok(jw);
  11167. }
  11168. var resultArr = new ArrayList();
  11169. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  11170. if (content.Count == 0)
  11171. {
  11172. ////黑屏代码数据
  11173. //DataTable dt = GetTableByBlackCode(group.Id);
  11174. //if (dt.Rows[0]["Day"] == null || dt.Rows[0]["Day"].ToString() == "")//判断黑屏代码数据是否正确生成
  11175. //{
  11176. //}
  11177. //else
  11178. //{
  11179. // jw.Msg = "黑屏代码有误!";
  11180. // return Ok(jw);
  11181. //}
  11182. DateTime StartDate = (group.VisitStartDate);
  11183. DateTime EndDate = (group.VisitEndDate);
  11184. TimeSpan t3 = EndDate - StartDate; //两个时间相减 。默认得到的是 两个时间之间的天数 得到:365.00:00:00
  11185. var getDay = t3.Days;
  11186. if (getDay == 0) getDay = 1;
  11187. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11188. _sqlSugar.BeginTran();
  11189. for (int i = 0; i < getDay; i++)
  11190. {
  11191. DateTime NewData = StartDate.AddDays(i);
  11192. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11193. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11194. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11195. appro.Diid = diid ?? -1;
  11196. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11197. appro.Id = thisId;
  11198. appro.CreateUserId = dto.UserId;
  11199. appro.CreateTime = DateTime.Now;
  11200. content.Add(appro);
  11201. }
  11202. _sqlSugar.CommitTran();
  11203. }
  11204. foreach (var x in content)
  11205. {
  11206. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  11207. if (chiList.Count < chiNumber)
  11208. {
  11209. for (int i = chiList.Count; i < chiNumber; i++)
  11210. {
  11211. chiList.Add(new Grp_ApprovalTravelDetails());
  11212. }
  11213. }
  11214. resultArr.Add(new
  11215. {
  11216. x.Id,
  11217. x.Date,
  11218. x.Diid,
  11219. chiList = chiList.Select(x1 => new
  11220. {
  11221. timeInterval = x1.Time == null ? new string [1] : x1.Time.Split('-'),
  11222. x1.Details,
  11223. x1.ParentId,
  11224. x1.Id
  11225. })
  11226. });
  11227. }
  11228. var data = new
  11229. {
  11230. groupList = groupList.Select(x => new
  11231. {
  11232. x.TeamName,
  11233. x.Id
  11234. }),
  11235. content = resultArr,
  11236. groupInfo = new
  11237. {
  11238. group.VisitDays,
  11239. group.TourCode,
  11240. group.VisitPNumber,
  11241. group.TeamName,
  11242. group.Id,
  11243. group.VisitStartDate,
  11244. group.VisitEndDate
  11245. },
  11246. };
  11247. jw = JsonView(true,"获取成功!",data);
  11248. return Ok(jw);
  11249. }
  11250. /// <summary>
  11251. /// 报批行程删除
  11252. /// </summary>
  11253. /// <param name="dto"></param>
  11254. /// <returns></returns>
  11255. [HttpPost]
  11256. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  11257. {
  11258. var jw = JsonView(false);
  11259. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x=>x.Id == dto.Diid && x.IsDel == 0);
  11260. if (group == null)
  11261. {
  11262. jw.Msg = "团组参数有误!";
  11263. return Ok(jw);
  11264. }
  11265. try
  11266. {
  11267. _sqlSugar.BeginTran();
  11268. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x=>x.Id).ToList();
  11269. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  11270. {
  11271. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11272. DeleteUserId = dto.uesrId,
  11273. IsDel = 1
  11274. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  11275. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  11276. {
  11277. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11278. DeleteUserId = dto.uesrId,
  11279. IsDel = 1
  11280. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  11281. _sqlSugar.CommitTran();
  11282. jw = JsonView(true, "删除成功");
  11283. }
  11284. catch (Exception ex)
  11285. {
  11286. jw = JsonView(false, ex.Message);
  11287. }
  11288. return Ok(jw);
  11289. }
  11290. /// <summary>
  11291. /// 报批行程保存
  11292. /// </summary>
  11293. /// <param name="dto"></param>
  11294. /// <returns></returns>
  11295. [HttpPost]
  11296. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  11297. {
  11298. var jw = JsonView(false);
  11299. var Find = dto.Arr.Find(x => x.id == 0);
  11300. if (Find != null)
  11301. {
  11302. jw.Msg = "生成的ID为0!";
  11303. return Ok(jw);
  11304. }
  11305. foreach (var item in dto.Arr)
  11306. {
  11307. foreach (var chi in item.chiList)
  11308. {
  11309. if (chi.parentId == 0)
  11310. {
  11311. chi.parentId = item.id;
  11312. }
  11313. }
  11314. }
  11315. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  11316. _sqlSugar.BeginTran();
  11317. if (chiArr.Where(x=>x.id == 0).Count() == chiArr.Count)
  11318. {
  11319. var parentIds = dto.Arr.Select(x => x.id).ToList();
  11320. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x=>new Grp_ApprovalTravelDetails
  11321. {
  11322. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  11323. DeleteUserId = dto.UserId,
  11324. IsDel = 1
  11325. }).ExecuteCommand();
  11326. }
  11327. try
  11328. {
  11329. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  11330. {
  11331. CreateTime = DateTime.Now,
  11332. CreateUserId = dto.UserId,
  11333. Details = x.details,
  11334. ParentId = x.parentId,
  11335. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11336. Remark = "",
  11337. IsDel = 0
  11338. }).ToList()).ExecuteCommand();
  11339. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  11340. {
  11341. Id = x.id,
  11342. Details = x.details,
  11343. ParentId = x.parentId,
  11344. Time = x.timeInterval.Count > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  11345. }).ToList()).UpdateColumns(x=> new Grp_ApprovalTravelDetails
  11346. {
  11347. Details = x.Details,
  11348. ParentId = x.ParentId,
  11349. Time = x.Time
  11350. }).ExecuteCommand();
  11351. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  11352. {
  11353. Id = x.id,
  11354. Date = x.date,
  11355. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  11356. {
  11357. Date = x.Date
  11358. }).ExecuteCommand();
  11359. _sqlSugar.CommitTran();
  11360. jw = JsonView(true, "保存成功!");
  11361. }
  11362. catch (Exception ex)
  11363. {
  11364. _sqlSugar.RollbackTran();
  11365. jw = JsonView(false, "保存失败!" + ex.Message);
  11366. }
  11367. return Ok(jw);
  11368. }
  11369. /// <summary>
  11370. /// 报批行程生成
  11371. /// </summary>
  11372. /// <param name="dto"></param>
  11373. /// <returns></returns>
  11374. [HttpPost]
  11375. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  11376. {
  11377. var jw = JsonView(false);
  11378. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11379. if (group == null)
  11380. {
  11381. jw.Msg = "暂无该团组!";
  11382. return Ok(jw);
  11383. }
  11384. DateTime StartDate = (group.VisitStartDate);
  11385. DateTime EndDate = (group.VisitEndDate);
  11386. TimeSpan t3 = EndDate - StartDate;
  11387. var getDay = t3.Days;
  11388. if (getDay == 0) getDay = 1;
  11389. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  11390. var resultArr = new ArrayList();
  11391. if (officialActivitiesArr.Count == 0)
  11392. {
  11393. jw.Msg = "暂无公务出访信息!";
  11394. return Ok(jw);
  11395. }
  11396. try
  11397. {
  11398. _sqlSugar.BeginTran();
  11399. DeleteApprovalJourney(new
  11400. Domain.Dtos.Groups.DeleteApprovalJourney
  11401. {
  11402. Diid = dto.Diid,
  11403. uesrId = dto.Userid
  11404. });
  11405. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  11406. for (int i = 0; i < getDay; i++)
  11407. {
  11408. DateTime NewData = StartDate.AddDays(i);
  11409. 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();
  11410. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  11411. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  11412. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ") 第" + intToString(i + 1) + "天";
  11413. appro.Diid = dto.Diid;
  11414. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  11415. appro.Id = thisId;
  11416. appro.CreateUserId = dto.Userid;
  11417. appro.CreateTime = DateTime.Now;
  11418. var chiarr = new List<Grp_ApprovalTravelDetails>();
  11419. foreach (var item in gwinfo)
  11420. {
  11421. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  11422. chi.Details = "拜访" + item.Client;
  11423. chi.ParentId = thisId;
  11424. chi.Time = item.Time;
  11425. chiarr.Add(chi);
  11426. }
  11427. if (chiarr.Count < 5)
  11428. {
  11429. for (int j = chiarr.Count; j < 5; j++)
  11430. {
  11431. chiarr.Add(new
  11432. Grp_ApprovalTravelDetails());
  11433. }
  11434. }
  11435. resultArr.Add(new
  11436. {
  11437. appro.Id,
  11438. appro.Date,
  11439. appro.Diid,
  11440. chiList = chiarr.Select(x1 => new
  11441. {
  11442. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  11443. x1.Details,
  11444. x1.ParentId,
  11445. x1.Id
  11446. })
  11447. });
  11448. }
  11449. _sqlSugar.CommitTran();
  11450. jw = JsonView(true, "生成成功!", resultArr);
  11451. }
  11452. catch (Exception ex)
  11453. {
  11454. jw.Code = 400;
  11455. jw.Msg = "生成失败!" + ex.Message;
  11456. }
  11457. return Ok(jw);
  11458. }
  11459. /// <summary>
  11460. /// 报批行程word导出
  11461. /// </summary>
  11462. /// <param name="dto"></param>
  11463. /// <returns></returns>
  11464. [HttpPost]
  11465. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  11466. {
  11467. var jw = JsonView(false);
  11468. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  11469. if (group == null)
  11470. {
  11471. jw.Msg = "暂无该团组!";
  11472. return Ok(jw);
  11473. }
  11474. //模板路径
  11475. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx");
  11476. //载入模板
  11477. Document doc = new Document(tempPath);
  11478. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11479. //获取所填表格的序数
  11480. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11481. Aspose.Words.Tables.Row titleRowClone = null;
  11482. Aspose.Words.Tables.Row CenterRowClone = null;
  11483. int index = 0;
  11484. int indexChi = 0;
  11485. int SetIndex = 0;
  11486. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  11487. //获取数据,放到datatable
  11488. foreach (var item in ApprovalTravelArr)
  11489. {
  11490. if (index > 0)
  11491. {
  11492. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  11493. tableOne.AppendChild(titleRowClone);
  11494. }
  11495. var textTime = item.Date;
  11496. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  11497. SetCells(tableOne, doc, SetIndex, 0, textTime);
  11498. SetIndex++;
  11499. if (ChiRep.Count > 0)
  11500. {
  11501. foreach (var itemChi in ChiRep)
  11502. {
  11503. var txtTime = itemChi.Time;
  11504. var txtDetail = itemChi.Details;
  11505. if (indexChi > 0)
  11506. {
  11507. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11508. tableOne.AppendChild(CenterRowClone);
  11509. }
  11510. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  11511. {
  11512. SetCells(tableOne, doc, SetIndex, 0, "");
  11513. SetCells(tableOne, doc, SetIndex, 1, "");
  11514. indexChi++;
  11515. SetIndex++;
  11516. break;
  11517. }
  11518. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  11519. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  11520. indexChi++;
  11521. SetIndex++;
  11522. }
  11523. }
  11524. else
  11525. {
  11526. if (indexChi > 0)
  11527. {
  11528. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  11529. tableOne.AppendChild(CenterRowClone);
  11530. }
  11531. SetCells(tableOne, doc, SetIndex, 0, "");
  11532. SetCells(tableOne, doc, SetIndex, 1, "");
  11533. indexChi++;
  11534. SetIndex++;
  11535. }
  11536. index++;
  11537. }
  11538. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  11539. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);
  11540. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; ;
  11541. jw.Code = 200;
  11542. jw.Msg = "";
  11543. return Ok(jw);
  11544. }
  11545. private string intToString(int numberVal)
  11546. {
  11547. string numberval = numberVal.ToString();
  11548. Dictionary<char, string> Number = new Dictionary<char, string>();
  11549. Number.Add('1', "一");
  11550. Number.Add('2', "二");
  11551. Number.Add('3', "三");
  11552. Number.Add('4', "四");
  11553. Number.Add('5', "五");
  11554. Number.Add('6', "六");
  11555. Number.Add('7', "七");
  11556. Number.Add('8', "八");
  11557. Number.Add('9', "九");
  11558. string stringNumberVal = string.Empty;
  11559. for (int i = 0; i < numberval.Length; i++)
  11560. {
  11561. if (i == 0)
  11562. {
  11563. stringNumberVal += Number[numberval[i]];
  11564. }
  11565. else if (i >= 1)
  11566. {
  11567. if (numberval[i] == '0')
  11568. {
  11569. stringNumberVal = "十";
  11570. }
  11571. else
  11572. {
  11573. stringNumberVal += "十" + Number[numberval[i]];
  11574. }
  11575. }
  11576. }
  11577. return stringNumberVal;
  11578. }
  11579. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  11580. {
  11581. //获取table中的某个单元格,从0开始
  11582. Cell lshCell = table.Rows[rows].Cells[cells];
  11583. //将单元格中的第一个段落移除
  11584. lshCell.FirstParagraph.Remove();
  11585. //新建一个段落
  11586. Paragraph p = new Paragraph(doc);
  11587. var r = new Run(doc, val);
  11588. //把设置的值赋给之前新建的段落
  11589. p.AppendChild(r);
  11590. //将此段落加到单元格内
  11591. lshCell.AppendChild(p);
  11592. }
  11593. #endregion
  11594. // /// <summary>
  11595. // ///
  11596. // /// </summary>
  11597. // /// <param name="_dto"></param>
  11598. // /// <returns></returns>
  11599. // [HttpPost]
  11600. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11601. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11602. // {
  11603. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11604. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  11605. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  11606. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11607. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  11608. // dic_psg.Add("客人", 974);
  11609. // dic_psg.Add("司机", 975);
  11610. // dic_psg.Add("导游", 976);
  11611. // dic_psg.Add("公司内部人员", 977);
  11612. // dic_psg.Add("司机/导游/公司内部人员", 978);
  11613. // foreach (var item in list_visa)
  11614. // {
  11615. // Grp_VisaInfo temp = new Grp_VisaInfo();
  11616. // temp.Id = item.Id;
  11617. // temp.DIId = item.DIId;
  11618. // temp.VisaClient = item.VisaClient;
  11619. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  11620. // temp.VisaCurrency = item.VisaCurrency;
  11621. // temp.IsThird = item.IsThird;
  11622. // if (dic_psg.ContainsKey(item.PassengerType))
  11623. // {
  11624. // temp.PassengerType = dic_psg[item.PassengerType];
  11625. // }
  11626. // else {
  11627. // temp.PassengerType = -1;
  11628. // }
  11629. // temp.VisaNumber = item.VisaNumber;
  11630. // temp.VisaFreeNumber = item.VisaFreeNumber;
  11631. // temp.CreateUserId = item.Operators;
  11632. // DateTime dt_ct;
  11633. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  11634. // if (b_ct)
  11635. // {
  11636. // temp.CreateTime = dt_ct;
  11637. // }
  11638. // else
  11639. // {
  11640. // temp.CreateTime = DateTime.Now;
  11641. // }
  11642. // temp.DeleteTime = "";
  11643. // temp.DeleteUserId = 0;
  11644. // temp.Remark = item.Remark;
  11645. // if (string.IsNullOrEmpty(temp.Remark)) {
  11646. // temp.Remark = "";
  11647. // }
  11648. // temp.IsDel = item.IsDel;
  11649. // temp.VisaDescription = item.VisaAttachment;
  11650. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  11651. //([Id]
  11652. // ,[DIId]
  11653. // ,[VisaClient]
  11654. // ,[VisaPrice]
  11655. // ,[VisaCurrency]
  11656. // ,[IsThird]
  11657. // ,[PassengerType]
  11658. // ,[VisaNumber]
  11659. // ,[VisaFreeNumber]
  11660. // ,[CreateUserId]
  11661. // ,[CreateTime]
  11662. // ,[DeleteTime]
  11663. // ,[DeleteUserId]
  11664. // ,[Remark]
  11665. // ,[IsDel]
  11666. // ,[visaDescription])
  11667. // VALUES
  11668. // ({0},{1},'{2}',{3},{4}
  11669. //,{5},{6},{7},{8},{9}
  11670. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  11671. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  11672. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  11673. //);
  11674. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  11675. // }
  11676. // return Ok(JsonView(true, "操作成功!"));
  11677. // }
  11678. /// <summary>
  11679. /// 123132123
  11680. /// </summary>
  11681. /// <param name="_dto"></param>
  11682. /// <returns></returns>
  11683. [HttpPost]
  11684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11685. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  11686. {
  11687. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  11688. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  11689. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  11690. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  11691. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  11692. dicDetail.Add(789, 1034);
  11693. dicDetail.Add(790, 1035);
  11694. dicDetail.Add(791, 1036);
  11695. dicDetail.Add(792, 1037);
  11696. dicDetail.Add(793, 1038);
  11697. dicDetail.Add(794, 1039);
  11698. dicDetail.Add(795, 1040);
  11699. dicDetail.Add(796, 1041);
  11700. dicDetail.Add(797, 1042);
  11701. dicDetail.Add(798, 1043);
  11702. dicDetail.Add(801, 1044);
  11703. dicDetail.Add(802, 1045);
  11704. dicDetail.Add(803, 1046);
  11705. Dictionary<int, int> dic = new Dictionary<int, int>();
  11706. dic.Add(806, 1027);
  11707. dic.Add(807, 1028);
  11708. dic.Add(808, 1029);
  11709. dic.Add(809, 1030);
  11710. dic.Add(810, 1031);
  11711. dic.Add(811, 1032);
  11712. dic.Add(812, 1033);
  11713. foreach (var item in list_visa)
  11714. {
  11715. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  11716. temp.Coefficient = item.coefficient;
  11717. DateTime dtCrt;
  11718. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  11719. if (b1)
  11720. {
  11721. temp.CreateTime = dtCrt;
  11722. }
  11723. else
  11724. {
  11725. temp.CreateTime = DateTime.Now;
  11726. }
  11727. temp.CreateUserId = item.Operators;
  11728. temp.DeleteTime = "";
  11729. temp.DeleteUserId = 0;
  11730. temp.DiId = int.Parse(item.DIID);
  11731. temp.FilePath = item.FilePath;
  11732. temp.IsDel = item.IsDel;
  11733. temp.Price = item.Price;
  11734. temp.PriceCount = 1;
  11735. temp.PriceCurrency = item.Currency;
  11736. int detailId = 0;
  11737. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  11738. {
  11739. detailId = dicDetail[item.PriceTypeDetail];
  11740. }
  11741. temp.PriceDetailType = detailId;
  11742. temp.PriceDt = DateTime.Now;
  11743. temp.PriceName = item.PriceName;
  11744. temp.PriceSum = item.Price;
  11745. int tid = 0;
  11746. if (dic.ContainsKey(item.PriceType))
  11747. {
  11748. tid = dic[item.PriceType];
  11749. }
  11750. temp.PriceType = tid;
  11751. temp.Remark = item.Remark;
  11752. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  11753. }
  11754. return Ok(JsonView(true, "操作成功!"));
  11755. }
  11756. }
  11757. }