GroupsController.cs 1005 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using EyeSoft.Collections.Generic;
  7. using Microsoft.AspNetCore.SignalR;
  8. using Microsoft.EntityFrameworkCore.Query.Internal;
  9. using NPOI.HSSF.UserModel;
  10. using NPOI.SS.Formula.Functions;
  11. using NPOI.SS.UserModel;
  12. using NPOI.SS.Util;
  13. using NPOI.XSSF.UserModel;
  14. using OASystem.API.Middlewares;
  15. using OASystem.API.OAMethodLib;
  16. using OASystem.API.OAMethodLib.APNs;
  17. using OASystem.API.OAMethodLib.File;
  18. using OASystem.API.OAMethodLib.Hub.HubClients;
  19. using OASystem.API.OAMethodLib.Hub.Hubs;
  20. using OASystem.API.OAMethodLib.JuHeAPI;
  21. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  22. using OASystem.Domain.AesEncryption;
  23. using OASystem.Domain.Dtos.CRM;
  24. using OASystem.Domain.Dtos.FileDto;
  25. using OASystem.Domain.Dtos.Financial;
  26. using OASystem.Domain.Dtos.Groups;
  27. using OASystem.Domain.Entities.Customer;
  28. using OASystem.Domain.Entities.Financial;
  29. using OASystem.Domain.Entities.Groups;
  30. using OASystem.Domain.ViewModels.Financial;
  31. using OASystem.Domain.ViewModels.Groups;
  32. using OASystem.Infrastructure.Repositories.CRM;
  33. using OASystem.Infrastructure.Repositories.Financial;
  34. using OASystem.Infrastructure.Repositories.Groups;
  35. using OfficeOpenXml;
  36. using Org.BouncyCastle.Asn1.Ocsp;
  37. using Org.BouncyCastle.Utilities.Encoders;
  38. using Quartz.Util;
  39. using SqlSugar.Extensions;
  40. using System.Collections;
  41. using System.Data;
  42. using System.Diagnostics;
  43. using System.Globalization;
  44. using System.IO.Compression;
  45. using static OASystem.API.OAMethodLib.JWTHelper;
  46. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  47. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  48. using Bookmark = Aspose.Words.Bookmark;
  49. using Cell = Aspose.Words.Tables.Cell;
  50. using Table = Aspose.Words.Tables.Table;
  51. namespace OASystem.API.Controllers
  52. {
  53. /// <summary>
  54. /// 团组相关
  55. /// </summary>
  56. //[Authorize]
  57. [Route("api/[controller]/[action]")]
  58. public class GroupsController : ControllerBase
  59. {
  60. private readonly ILogger<GroupsController> _logger;
  61. private readonly GrpScheduleRepository _grpScheduleRep;
  62. private readonly IMapper _mapper;
  63. private readonly DelegationInfoRepository _groupRepository;
  64. private readonly TaskAssignmentRepository _taskAssignmentRep;
  65. private readonly AirTicketResRepository _airTicketResRep;
  66. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  67. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  68. private readonly DelegationEnDataRepository _delegationEnDataRep;
  69. private readonly DelegationVisaRepository _delegationVisaRep;
  70. private readonly VisaPriceRepository _visaPriceRep;
  71. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  72. private readonly HotelPriceRepository _hotelPriceRep;
  73. private readonly CustomersRepository _customersRep;
  74. private readonly MessageRepository _message;
  75. private readonly SqlSugarClient _sqlSugar;
  76. private readonly TourClientListRepository _tourClientListRep;
  77. private readonly TeamRateRepository _teamRateRep;
  78. #region 成本相关
  79. private readonly CheckBoxsRepository _checkBoxs;
  80. private readonly GroupCostRepository _GroupCostRepository;
  81. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  82. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  83. #endregion
  84. private readonly SetDataRepository _setDataRep;
  85. private string url;
  86. private string path;
  87. private readonly EnterExitCostRepository _enterExitCostRep;
  88. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  89. private readonly UsersRepository _usersRep;
  90. private readonly IJuHeApiService _juHeApi;
  91. private readonly InvertedListRepository _invertedListRep;
  92. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  93. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  94. private readonly ThreeCodeRepository _threeCodeRepository;
  95. private readonly HotelInquiryRepository _hotelInquiryRep;
  96. private readonly FeeAuditRepository _feeAuditRep;
  97. private readonly VisaCommissionRepository _visaCommissionRep;
  98. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  99. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  100. private readonly List<CurrencyInfo> _currencyInit;
  101. private readonly List<int> _portTypeData;
  102. private readonly TableOperationRecordRepository _tableorRep;
  103. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  104. private readonly RestaurantRepository _restaurantRep;
  105. /// <summary>
  106. /// 构造函数
  107. /// </summary>
  108. /// <param name="logger"></param>
  109. /// <param name="mapper"></param>
  110. /// <param name="hubContext"></param>
  111. /// <param name="sqlSugar"></param>
  112. /// <param name="grpScheduleRep"></param>
  113. /// <param name="groupRepository"></param>
  114. /// <param name="taskAssignmentRep"></param>
  115. /// <param name="airTicketResRep"></param>
  116. /// <param name="decreasePaymentsRep"></param>
  117. /// <param name="InvitationOfficialActivitiesRep"></param>
  118. /// <param name="delegationEnDataRep"></param>
  119. /// <param name="enterExitCostRep"></param>
  120. /// <param name="delegationVisaRep"></param>
  121. /// <param name="message"></param>
  122. /// <param name="visaPriceRep"></param>
  123. /// <param name="carTouristGuideGroundRep"></param>
  124. /// <param name="checkBoxs"></param>
  125. /// <param name="GroupCostRepository"></param>
  126. /// <param name="CostTypeHotelNumberRepository"></param>
  127. /// <param name="GroupCostParameterRepository"></param>
  128. /// <param name="hotelPriceRep"></param>
  129. /// <param name="customersRep"></param>
  130. /// <param name="setDataRep"></param>
  131. /// <param name="tourClientListRep"></param>
  132. /// <param name="teamRateRep"></param>
  133. /// <param name="usersRep"></param>
  134. /// <param name="juHeApi"></param>
  135. /// <param name="invertedListRep"></param>
  136. /// <param name="visaFeeInfoRep"></param>
  137. /// <param name="ticketBlackCodeRep"></param>
  138. /// <param name="hotelInquiryRep"></param>
  139. /// <param name="threeCodeRepository"></param>
  140. /// <param name="feeAuditRep"></param>
  141. /// <param name="visaCommissionRep"></param>
  142. /// <param name="ffrRep"></param>
  143. /// <param name="opinionaireRep"></param>
  144. /// <param name="tableorRep"></param>
  145. /// <param name="enterExitCostDraftRep"></param>
  146. /// <param name="restaurantRep"></param>
  147. public GroupsController(
  148. ILogger<GroupsController> logger,
  149. IMapper mapper,
  150. IHubContext<ChatHub, IChatClient> hubContext,
  151. SqlSugarClient sqlSugar,
  152. GrpScheduleRepository grpScheduleRep,
  153. DelegationInfoRepository groupRepository,
  154. TaskAssignmentRepository taskAssignmentRep,
  155. AirTicketResRepository airTicketResRep,
  156. DecreasePaymentsRepository decreasePaymentsRep,
  157. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  158. DelegationEnDataRepository delegationEnDataRep,
  159. EnterExitCostRepository enterExitCostRep,
  160. DelegationVisaRepository delegationVisaRep,
  161. MessageRepository message,
  162. VisaPriceRepository visaPriceRep,
  163. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  164. CheckBoxsRepository checkBoxs,
  165. GroupCostRepository GroupCostRepository,
  166. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  167. GroupCostParameterRepository GroupCostParameterRepository,
  168. HotelPriceRepository hotelPriceRep,
  169. CustomersRepository customersRep,
  170. SetDataRepository setDataRep,
  171. TourClientListRepository tourClientListRep,
  172. TeamRateRepository teamRateRep,
  173. UsersRepository usersRep, IJuHeApiService juHeApi,
  174. InvertedListRepository invertedListRep,
  175. VisaFeeInfoRepository visaFeeInfoRep,
  176. TicketBlackCodeRepository ticketBlackCodeRep,
  177. HotelInquiryRepository hotelInquiryRep,
  178. ThreeCodeRepository threeCodeRepository,
  179. FeeAuditRepository feeAuditRep,
  180. VisaCommissionRepository visaCommissionRep,
  181. ForeignReceivablesRepository ffrRep,
  182. OpinionaireRepository opinionaireRep,
  183. TableOperationRecordRepository tableorRep,
  184. EnterExitCostDraftRepository enterExitCostDraftRep,
  185. RestaurantRepository restaurantRep
  186. )
  187. {
  188. _logger = logger;
  189. _mapper = mapper;
  190. _grpScheduleRep = grpScheduleRep;
  191. _groupRepository = groupRepository;
  192. _taskAssignmentRep = taskAssignmentRep;
  193. _airTicketResRep = airTicketResRep;
  194. _sqlSugar = sqlSugar;
  195. url = AppSettingsHelper.Get("ExcelBaseUrl");
  196. path = AppSettingsHelper.Get("ExcelBasePath");
  197. if (!System.IO.Directory.Exists(path))
  198. {
  199. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  200. }
  201. _decreasePaymentsRep = decreasePaymentsRep;
  202. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  203. _delegationEnDataRep = delegationEnDataRep;
  204. _enterExitCostRep = enterExitCostRep;
  205. _delegationVisaRep = delegationVisaRep;
  206. _message = message;
  207. _visaPriceRep = visaPriceRep;
  208. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  209. _checkBoxs = checkBoxs;
  210. _GroupCostRepository = GroupCostRepository;
  211. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  212. _GroupCostParameterRepository = GroupCostParameterRepository;
  213. _hotelPriceRep = hotelPriceRep;
  214. _customersRep = customersRep;
  215. _setDataRep = setDataRep;
  216. _tourClientListRep = tourClientListRep;
  217. _teamRateRep = teamRateRep;
  218. _hubContext = hubContext;
  219. _usersRep = usersRep;
  220. _juHeApi = juHeApi;
  221. _invertedListRep = invertedListRep;
  222. _visaFeeInfoRep = visaFeeInfoRep;
  223. _ticketBlackCodeRep = ticketBlackCodeRep;
  224. _hotelInquiryRep = hotelInquiryRep;
  225. _threeCodeRepository = threeCodeRepository;
  226. _feeAuditRep = feeAuditRep;
  227. _visaCommissionRep = visaCommissionRep;
  228. _ffrRep = ffrRep;
  229. _opinionaireRep = opinionaireRep;
  230. _currencyInit = new List<CurrencyInfo>()
  231. {
  232. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  233. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  234. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  235. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  236. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  237. };
  238. _portTypeData = new List<int>() { 2, 3 };
  239. _tableorRep = tableorRep;
  240. _enterExitCostDraftRep = enterExitCostDraftRep;
  241. _restaurantRep = restaurantRep;
  242. }
  243. #region 流程管控
  244. /// <summary>
  245. /// 获取团组流程管控信息
  246. /// </summary>
  247. /// <param name="paras">参数Json字符串</param>
  248. /// <returns></returns>
  249. [HttpPost]
  250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  251. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  252. {
  253. if (string.IsNullOrEmpty(_jsonDto.Paras))
  254. {
  255. return Ok(JsonView(false, "参数为空"));
  256. }
  257. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  258. if (_ScheduleDto != null)
  259. {
  260. if (_ScheduleDto.SearchType == 2)//获取列表
  261. {
  262. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  263. return Ok(JsonView(_grpScheduleViewList));
  264. }
  265. else//获取对象
  266. {
  267. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  268. if (_grpScheduleView != null)
  269. {
  270. return Ok(JsonView(_grpScheduleView));
  271. }
  272. }
  273. }
  274. else
  275. {
  276. return Ok(JsonView(false, "参数反序列化失败"));
  277. }
  278. return Ok(JsonView(false, "暂无数据!"));
  279. }
  280. /// <summary>
  281. /// 修改团组流程管控详细表数据
  282. /// </summary>
  283. /// <param name="paras"></param>
  284. /// <returns></returns>
  285. [HttpPost]
  286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  287. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  288. {
  289. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  290. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  291. .SetColumns(it => it.Duty == _detail.Duty)
  292. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  293. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  294. .SetColumns(it => it.JobContent == _detail.JobContent)
  295. .SetColumns(it => it.Remark == _detail.Remark)
  296. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  297. .Where(s => s.Id == dto.Id)
  298. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  299. .ExecuteCommandAsync();
  300. if (result > 0)
  301. {
  302. return Ok(JsonView(true, "保存成功!"));
  303. }
  304. return Ok(JsonView(false, "保存失败!"));
  305. }
  306. /// <summary>
  307. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  308. /// </summary>
  309. /// <param name="dto"></param>
  310. /// <returns></returns>
  311. [HttpPost]
  312. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  313. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  314. {
  315. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  316. _detail.IsDel = 1;
  317. _detail.DeleteUserId = dto.Duty;
  318. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  319. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  320. .SetColumns(it => it.IsDel == _detail.IsDel)
  321. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  322. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  323. .Where(it => it.Id == dto.Id)
  324. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  325. //.WhereColumns(s => s.Id == dto.Id)
  326. .ExecuteCommandAsync();
  327. if (result > 0)
  328. {
  329. return Ok(JsonView(true, "删除成功!"));
  330. }
  331. return Ok(JsonView(false, "删除失败!"));
  332. }
  333. /// <summary>
  334. /// 增加团组流程管控详细表数据
  335. /// </summary>
  336. /// <param name="dto"></param>
  337. /// <returns></returns>
  338. [HttpPost]
  339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  340. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  341. {
  342. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  343. if (DateTime.Now < _detail.ExpectBeginDt)
  344. {
  345. _detail.StepStatus = 0;
  346. }
  347. else
  348. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  349. _detail.StepStatus = 1;
  350. }
  351. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  352. if (result > 0)
  353. {
  354. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  355. return Ok(JsonView(true, "添加成功!", _result));
  356. }
  357. return Ok(JsonView(false, "添加失败!"));
  358. }
  359. #endregion
  360. #region 团组基本信息
  361. /// <summary>
  362. /// 接团信息列表
  363. /// </summary>
  364. /// <param name="dto">团组列表请求dto</param>
  365. /// <returns></returns>
  366. [HttpPost]
  367. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  368. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  369. {
  370. var groupData = await _groupRepository.GetGroupList(dto);
  371. if (groupData.Code != 0)
  372. {
  373. return Ok(JsonView(false, groupData.Msg));
  374. }
  375. return Ok(JsonView(groupData.Data));
  376. }
  377. /// <summary>
  378. /// 分页查询团组列表
  379. /// </summary>
  380. /// <param name="dto"></param>
  381. /// <returns></returns>
  382. [HttpPost]
  383. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  384. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  385. {
  386. var watch = new Stopwatch();
  387. watch.Start();
  388. RefAsync<int> total = 0;
  389. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  390. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  391. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  392. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  393. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  394. .Distinct()
  395. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  396. watch.Stop();
  397. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  398. }
  399. /// <summary>
  400. /// 接团信息列表 Page Init
  401. /// </summary>
  402. /// <returns></returns>
  403. [HttpPost]
  404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  405. public async Task<IActionResult> PostGroupPageListInit()
  406. {
  407. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  408. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  409. rankDatas.Insert(0, new { Id=0, Name ="全部" });
  410. var _view = new
  411. {
  412. depData = depDatas,
  413. rankData = rankDatas
  414. };
  415. return Ok(JsonView(true, "查询成功!", _view));
  416. }
  417. /// <summary>
  418. /// 接团信息列表 Page
  419. /// </summary>
  420. /// <param name="dto">团组列表请求dto</param>
  421. /// <returns></returns>
  422. [HttpPost]
  423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  424. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  425. {
  426. #region 参数验证
  427. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  428. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  429. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  430. #region 页面操作权限验证
  431. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  432. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  433. #endregion
  434. #endregion
  435. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  436. {
  437. string sqlWhere = string.Empty;
  438. if (dto.IsSure == 0) //未完成
  439. {
  440. sqlWhere += string.Format(@" And IsSure = 0");
  441. }
  442. else if (dto.IsSure == 1) //已完成
  443. {
  444. sqlWhere += string.Format(@" And IsSure = 1");
  445. }
  446. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  447. {
  448. string tj = dto.SearchCriteria;
  449. 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}%')",
  450. tj, tj, tj, tj, tj);
  451. }
  452. if (int.TryParse(dto.Rank,out int rankId))
  453. {
  454. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  455. }
  456. string sqlWhere1 = string.Empty;
  457. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  458. {
  459. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  460. }
  461. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  462. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  463. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  464. JietuanOperator,IsSure,CreateTime,IsBid
  465. From (
  466. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  467. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  468. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  469. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  470. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  471. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  472. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  473. From Grp_DelegationInfo gdi
  474. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  475. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  476. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  477. Where gdi.IsDel = 0 {0}
  478. ) temp {1}", sqlWhere, sqlWhere1);
  479. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  480. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  481. var _view = new
  482. {
  483. PageFuncAuth = pageFunAuthView,
  484. Data = _DelegationList
  485. };
  486. return Ok(JsonView(true, "查询成功!", _view, total));
  487. }
  488. else
  489. {
  490. return Ok(JsonView(false, "查询失败"));
  491. }
  492. }
  493. /// <summary>
  494. /// 团组列表
  495. /// </summary>
  496. /// <returns></returns>
  497. [HttpPost]
  498. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  499. {
  500. #region 参数验证
  501. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  502. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  503. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  504. #region 页面操作权限验证
  505. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  506. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  507. #endregion
  508. #endregion
  509. if (dto.PortType != 1 && dto.PortType != 2)
  510. {
  511. return Ok(JsonView(false, "查询失败!"));
  512. }
  513. string orderbyStr = "order by gdi.CreateTime Desc";
  514. string sqlWhere = string.Empty;
  515. if (dto.IsSure == 0) //未完成
  516. {
  517. sqlWhere += string.Format(@" And IsSure = 0");
  518. }
  519. else if (dto.IsSure == 1) //已完成
  520. {
  521. sqlWhere += string.Format(@" And IsSure = 1");
  522. }
  523. //团组类型
  524. if (dto.TeamDid > 0)
  525. {
  526. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  527. }
  528. //团组名称
  529. if (!string.IsNullOrEmpty(dto.TeamName))
  530. {
  531. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  532. }
  533. //客户名称
  534. if (!string.IsNullOrEmpty(dto.ClientName))
  535. {
  536. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  537. }
  538. //客户单位
  539. if (!string.IsNullOrEmpty(dto.ClientUnit))
  540. {
  541. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  542. }
  543. //出访时间
  544. if (!string.IsNullOrEmpty(dto.visitDataTime))
  545. {
  546. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  547. orderbyStr = "order by gdi.VisitDate";
  548. }
  549. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  550. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  551. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  552. JietuanOperator,IsSure,CreateTime
  553. From (
  554. Select row_number() over({0}) as Row_Number,
  555. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  556. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  557. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  558. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  559. From Grp_DelegationInfo gdi
  560. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  561. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  562. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  563. Where gdi.IsDel = 0 {1}
  564. ) temp ", orderbyStr, sqlWhere);
  565. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  566. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  567. #region 处理所属部门
  568. /*
  569. * 1.sq 和 gyy 等显示 市场部
  570. * 2.王鸽和主管及张总还有管理员号统一国交部
  571. * 2-1. 4 管理员 ,21 张海麟
  572. */
  573. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  574. List<int> userIds1 = new List<int>() { 4, 21 };
  575. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  576. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  577. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  578. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  579. .ToList();
  580. foreach (var item in _DelegationList)
  581. {
  582. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  583. }
  584. #endregion
  585. var _view = new
  586. {
  587. PageFuncAuth = pageFunAuthView,
  588. Data = _DelegationList
  589. };
  590. return Ok(JsonView(true, "查询成功!", _view, total));
  591. }
  592. /// <summary>
  593. /// 接团信息详情
  594. /// </summary>
  595. /// <param name="dto">团组info请求dto</param>
  596. /// <returns></returns>
  597. [HttpPost]
  598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  599. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  600. {
  601. var groupData = await _groupRepository.GetGroupInfo(dto);
  602. if (groupData.Code != 0)
  603. {
  604. return Ok(JsonView(false, groupData.Msg));
  605. }
  606. return Ok(JsonView(groupData.Data));
  607. }
  608. /// <summary>
  609. /// 接团信息 编辑添加
  610. /// 基础信息数据源
  611. /// </summary>
  612. /// <param name="dto"></param>
  613. /// <returns></returns>
  614. [HttpPost]
  615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  616. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  617. {
  618. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  619. if (groupData.Code != 0)
  620. {
  621. return Ok(JsonView(false, groupData.Msg));
  622. }
  623. return Ok(JsonView(groupData.Data));
  624. }
  625. /// <summary>
  626. /// 接团信息 操作(增改)
  627. /// </summary>
  628. /// <param name="dto"></param>
  629. /// <returns></returns>
  630. [HttpPost]
  631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  632. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  633. {
  634. // 创建 Stopwatch 实例
  635. Stopwatch stopwatch = Stopwatch.StartNew();
  636. decimal ffrPrice = 0.00M;
  637. DateTime? visitDt = null;
  638. if (dto.Status == 2)
  639. {
  640. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  641. if (groupInfo != null)
  642. {
  643. ffrPrice = groupInfo.PaymentMoney;
  644. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  645. }
  646. }
  647. var groupData = await _groupRepository.GroupOperation(dto);
  648. if (groupData.Code != 0)
  649. {
  650. return Ok(JsonView(false, groupData.Msg));
  651. }
  652. int diId = 0;
  653. try
  654. {
  655. //添加时 默认加入团组汇率
  656. if (dto.Status == 1) //添加
  657. {
  658. diId = groupData.Data;
  659. //添加默认币种
  660. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  661. //默认分配权限
  662. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  663. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  664. var _managerIds = new List<int>() { 22, 32, 21 };
  665. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  666. if (userIds.Count > 0)
  667. {
  668. userIds.Add(208);
  669. //创建团组管控
  670. GroupStepForDelegation.CreateWorkStep(diId);
  671. //发送消息
  672. string groupName = dto.TeamName;
  673. string createGroupUser = string.Empty;
  674. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  675. if (userInfo != null) createGroupUser = userInfo.CnName;
  676. string title = $"系统通知";
  677. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  678. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  679. }
  680. //默认创建倒推表
  681. await _invertedListRep._Create(dto.UserId, diId);
  682. }
  683. else if (dto.Status == 2)
  684. {
  685. diId = dto.Id;
  686. }
  687. #region 签证人员团组时间通知
  688. #region 计算出访起止时间
  689. var startTime = new DateTime();
  690. var endTime = new DateTime();
  691. if (DateTime.TryParse(dto.VisitDate, out startTime))
  692. {
  693. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  694. }
  695. #endregion
  696. #endregion
  697. #region 团组操作默认添加/修改收款账单
  698. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  699. {
  700. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  701. .Where(x => x.IsDel == 0 &&
  702. x.Diid == diId &&
  703. x.Remark.Equals("预付款")
  704. )
  705. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  706. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  707. .FirstAsync();
  708. ffrInfo = new Fin_ForeignReceivables()
  709. {
  710. Diid = diId,
  711. PriceName = dto.ClientUnit,
  712. Price = dto.PaymentMoney,
  713. Count = 1,
  714. Unit = $"元",
  715. ItemSumPrice = dto.PaymentMoney,
  716. Rate = 1.0000M,
  717. Currency = 836,
  718. AddingWay = 0,
  719. CreateUserId = dto.UserId,
  720. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  721. Remark = $"预付款"
  722. };
  723. if (ffrInfo == null) //Add
  724. {
  725. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  726. }
  727. else //修改
  728. {
  729. await _sqlSugar.Updateable(ffrInfo)
  730. .UpdateColumns(x => new
  731. {
  732. x.PriceName,
  733. x.Price,
  734. x.ItemSumPrice,
  735. x.CreateTime,
  736. x.CreateUserId
  737. })
  738. .WhereColumns(x => x.Id)
  739. .ExecuteCommandAsync();
  740. }
  741. }
  742. #endregion
  743. if (diId > 0)
  744. {
  745. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  746. }
  747. // 停止计时
  748. stopwatch.Stop();
  749. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  750. }
  751. catch (Exception ex)
  752. {
  753. // 停止计时
  754. stopwatch.Stop();
  755. Logs("[response]" + JsonConvert.SerializeObject(dto));
  756. Logs(ex.Message);
  757. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  758. }
  759. // 停止计时
  760. stopwatch.Stop();
  761. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  762. }
  763. /// <summary>
  764. /// 接团流程操作(增改)
  765. /// 安卓端使用 建团时添加客户名单
  766. /// </summary>
  767. /// <param name="dto"></param>
  768. /// <returns></returns>
  769. [HttpPost]
  770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  771. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  772. {
  773. #region 参数验证
  774. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  775. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  776. #region 页面操作权限验证
  777. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  778. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  779. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  780. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  781. #endregion
  782. #endregion
  783. try
  784. {
  785. //_sqlSugar.BeginTran();
  786. decimal ffrPrice = 0.00M;
  787. DateTime? visitDt = null;
  788. if (dto.Status == 2)
  789. {
  790. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  791. if (groupInfo != null)
  792. {
  793. ffrPrice = groupInfo.PaymentMoney;
  794. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  795. }
  796. }
  797. var _dto = new GroupOperationDto();
  798. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  799. var groupData = await _groupRepository.GroupOperation(_dto);
  800. if (groupData.Code != 0)
  801. {
  802. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  803. }
  804. int diId = 0;
  805. //添加时 默认加入团组汇率
  806. if (dto.Status == 1) //添加
  807. {
  808. diId = groupData.Data;
  809. //添加默认币种
  810. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  811. //默认分配权限
  812. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  813. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  814. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  815. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  816. if (userIds.Count > 0)
  817. {
  818. userIds.Add(208);
  819. //创建团组管控
  820. GroupStepForDelegation.CreateWorkStep(diId);
  821. //发送消息
  822. string groupName = dto.TeamName;
  823. string createGroupUser = string.Empty;
  824. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  825. if (userInfo != null) createGroupUser = userInfo.CnName;
  826. string title = $"系统通知";
  827. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  828. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  829. }
  830. #region 应用推送
  831. try
  832. {
  833. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  834. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  835. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  836. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  837. {
  838. List<string> userList = new List<string>() { users.QiyeChatUserId };
  839. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  840. }
  841. }
  842. catch (Exception ex)
  843. {
  844. }
  845. #endregion
  846. //默认创建倒推表
  847. await _invertedListRep._Create(dto.UserId, diId);
  848. }
  849. if (dto.Status == 2)
  850. {
  851. diId = dto.Id;
  852. if (diId == 0)
  853. {
  854. //_sqlSugar.RollbackTran();
  855. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  856. }
  857. }
  858. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  859. if (viewData.Code != 0)
  860. {
  861. //_sqlSugar.RollbackTran();
  862. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  863. }
  864. #region 团组操作默认添加/修改收款账单
  865. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  866. {
  867. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  868. .Where(x => x.IsDel == 0 &&
  869. x.Diid == diId &&
  870. x.Remark.Equals("预付款")
  871. )
  872. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  873. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  874. .FirstAsync();
  875. ffrInfo = new Fin_ForeignReceivables()
  876. {
  877. Diid = diId,
  878. PriceName = dto.ClientUnit,
  879. Price = dto.PaymentMoney,
  880. Count = 1,
  881. Unit = $"元",
  882. ItemSumPrice = dto.PaymentMoney,
  883. Rate = 1.0000M,
  884. Currency = 836,
  885. AddingWay = 0,
  886. CreateUserId = dto.UserId,
  887. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  888. Remark = $"预付款"
  889. };
  890. if (ffrInfo == null) //Add
  891. {
  892. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  893. }
  894. else //修改
  895. {
  896. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  897. .UpdateColumns(x => new
  898. {
  899. x.PriceName,
  900. x.Price,
  901. x.ItemSumPrice,
  902. x.CreateTime,
  903. x.CreateUserId
  904. })
  905. .WhereColumns(x => x.Id)
  906. .ExecuteCommandAsync();
  907. }
  908. }
  909. #endregion
  910. #region 签证人员团组时间通知
  911. #region 计算出访起止时间
  912. var startTime = new DateTime();
  913. var endTime = new DateTime();
  914. if (DateTime.TryParse(dto.VisitDate, out startTime))
  915. {
  916. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  917. }
  918. #endregion
  919. if (diId > 0)
  920. {
  921. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  922. }
  923. #endregion
  924. //_sqlSugar.CommitTran();
  925. return Ok(JsonView(true, "添加成功"));
  926. }
  927. catch (Exception ex)
  928. {
  929. _sqlSugar.RollbackTran();
  930. return Ok(JsonView(false, ex.Message));
  931. }
  932. }
  933. /// <summary>
  934. /// 接团流程操作(增改)
  935. /// 安卓端使用 建团时添加客户名单
  936. /// </summary>
  937. /// <param name="dto"></param>
  938. /// <returns></returns>
  939. [HttpPost]
  940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  941. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  942. {
  943. #region 参数验证
  944. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  945. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  946. #region 页面操作权限验证
  947. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  948. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  949. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  950. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  951. #endregion
  952. #endregion
  953. _sqlSugar.BeginTran();
  954. decimal ffrPrice = 0.00M;
  955. DateTime? visitDt = null;
  956. if (dto.Status == 2)
  957. {
  958. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  959. if (groupInfo != null)
  960. {
  961. ffrPrice = groupInfo.PaymentMoney;
  962. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  963. }
  964. }
  965. var _dto = new GroupOperationDto();
  966. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  967. var groupData = await _groupRepository.GroupOperation(_dto);
  968. if (groupData.Code != 0)
  969. {
  970. _sqlSugar.RollbackTran();
  971. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  972. }
  973. try
  974. {
  975. int diId = 0;
  976. //添加时 默认加入团组汇率
  977. if (dto.Status == 1) //添加
  978. {
  979. diId = groupData.Data;
  980. //添加默认币种
  981. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  982. //默认分配权限
  983. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  984. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  985. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  986. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  987. if (userIds.Count > 0)
  988. {
  989. userIds.Add(208);
  990. //创建团组管控
  991. GroupStepForDelegation.CreateWorkStep(diId);
  992. //发送消息
  993. string groupName = dto.TeamName;
  994. string createGroupUser = string.Empty;
  995. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  996. if (userInfo != null) createGroupUser = userInfo.CnName;
  997. string title = $"系统通知";
  998. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  999. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1000. }
  1001. #region 应用推送
  1002. try
  1003. {
  1004. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1005. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1006. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1007. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1008. {
  1009. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1010. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1011. }
  1012. }
  1013. catch (Exception ex)
  1014. {
  1015. _sqlSugar.CommitTran();
  1016. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1017. }
  1018. #endregion
  1019. //默认创建倒推表
  1020. await _invertedListRep._Create(dto.UserId, diId);
  1021. }
  1022. else if (dto.Status == 2)
  1023. {
  1024. diId = dto.Id;
  1025. if (diId == 0)
  1026. {
  1027. _sqlSugar.RollbackTran();
  1028. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1029. }
  1030. }
  1031. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1032. if (viewData.Code != 0)
  1033. {
  1034. _sqlSugar.RollbackTran();
  1035. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1036. }
  1037. #region 团组操作默认添加/修改收款账单
  1038. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1039. {
  1040. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1041. .Where(x => x.IsDel == 0 &&
  1042. x.Diid == diId &&
  1043. x.Remark.Equals("预付款")
  1044. )
  1045. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1046. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1047. .FirstAsync();
  1048. ffrInfo = new Fin_ForeignReceivables()
  1049. {
  1050. Diid = diId,
  1051. PriceName = dto.ClientUnit,
  1052. Price = dto.PaymentMoney,
  1053. Count = 1,
  1054. Unit = $"元",
  1055. ItemSumPrice = dto.PaymentMoney,
  1056. Rate = 1.0000M,
  1057. Currency = 836,
  1058. AddingWay = 0,
  1059. CreateUserId = dto.UserId,
  1060. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1061. Remark = $"预付款"
  1062. };
  1063. if (ffrInfo == null) //Add
  1064. {
  1065. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1066. }
  1067. else //修改
  1068. {
  1069. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1070. .UpdateColumns(x => new
  1071. {
  1072. x.PriceName,
  1073. x.Price,
  1074. x.ItemSumPrice,
  1075. x.CreateTime,
  1076. x.CreateUserId
  1077. })
  1078. .WhereColumns(x => x.Id)
  1079. .ExecuteCommandAsync();
  1080. }
  1081. }
  1082. #endregion
  1083. #region 签证人员团组时间通知
  1084. #region 计算出访起止时间
  1085. var startTime = new DateTime();
  1086. var endTime = new DateTime();
  1087. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1088. {
  1089. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1090. }
  1091. #endregion
  1092. if (diId > 0)
  1093. {
  1094. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1095. }
  1096. #endregion
  1097. _sqlSugar.CommitTran();
  1098. return Ok(JsonView(true));
  1099. }
  1100. catch (Exception ex)
  1101. {
  1102. _sqlSugar.RollbackTran();
  1103. return Ok(JsonView(false, ex.Message));
  1104. }
  1105. }
  1106. /// <summary>
  1107. /// 接团信息 操作(删除)
  1108. /// </summary>
  1109. /// <param name="dto"></param>
  1110. /// <returns></returns>
  1111. [HttpPost]
  1112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1113. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1114. {
  1115. var diId = dto.Id;
  1116. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1117. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1118. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1119. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1120. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1121. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1122. #endregion
  1123. var groupData = await _groupRepository.GroupDel(dto);
  1124. if (groupData.Code != 0)
  1125. {
  1126. return Ok(JsonView(false, groupData.Msg));
  1127. }
  1128. return Ok(JsonView(true));
  1129. }
  1130. /// <summary>
  1131. /// 获取团组销售报价号
  1132. /// 团组添加时 使用
  1133. /// </summary>
  1134. /// <returns></returns>
  1135. [HttpPost]
  1136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1137. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1138. {
  1139. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1140. if (groupData.Code != 0)
  1141. {
  1142. return Ok(JsonView(false, groupData.Msg));
  1143. }
  1144. object salesQuoteNo = new
  1145. {
  1146. SalesQuoteNo = groupData.Data
  1147. };
  1148. return Ok(JsonView(salesQuoteNo));
  1149. }
  1150. /// <summary>
  1151. /// 设置确认出团
  1152. /// </summary>
  1153. /// <param name="dto"></param>
  1154. /// <returns></returns>
  1155. [HttpPost]
  1156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1157. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1158. {
  1159. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1160. if (groupData.Code != 0)
  1161. {
  1162. return Ok(JsonView(false, groupData.Msg));
  1163. }
  1164. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1165. #region OA消息推送
  1166. try
  1167. {
  1168. string groupName = groupInfo.TeamName;
  1169. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1170. string title = $"系统通知";
  1171. string content = $"团组[{groupName}]已确认出团!";
  1172. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1173. }
  1174. catch (Exception ex)
  1175. {
  1176. }
  1177. #endregion
  1178. #region 应用推送
  1179. try
  1180. {
  1181. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1182. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1183. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1184. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1185. {
  1186. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1187. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1188. }
  1189. }
  1190. catch (Exception ex)
  1191. {
  1192. }
  1193. #endregion
  1194. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1195. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1196. }
  1197. /// <summary>
  1198. /// 获取团组名称data And 签证国别Data
  1199. /// </summary>
  1200. /// <param name="dto"></param>
  1201. /// <returns></returns>
  1202. [HttpPost]
  1203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1204. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1205. {
  1206. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1207. if (groupData.Code != 0)
  1208. {
  1209. return Ok(JsonView(false, groupData.Msg));
  1210. }
  1211. return Ok(JsonView(groupData.Data));
  1212. }
  1213. /// <summary>
  1214. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1215. /// </summary>
  1216. /// <returns></returns>
  1217. [HttpPost]
  1218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1219. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1220. {
  1221. try
  1222. {
  1223. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1224. if (groupData.Code != 0)
  1225. {
  1226. return Ok(JsonView(false, groupData.Msg));
  1227. }
  1228. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1229. }
  1230. catch (Exception ex)
  1231. {
  1232. return Ok(JsonView(false, "程序错误!"));
  1233. throw;
  1234. }
  1235. }
  1236. /// <summary>
  1237. /// 团组清单 Excel
  1238. /// </summary>
  1239. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1240. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1241. /// <returns></returns>
  1242. [HttpGet]
  1243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1244. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1245. {
  1246. DateTime _beginDt, _endDt;
  1247. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1248. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1249. if (!beginBool && !endBool)
  1250. {
  1251. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1252. }
  1253. string sql = string.Format(@"
  1254. SELECT
  1255. ROW_NUMBER,
  1256. Id,
  1257. SalesQuoteNo,
  1258. TourCode,
  1259. TeamTypeId,
  1260. TeamType,
  1261. TeamLevId,
  1262. TeamLev,
  1263. TeamName,
  1264. ClientName,
  1265. ClientUnit,
  1266. VisitDate,
  1267. VisitDays,
  1268. VisitPNumber,
  1269. JietuanOperatorId,
  1270. JietuanOperator,
  1271. IsSure,
  1272. CreateUserName,
  1273. IsBid
  1274. FROM
  1275. (
  1276. SELECT
  1277. ROW_NUMBER() OVER(
  1278. ORDER BY
  1279. gdi.CreateTime Desc
  1280. ) AS ROW_NUMBER,
  1281. gdi.Id,
  1282. SalesQuoteNo,
  1283. TourCode,
  1284. ssd.Id TeamTypeId,
  1285. ssd.Name TeamType,
  1286. ssd1.Id TeamLevId,
  1287. ssd1.Name TeamLev,
  1288. TeamName,
  1289. ClientName,
  1290. ClientUnit,
  1291. VisitDate,
  1292. VisitDays,
  1293. VisitPNumber,
  1294. JietuanOperator JietuanOperatorId,
  1295. su.CnName JietuanOperator,
  1296. IsSure,
  1297. gdi.CreateTime,
  1298. su1.CnName As CreateUserName,
  1299. gdi.IsBid
  1300. FROM
  1301. Grp_DelegationInfo gdi
  1302. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1303. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1304. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1305. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1306. WHERE
  1307. gdi.IsDel = 0
  1308. AND gdi.IsBid = 0
  1309. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1310. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1311. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1312. #region 处理所属部门
  1313. /*
  1314. * 1.sq 和 gyy 等显示 市场部
  1315. * 2.王鸽和主管及张总还有管理员号统一国交部
  1316. * 2-1. 4 管理员 ,21 张海麟
  1317. */
  1318. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1319. List<int> userIds1 = new List<int>() { 4, 21 };
  1320. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1321. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1322. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1323. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1324. .ToListAsync();
  1325. var droupIds = groupList.Select(it => it.Id).ToList();
  1326. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1327. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1328. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1329. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1330. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1331. {
  1332. DiId = tcl.DiId,
  1333. LastName = dc.LastName,
  1334. FirstName = dc.FirstName,
  1335. Sex = dc.Sex,
  1336. Birthday = dc.BirthDay,
  1337. Company = cc.CompanyFullName,
  1338. Job = dc.Job,
  1339. CreateTime = tcl.CreateTime,
  1340. })
  1341. .ToList();
  1342. foreach (var item in groupList)
  1343. {
  1344. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1345. string groupFirstName = "";
  1346. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1347. if (currDatas.Any())
  1348. {
  1349. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1350. }
  1351. item.GroupFirst = groupFirstName;
  1352. }
  1353. #endregion
  1354. #region Excel
  1355. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1356. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1357. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1358. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1359. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1360. //载入模板
  1361. WorkbookDesigner designer = new WorkbookDesigner();
  1362. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1363. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1364. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1365. dt.TableName = "GroupList";
  1366. designer.SetDataSource(dt);
  1367. designer.Process();
  1368. if (!Directory.Exists(savePath))
  1369. {
  1370. Directory.CreateDirectory(savePath);
  1371. }
  1372. string serverPath = $"{savePath}{fileName}";
  1373. designer.Workbook.Save(serverPath);
  1374. string rst = $"{servicePath}{ftpPath}{fileName}";
  1375. #endregion
  1376. return Ok(JsonView(true, "操作成功!", rst));
  1377. }
  1378. #endregion
  1379. #region 团组&签证
  1380. /// <summary>
  1381. /// 根据团组Id获取签证客户信息List
  1382. /// </summary>
  1383. /// <param name="dto">请求dto</param>
  1384. /// <returns></returns>
  1385. [HttpPost]
  1386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1387. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1388. {
  1389. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1390. if (groupData.Code != 0)
  1391. {
  1392. return Ok(JsonView(false, groupData.Msg));
  1393. }
  1394. return Ok(JsonView(groupData.Data));
  1395. }
  1396. /// <summary>
  1397. /// IOS获取团组签证拍照上传进度01(团组列表)
  1398. /// </summary>
  1399. /// <param name="dto">请求dto</param>
  1400. /// <returns></returns>
  1401. [HttpPost]
  1402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1403. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1404. {
  1405. if (dto == null)
  1406. {
  1407. return Ok(JsonView(false, "参数为空"));
  1408. }
  1409. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1410. return Ok(JsonView(visaList));
  1411. }
  1412. /// <summary>
  1413. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1414. /// </summary>
  1415. /// <returns></returns>
  1416. [HttpPost]
  1417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1418. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1419. {
  1420. if (dto == null)
  1421. {
  1422. return Ok(JsonView(false, "请求错误:"));
  1423. }
  1424. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1425. return Ok(JsonView(list));
  1426. }
  1427. /// <summary>
  1428. /// IOS获取团组签证拍照上传进度03(相册)
  1429. /// </summary>
  1430. /// <returns></returns>
  1431. [HttpPost]
  1432. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1433. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1434. {
  1435. if (dto == null)
  1436. {
  1437. return Ok(JsonView(false, "请求错误:"));
  1438. }
  1439. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1440. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1441. list.ForEach(s => s.url = url);
  1442. return Ok(JsonView(list));
  1443. }
  1444. /// <summary>
  1445. /// IOS获取团组签证拍照上传进度04(图片上传)
  1446. /// </summary>
  1447. /// <param name="dto"></param>
  1448. /// <returns></returns>
  1449. [HttpPost]
  1450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1451. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1452. {
  1453. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1454. //if (!string.IsNullOrEmpty(result))
  1455. //{
  1456. //}
  1457. //else {
  1458. // return Ok(JsonView(false, "上传失败"));
  1459. //}
  1460. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1461. int sucNum = 0;
  1462. try
  1463. {
  1464. foreach (var item in dto.base64DataList)
  1465. {
  1466. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1467. string result = decodeBase64ToImage(item, imageName);
  1468. if (!string.IsNullOrEmpty(result))
  1469. {
  1470. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1471. pic.CreateUserId = dto.CreateUserId;
  1472. pic.PicName = imageName;
  1473. pic.PicPath = result;
  1474. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1475. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1476. if (insertResult > 0)
  1477. {
  1478. sucNum++;
  1479. }
  1480. }
  1481. }
  1482. }
  1483. catch (Exception ex)
  1484. {
  1485. return Ok(JsonView(false, ex.Message));
  1486. }
  1487. string msg = string.Format(@"成功上传{0}张", sucNum);
  1488. return Ok(JsonView(true, msg));
  1489. }
  1490. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1491. {
  1492. string filename = "";//声明一个string类型的相对路径
  1493. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1494. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1495. try//会有异常抛出,try,catch一下
  1496. {
  1497. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1498. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1499. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1500. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1501. //文件名称
  1502. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1503. //上传的文件的路径
  1504. string filePath = "";
  1505. if (!Directory.Exists(fileDir))
  1506. {
  1507. Directory.CreateDirectory(fileDir);
  1508. }
  1509. //上传的文件的路径
  1510. filePath = fileDir + filename;
  1511. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1512. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1513. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1514. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1515. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1516. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1517. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1518. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1519. bitmap.Dispose();
  1520. }
  1521. catch (Exception e)
  1522. {
  1523. string massage = e.Message;
  1524. Logs("IOS图片上传Error:" + massage);
  1525. //filename = e.Message;
  1526. }
  1527. return filename;//返回相对路径
  1528. }
  1529. /// <summary>
  1530. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1531. /// </summary>
  1532. /// <param name="dto"></param>
  1533. /// <returns></returns>
  1534. [HttpPost]
  1535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1536. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1537. {
  1538. if (dto == null)
  1539. {
  1540. return Ok(JsonView(false, "请求错误:"));
  1541. }
  1542. string msg = "参数错误";
  1543. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1544. {
  1545. try
  1546. {
  1547. //_delegationVisaRep.BeginTran();
  1548. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1549. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1550. .Where(s => s.Id == dto.visaProgressCustomerId)
  1551. .ExecuteCommandAsync();
  1552. if (updCount > 0 && dto.publishCode == 1)
  1553. {
  1554. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1555. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1556. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1557. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1558. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1559. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1560. if (groupData == null)
  1561. {
  1562. _delegationVisaRep.RollbackTran();
  1563. }
  1564. string title = string.Format(@"[签证进度更新]");
  1565. string content = string.Format(@"测试文本");
  1566. bool rst = await _message.AddMsg(new MessageDto()
  1567. {
  1568. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1569. IssuerId = dto.publisher,
  1570. Title = title,
  1571. Content = content,
  1572. ReleaseTime = DateTime.Now,
  1573. UIdList = new List<int> {
  1574. 234
  1575. }
  1576. });
  1577. if (rst)
  1578. {
  1579. return Ok(JsonView(true, "发送通知成功"));
  1580. }
  1581. }
  1582. //_delegationVisaRep.CommitTran();
  1583. }
  1584. catch (Exception)
  1585. {
  1586. //_delegationVisaRep.RollbackTran();
  1587. }
  1588. }
  1589. return Ok(JsonView(true, msg));
  1590. }
  1591. #endregion
  1592. #region 团组任务分配
  1593. /// <summary>
  1594. /// 团组任务分配初始化
  1595. /// </summary>
  1596. /// <param name="dto"></param>
  1597. /// <returns></returns>
  1598. [HttpPost]
  1599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1600. public async Task<IActionResult> GetTaskAssignmen()
  1601. {
  1602. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1603. if (groupData.Code != 0)
  1604. {
  1605. return Ok(JsonView(false, groupData.Msg));
  1606. }
  1607. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1608. }
  1609. /// <summary>
  1610. /// 团组任务分配查询
  1611. /// </summary>
  1612. /// <param name="dto"></param>
  1613. /// <returns></returns>
  1614. [HttpPost]
  1615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1616. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1617. {
  1618. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1619. if (groupData.Code != 0)
  1620. {
  1621. return Ok(JsonView(false, groupData.Msg));
  1622. }
  1623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1624. }
  1625. /// <summary>
  1626. /// 团组任务分配操作
  1627. /// </summary>
  1628. /// <param name="dto"></param>
  1629. /// <returns></returns>
  1630. [HttpPost]
  1631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1632. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1633. {
  1634. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1635. if (groupData.Code != 0)
  1636. {
  1637. return Ok(JsonView(false, groupData.Msg));
  1638. }
  1639. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1640. }
  1641. /// <summary>
  1642. /// 团组任务分配
  1643. /// 批量分配
  1644. /// 查询团组
  1645. /// </summary>
  1646. /// <param name="dto"></param>
  1647. /// <returns></returns>
  1648. [HttpPost]
  1649. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1650. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1651. {
  1652. //参数验证
  1653. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1654. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1655. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1656. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1657. }
  1658. /// <summary>
  1659. /// 团组任务分配
  1660. /// 批量分配
  1661. /// </summary>
  1662. /// <param name="dto"></param>
  1663. /// <returns></returns>
  1664. [HttpPost]
  1665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1666. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1667. {
  1668. //参数验证
  1669. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1670. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1671. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1672. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1673. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1674. }
  1675. #endregion
  1676. #region 团组费用审核
  1677. /// <summary>
  1678. /// 费用审核
  1679. /// 团组列表 Page
  1680. /// </summary>
  1681. /// <param name="_dto">团组列表请求dto</param>
  1682. /// <returns></returns>
  1683. [HttpPost]
  1684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1685. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1686. {
  1687. #region 参数验证
  1688. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1689. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1690. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1691. #region 页面操作权限验证
  1692. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1693. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1694. #endregion
  1695. #endregion
  1696. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1697. {
  1698. string sqlWhere = string.Empty;
  1699. if (_dto.IsSure == 0) //未完成
  1700. {
  1701. sqlWhere += string.Format(@" And IsSure = 0");
  1702. }
  1703. else if (_dto.IsSure == 1) //已完成
  1704. {
  1705. sqlWhere += string.Format(@" And IsSure = 1");
  1706. }
  1707. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1708. {
  1709. string tj = _dto.SearchCriteria;
  1710. 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}%')",
  1711. tj, tj, tj, tj, tj);
  1712. }
  1713. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1714. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1715. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1716. From (
  1717. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1718. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1719. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1720. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1721. From Grp_DelegationInfo gdi
  1722. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1723. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1724. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1725. Where gdi.IsDel = 0 {0}
  1726. ) temp ", sqlWhere);
  1727. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1728. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1729. var _view = new
  1730. {
  1731. PageFuncAuth = pageFunAuthView,
  1732. Data = _DelegationList
  1733. };
  1734. return Ok(JsonView(true, "查询成功!", _view, total));
  1735. }
  1736. else
  1737. {
  1738. return Ok(JsonView(false, "查询失败"));
  1739. }
  1740. }
  1741. /// <summary>
  1742. /// 获取团组费用审核
  1743. /// </summary>
  1744. /// <param name="paras">参数Json字符串</param>
  1745. /// <returns></returns>
  1746. [HttpPost]
  1747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1748. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1749. {
  1750. try
  1751. {
  1752. #region 参数验证
  1753. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1754. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1755. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1756. #region 页面操作权限验证
  1757. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1758. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1759. #endregion
  1760. #endregion
  1761. var _view = new Grp_CreditCardPaymentView();
  1762. var clientNameList = getSimplClientList(_dto.DiId);
  1763. #region 费用清单
  1764. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1765. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1766. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1767. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1768. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1769. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1770. /*
  1771. * 76://酒店预订
  1772. */
  1773. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1774. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. /*
  1776. * 79://车/导游地接
  1777. */
  1778. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1780. /*
  1781. * 80: //签证
  1782. */
  1783. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1784. /*
  1785. *81: //邀请/公务活动
  1786. */
  1787. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1788. /*
  1789. * 82: //团组客户保险
  1790. */
  1791. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1792. /*
  1793. * Lable = 85 机票预订
  1794. */
  1795. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1796. /*
  1797. * 85 机票预定
  1798. */
  1799. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 98 其他款项
  1802. */
  1803. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1804. /*
  1805. * 285:收款退还
  1806. */
  1807. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1808. /*
  1809. * 1015: //超支费用
  1810. */
  1811. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1812. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1813. /*
  1814. * 币种信息
  1815. */
  1816. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1817. /*
  1818. * 车/导游地接 费用类型
  1819. */
  1820. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1821. /*
  1822. * 车/导游地接 费用类型
  1823. */
  1824. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1825. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1826. /*
  1827. * 用户信息
  1828. */
  1829. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1830. /*
  1831. * 费用模块
  1832. */
  1833. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1834. string priceModule = string.Empty;
  1835. if (sdPriceName != null)
  1836. {
  1837. priceModule = sdPriceName.Name;
  1838. }
  1839. /*
  1840. * 成本信息
  1841. */
  1842. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1843. decimal _groupRate = 0.0000M;
  1844. string _groupCurrencyCode = "-";
  1845. if (groupCost != null)
  1846. {
  1847. _groupRate = groupCost.Rate;
  1848. if (int.TryParse(groupCost.Currency, out int _currency))
  1849. {
  1850. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1851. }
  1852. else _groupCurrencyCode = groupCost.Currency;
  1853. }
  1854. string costContentSql = $"Select * From Grp_GroupCost";
  1855. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1856. //处理日期为空的天数
  1857. for (int i = 0; i < groupCostDetails.Count; i++)
  1858. if (i != 0)
  1859. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1860. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1861. /*
  1862. * 处理详情数据
  1863. */
  1864. foreach (var entity in entityList)
  1865. {
  1866. var _detail = new Grp_CreditCardPaymentDetailView();
  1867. _detail.Id = entity.Id;
  1868. _detail.PriceName = priceModule;
  1869. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1870. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1871. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1872. //处理金额
  1873. if (entity.CTable == 1015)
  1874. {
  1875. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1876. if (czInfo != null)
  1877. {
  1878. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1879. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1880. }
  1881. }
  1882. /*
  1883. * 应付款金额
  1884. */
  1885. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1886. string PaymentCurrency_WaitPay = "Unknown";
  1887. string hotelCurrncyCode = "Unknown";
  1888. string hotelCurrncyName = "Unknown";
  1889. if (sdPaymentCurrency_WaitPay != null)
  1890. {
  1891. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1892. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1893. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1894. if (hotelCurrncyCode.Equals("CNY"))
  1895. {
  1896. entity.DayRate = 1.0000M;
  1897. }
  1898. }
  1899. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1900. /*
  1901. * 此次付款金额
  1902. */
  1903. decimal CurrPayStr = 0.00M,
  1904. OriginalCurrPay = 0.00M;
  1905. if (entity.PayPercentage == 0)
  1906. {
  1907. if (entity.PayThenMoney != 0)
  1908. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1909. }
  1910. else
  1911. {
  1912. if (entity.PayMoney != 0)
  1913. {
  1914. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1915. }
  1916. }
  1917. //if (_dto.Label == 79)
  1918. //{
  1919. // string original = string.Empty;
  1920. // if (hotelCurrncyCode.Equals("CNY"))
  1921. // {
  1922. // OriginalCurrPay = CurrPayStr;
  1923. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1924. // }
  1925. // else
  1926. // {
  1927. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1928. // //760 EUR(7600.00 CNY)
  1929. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1930. // }
  1931. //}
  1932. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1933. string original = string.Empty;
  1934. if (hotelCurrncyCode.Equals("CNY"))
  1935. {
  1936. OriginalCurrPay = CurrPayStr;
  1937. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1938. }
  1939. else
  1940. {
  1941. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1942. //760 EUR(7600.00 CNY)
  1943. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1944. }
  1945. /*
  1946. * 剩余尾款
  1947. */
  1948. decimal BalanceStr = 0;
  1949. if (CurrPayStr != 0)
  1950. {
  1951. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1952. BalanceStr = 0;
  1953. else
  1954. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1955. }
  1956. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1957. /*
  1958. * Bus名称
  1959. */
  1960. _detail.BusName = "待增加";
  1961. /*
  1962. *费用所属
  1963. */
  1964. switch (entity.CTable)
  1965. {
  1966. case 76://酒店预订
  1967. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1968. if (hotelReservations != null)
  1969. {
  1970. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1971. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1972. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1973. string roomFeeStr = "", roomFeestr1 = "";
  1974. //是否比较房型价格
  1975. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1976. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1977. roomFeeStr += $"<br/>";
  1978. var roomTotal = 0.00M;
  1979. if (hotelReservations.SingleRoomPrice > 0)
  1980. {
  1981. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1982. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1983. __isSingle = true;
  1984. roomTotal += fee;
  1985. }
  1986. if (hotelReservations.DoubleRoomPrice > 0)
  1987. {
  1988. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1989. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1990. __isDouble = true;
  1991. roomTotal += fee;
  1992. }
  1993. if (hotelReservations.SuiteRoomPrice > 0)
  1994. {
  1995. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1996. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1997. __isSuite = true;
  1998. roomTotal += fee;
  1999. }
  2000. if (hotelReservations.OtherRoomPrice > 0)
  2001. {
  2002. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  2003. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2004. __isOther = true;
  2005. roomTotal += fee;
  2006. }
  2007. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2008. else roomFeeStr += " 0.00 * 0";
  2009. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2010. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2011. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2012. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2013. /*
  2014. * 费用类型
  2015. * 1:房费
  2016. * 2:早餐
  2017. * 3:地税
  2018. * 4:城市税
  2019. * </summary>
  2020. */
  2021. //地税
  2022. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2023. if (governmentRentData != null)
  2024. {
  2025. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2026. governmentRentFee = governmentRentData.Price;
  2027. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2028. if (governmentRentCurrData != null)
  2029. {
  2030. governmentRentCode = governmentRentCurrData.Name;
  2031. governmentRentName = $"({governmentRentCurrData.Remark})";
  2032. }
  2033. }
  2034. //城市税
  2035. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2036. if (cityTaxData != null)
  2037. {
  2038. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2039. cityTaxFee = cityTaxData.Price;
  2040. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2041. if (cityTaxCurrData != null)
  2042. {
  2043. cityTaxCode = cityTaxCurrData.Name;
  2044. cityTaxName = $"({cityTaxCurrData.Remark})";
  2045. }
  2046. }
  2047. //酒店早餐
  2048. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2049. if (breakfastData != null)
  2050. {
  2051. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2052. breakfastFee = breakfastData.Price;
  2053. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2054. if (breakfastCurrData != null)
  2055. {
  2056. breakfastCode = breakfastCurrData.Name;
  2057. breakfastName = $"({breakfastCurrData.Remark})";
  2058. }
  2059. }
  2060. //房间费用
  2061. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2062. if (roomData != null)
  2063. {
  2064. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2065. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2066. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2067. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2068. roomFee = roomData.Price;
  2069. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2070. if (roomCurrData != null)
  2071. {
  2072. roomCode = roomCurrData.Name;
  2073. roomName = $"({roomCurrData.Remark})";
  2074. }
  2075. }
  2076. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2077. string hotelCostStr = "";
  2078. decimal hotelCsotTotal = 0.00M;
  2079. if (groupCost != null)
  2080. {
  2081. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2082. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2083. }
  2084. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2085. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2086. string hotelCost_day = "";
  2087. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2088. foreach (var item in hotelCostDetails1)
  2089. {
  2090. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2091. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2092. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2093. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2094. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2095. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2096. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2097. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2098. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2099. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2100. hotelCost_day += @$"<br/>";
  2101. }
  2102. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2103. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2104. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2105. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2106. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2107. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2108. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2109. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2110. $"房间说明: {hotelReservations.Remark} <br/>" +
  2111. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2112. $"{hotelBreakfastStr}" +
  2113. $"{hotelGovernmentRentStr}" +
  2114. $"{hotelCityTaxStr}";
  2115. _detail.PriceNameContent = hotelReservations.HotelName;
  2116. }
  2117. break;
  2118. case 79://车/导游地接
  2119. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2120. if (touristGuideGroundReservations != null)
  2121. {
  2122. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2123. {
  2124. _detail.BusName = touristGuideGroundReservations.BusName;
  2125. }
  2126. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2127. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2128. //if (isInt)
  2129. //{
  2130. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2131. // if (cityInfo != null)
  2132. // {
  2133. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2134. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2135. // if (carFeeItem != null)
  2136. // {
  2137. // nameContent += $@"({carFeeItem.Name})";
  2138. // }
  2139. // _detail.PriceNameContent = nameContent;
  2140. // }
  2141. //}
  2142. //else
  2143. //{
  2144. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2145. //}
  2146. var touristGuideGroundReservationsContents =
  2147. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2148. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2149. foreach (var item in touristGuideGroundReservationsContents)
  2150. {
  2151. string typeName = "Unknown";
  2152. string carCurrencyCode = "Unknown";
  2153. string carCurrencyName = "Unknown";
  2154. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2155. if (carTypeData != null) typeName = carTypeData.Name;
  2156. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2157. if (currencyData != null)
  2158. {
  2159. carCurrencyCode = currencyData.Name;
  2160. carCurrencyName = currencyData.Remark;
  2161. }
  2162. //op、成本 币种是否一致
  2163. bool IsCurrencyAgreement = false;
  2164. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2165. string opCostStr = string.Empty;
  2166. decimal opCostTypePrice = 0.00M;
  2167. #region 处理成本各项费用
  2168. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2169. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2170. if (opCost.Count > 0)
  2171. {
  2172. switch (item.SId)
  2173. {
  2174. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2175. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2176. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2177. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2178. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2179. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2180. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2181. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2182. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2183. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2184. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2185. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2186. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2187. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2188. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2189. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2190. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2191. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2192. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2193. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2194. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2197. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2198. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2199. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2200. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2201. }
  2202. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2203. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2204. }
  2205. #endregion
  2206. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2207. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2208. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2209. $"{opTypeStr} {opCostStr}<br/>" +
  2210. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2211. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2212. }
  2213. _detail.PriceMsgContent = priceMsg;
  2214. }
  2215. break;
  2216. case 80: //签证
  2217. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2218. if (visaInfo != null)
  2219. {
  2220. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2221. _detail.PriceNameContent = visaInfo.VisaDescription;
  2222. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2223. }
  2224. break;
  2225. case 81: //邀请/公务活动
  2226. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2227. if (_ioa != null)
  2228. {
  2229. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2230. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2231. sendCurrName = "Unknown", //快递费用币种 Name
  2232. sendCurrCode = "Unknown", //快递费用币种 Code
  2233. eventsCurrName = "Unknown", //公务活动费币种 Name
  2234. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2235. translateCurrName = "Unknown", //公务翻译费 Name
  2236. translateCurrCode = "Unknown"; //公务翻译费 Code
  2237. #region 处理费用币种
  2238. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2239. if (inviteCurrData != null)
  2240. {
  2241. inviteCurrName = inviteCurrData.Remark;
  2242. inviteCurrCode = inviteCurrData.Name;
  2243. }
  2244. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2245. if (sendCurrData != null)
  2246. {
  2247. sendCurrName = sendCurrData.Remark;
  2248. sendCurrCode = sendCurrData.Name;
  2249. }
  2250. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2251. if (eventsCurrData != null)
  2252. {
  2253. eventsCurrName = eventsCurrData.Remark;
  2254. eventsCurrCode = eventsCurrData.Name;
  2255. }
  2256. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2257. if (translateCurrData != null)
  2258. {
  2259. translateCurrName = translateCurrData.Remark;
  2260. translateCurrCode = translateCurrData.Name;
  2261. }
  2262. #endregion
  2263. _detail.PriceNameContent = _ioa.InviterArea;
  2264. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2265. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2266. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2267. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2268. $@"备注:" + _ioa.Remark + "<br/>";
  2269. }
  2270. break;
  2271. case 82: //团组客户保险
  2272. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2273. if (customers != null)
  2274. {
  2275. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2276. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2277. }
  2278. break;
  2279. case 85: //机票预订
  2280. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2281. if (jpRes != null)
  2282. {
  2283. string FlightsDescription = jpRes.FlightsDescription;
  2284. string PriceDescription = jpRes.PriceDescription;
  2285. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2286. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2287. }
  2288. break;
  2289. case 98://其他款项
  2290. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2291. if (gdpRes != null)
  2292. {
  2293. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2294. _detail.PriceNameContent = gdpRes.PriceName;
  2295. }
  2296. break;
  2297. case 285://收款退还
  2298. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2299. if (refundAndOtherMoney != null)
  2300. {
  2301. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2302. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2303. }
  2304. break;
  2305. case 751://酒店早餐
  2306. break;
  2307. case 1015://超支费用
  2308. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2309. if (groupExtraCost != null)
  2310. {
  2311. _detail.PriceNameContent = groupExtraCost.PriceName;
  2312. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2313. }
  2314. break;
  2315. default:
  2316. break;
  2317. }
  2318. /*
  2319. * 申请人
  2320. */
  2321. string operatorName = " - ";
  2322. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2323. if (_opUser != null)
  2324. {
  2325. operatorName = _opUser.CnName;
  2326. }
  2327. _detail.OperatorName = operatorName;
  2328. /*
  2329. * 审核人
  2330. */
  2331. string auditOperatorName = "Unknown";
  2332. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2333. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2334. else
  2335. {
  2336. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2337. if (_adUser != null)
  2338. {
  2339. auditOperatorName = _adUser.CnName;
  2340. }
  2341. }
  2342. _detail.AuditOperatorName = auditOperatorName;
  2343. /*
  2344. * 超预算比例
  2345. */
  2346. string overBudgetStr = "";
  2347. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2348. else if (entity.ExceedBudget == 0)
  2349. {
  2350. if (entity.CTable == 76 || entity.CTable == 79)
  2351. {
  2352. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2353. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2354. }
  2355. else
  2356. {
  2357. overBudgetStr = "未超预算";
  2358. }
  2359. }
  2360. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2361. _detail.OverBudget = overBudgetStr;
  2362. decimal auditFee = 0.00M; //已审核金额 人名币
  2363. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2364. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2365. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2366. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2367. {
  2368. auditedFeeOriginal = entity.PayMoney;
  2369. auditFee = CurrPayStr;
  2370. }
  2371. else if (entity.IsAuditGM == 0)
  2372. {
  2373. unAuditFeeCNY = CurrPayStr;
  2374. unAuditFeeOriginal = OriginalCurrPay;
  2375. OriginalCurrPay = 0.00M;
  2376. }
  2377. /*
  2378. * 费用总计
  2379. */
  2380. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2381. {
  2382. CurrencyId = entity.PaymentCurrency,
  2383. CurrencyName = PaymentCurrency_WaitPay,
  2384. AmountPayable = entity.PayMoney,
  2385. ThisPayment = OriginalCurrPay,
  2386. BalancePayment = BalanceStr,
  2387. AuditedFunds = auditFee,
  2388. AuditedFundsOriginal = auditedFeeOriginal,
  2389. UnAuditFundsCNY = unAuditFeeCNY,
  2390. UnAuditFundsOriginal = unAuditFeeOriginal
  2391. });
  2392. _detail.IsAuditGM = entity.IsAuditGM;
  2393. detailList.Add(_detail);
  2394. }
  2395. #endregion
  2396. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2397. /*
  2398. * 下方描述处理
  2399. */
  2400. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2401. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2402. if (ccpCurrencyPrice != null)
  2403. {
  2404. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2405. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2406. }
  2407. else
  2408. {
  2409. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2410. }
  2411. string amountPayableStr = string.Format(@"应付款总金额: ");
  2412. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2413. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2414. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2415. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2416. foreach (var item in nonDuplicat)
  2417. {
  2418. var currencyName = item.CurrencyName;
  2419. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2420. if (strs.Count > 0)
  2421. {
  2422. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2423. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2424. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2425. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2426. //单独处理此次付款金额
  2427. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2428. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2429. //单独处理已审核费用
  2430. //if (item.CurrencyId == 836) //人民币
  2431. //{
  2432. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2433. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2434. //}
  2435. //else
  2436. //{
  2437. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2438. //}
  2439. if (currencyName.Equals("CNY"))
  2440. {
  2441. //已审核费用
  2442. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2443. //未审核费用
  2444. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2445. }
  2446. else
  2447. {
  2448. //已审核费用
  2449. auditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName, strs.Sum(x => x.AuditedFunds).ToString("#0.00"));
  2450. //未审核费用
  2451. unAuditedFundsStr += string.Format(@"{0}{1}({2}CNY)&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName, strs.Sum(x => x.UnAuditFundsCNY).ToString("#0.00"));
  2452. }
  2453. }
  2454. }
  2455. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2456. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2457. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2458. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2459. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2460. var _view1 = new
  2461. {
  2462. PageFuncAuth = pageFunAuthView,
  2463. Data = _view
  2464. };
  2465. return Ok(JsonView(_view1));
  2466. }
  2467. catch (Exception ex)
  2468. {
  2469. return Ok(JsonView(false, ex.Message));
  2470. }
  2471. }
  2472. /// <summary>
  2473. /// 费用审核
  2474. /// 修改团组费用审核状态
  2475. /// </summary>
  2476. /// <param name="_dto">参数Json字符串</param>
  2477. /// <returns></returns>
  2478. [HttpPost]
  2479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2480. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2481. {
  2482. #region 参数验证
  2483. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2484. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2485. #endregion
  2486. #region 页面操作权限验证
  2487. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2488. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2489. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2490. #endregion
  2491. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2492. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2493. DateTime dtNow = DateTime.Now;
  2494. _groupRepository.BeginTran();
  2495. int rst = 0;
  2496. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2497. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2498. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2499. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2500. List<dynamic> msgDatas = new List<dynamic>();
  2501. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2502. foreach (var item in idList)
  2503. {
  2504. int CreditId = int.Parse(item);
  2505. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2506. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2507. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2508. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2509. .Where(s => s.Id == CreditId)
  2510. .ExecuteCommandAsync();
  2511. if (result < 1)
  2512. {
  2513. rst = -1;
  2514. _groupRepository.RollbackTran();
  2515. return Ok(JsonView(false, "操作失败并回滚!"));
  2516. }
  2517. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2518. if (creditData != null)
  2519. {
  2520. #region 应用通知配置
  2521. try
  2522. {
  2523. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2524. }
  2525. catch (Exception ex)
  2526. {
  2527. }
  2528. #endregion
  2529. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2530. string groupNameStr = string.Empty;
  2531. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2532. if (groupData != null) groupNameStr = groupData.TeamName;
  2533. string creditTypeStr = string.Empty;
  2534. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2535. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2536. string creditCurrency = string.Empty;
  2537. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2538. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2539. if (creditCurrency.Equals("CNY"))
  2540. {
  2541. creditData.DayRate = 1.0000M;
  2542. }
  2543. if (creditData.PayPercentage == 0.00M)
  2544. {
  2545. creditData.PayPercentage = 100M;
  2546. }
  2547. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2548. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2549. string msgContent = "";
  2550. if (creditCurrency.Equals("CNY"))
  2551. {
  2552. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2553. }
  2554. else
  2555. {
  2556. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2557. }
  2558. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2559. }
  2560. }
  2561. if (rst == 0)
  2562. {
  2563. _groupRepository.CommitTran();
  2564. foreach (var item in msgDatas)
  2565. {
  2566. //发送消息
  2567. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2568. }
  2569. #region 应用推送
  2570. try
  2571. {
  2572. foreach (var ccpId in dic_ccp_user.Keys)
  2573. {
  2574. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2575. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2576. }
  2577. }
  2578. catch (Exception)
  2579. {
  2580. }
  2581. #endregion
  2582. return Ok(JsonView(true, "操作成功!"));
  2583. }
  2584. return Ok(JsonView(false, "操作失败!"));
  2585. }
  2586. #endregion
  2587. #region 机票费用录入
  2588. /// <summary>
  2589. /// 机票录入当前登录人可操作团组
  2590. /// </summary>
  2591. /// <param name="dto"></param>
  2592. /// <returns></returns>
  2593. [HttpPost]
  2594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2595. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2596. {
  2597. try
  2598. {
  2599. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2600. if (groupData.Code != 0)
  2601. {
  2602. return Ok(JsonView(false, groupData.Msg));
  2603. }
  2604. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2605. }
  2606. catch (Exception ex)
  2607. {
  2608. return Ok(JsonView(false, "程序错误!"));
  2609. throw;
  2610. }
  2611. }
  2612. /// <summary>
  2613. /// 机票费用录入列表
  2614. /// </summary>
  2615. /// <param name="dto"></param>
  2616. /// <returns></returns>
  2617. [HttpPost]
  2618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2619. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2620. {
  2621. try
  2622. {
  2623. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2624. if (groupData.Code != 0)
  2625. {
  2626. return Ok(JsonView(false, groupData.Msg));
  2627. }
  2628. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2629. }
  2630. catch (Exception ex)
  2631. {
  2632. return Ok(JsonView(false, ex.Message));
  2633. throw;
  2634. }
  2635. }
  2636. /// <summary>
  2637. /// 根据id查询费用录入信息
  2638. /// </summary>
  2639. /// <param name="dto"></param>
  2640. /// <returns></returns>
  2641. [HttpPost]
  2642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2643. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2644. {
  2645. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2646. if (groupData.Code != 0)
  2647. {
  2648. return Ok(JsonView(false, groupData.Msg));
  2649. }
  2650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  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> OpAirTicketRes(AirTicketResOpDto dto)
  2660. {
  2661. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2662. if (groupData.Code != 0)
  2663. {
  2664. return Ok(JsonView(false, groupData.Msg));
  2665. }
  2666. #region 应用推送
  2667. try
  2668. {
  2669. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2670. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2671. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2672. //2024-10-21 新增LZ UID
  2673. var userIds = new List<int>() { 21 };
  2674. string title = $"系统通知";
  2675. string content = "";
  2676. var diId = dto.AirTicketResOpData.DiId;
  2677. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2678. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2679. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2680. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2681. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2682. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2683. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2684. }
  2685. catch (Exception ex)
  2686. {
  2687. }
  2688. #endregion
  2689. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2690. }
  2691. /// <summary>
  2692. /// 根据舱位类型查询接团客户名单信息
  2693. /// </summary>
  2694. /// <param name="dto"></param>
  2695. /// <returns></returns>
  2696. [HttpPost]
  2697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2698. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2699. {
  2700. try
  2701. {
  2702. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2703. if (crm_Groups.Count != 0)
  2704. {
  2705. List<dynamic> Customer = new List<dynamic>();
  2706. foreach (var item in crm_Groups)
  2707. {
  2708. var data = new
  2709. {
  2710. Id = item.Id,
  2711. Pinyin = item.Pinyin,
  2712. Name = item.LastName + item.FirstName
  2713. };
  2714. Customer.Add(data);
  2715. }
  2716. return Ok(JsonView(true, "查询成功!", Customer));
  2717. }
  2718. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2719. }
  2720. catch (Exception ex)
  2721. {
  2722. return Ok(JsonView(false, "程序错误!"));
  2723. throw;
  2724. }
  2725. }
  2726. /// <summary>
  2727. /// 根据团号获取客户信息
  2728. /// </summary>
  2729. /// <param name="dto"></param>
  2730. /// <returns></returns>
  2731. [HttpPost]
  2732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2733. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2734. {
  2735. var jw = JsonView(false);
  2736. if (dto.DIID < 1)
  2737. {
  2738. jw.Msg += "请输入正确的diid";
  2739. return Ok(jw);
  2740. }
  2741. var arr = getSimplClientList(dto.DIID);
  2742. jw = JsonView(true, "获取成功!", arr);
  2743. return Ok(jw);
  2744. }
  2745. private List<SimplClientInfo> getSimplClientList(int diId)
  2746. {
  2747. 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);
  2748. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2749. foreach (var item in arr)
  2750. {
  2751. EncryptionProcessor.DecryptProperties(item);
  2752. }
  2753. return arr;
  2754. }
  2755. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2756. {
  2757. string result = origin;
  2758. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2759. {
  2760. string[] temparr = origin.Split(',');
  2761. string fistrStr = temparr[0];
  2762. int count = temparr.Count();
  2763. int tempId;
  2764. bool success = int.TryParse(fistrStr, out tempId);
  2765. if (success)
  2766. {
  2767. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2768. if (tempInfo != null)
  2769. {
  2770. if (count > 1)
  2771. {
  2772. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2773. }
  2774. else
  2775. {
  2776. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2777. }
  2778. }
  2779. }
  2780. }
  2781. return result;
  2782. }
  2783. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2784. {
  2785. string result = origin;
  2786. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2787. {
  2788. string[] temparr = origin.Split(',');
  2789. result = "";
  2790. foreach (var item in temparr)
  2791. {
  2792. int tempId;
  2793. bool success = int.TryParse(item, out tempId);
  2794. if (success)
  2795. {
  2796. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2797. if (tempInfo != null)
  2798. {
  2799. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2800. }
  2801. }
  2802. }
  2803. }
  2804. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2805. return result;
  2806. }
  2807. /// <summary>
  2808. /// 机票费用录入,删除
  2809. /// </summary>
  2810. /// <param name="dto"></param>
  2811. /// <returns></returns>
  2812. [HttpPost]
  2813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2814. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2815. {
  2816. try
  2817. {
  2818. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2819. if (res)
  2820. {
  2821. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2822. {
  2823. IsDel = 1,
  2824. DeleteUserId = dto.DeleteUserId,
  2825. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2826. }).ExecuteCommandAsync();
  2827. return Ok(JsonView(true, "删除成功!"));
  2828. }
  2829. return Ok(JsonView(false, "删除失败!"));
  2830. }
  2831. catch (Exception ex)
  2832. {
  2833. return Ok(JsonView(false, "程序错误!"));
  2834. throw;
  2835. }
  2836. }
  2837. /// <summary>
  2838. /// 导出机票录入报表
  2839. /// </summary>
  2840. /// <param name="dto"></param>
  2841. /// <returns></returns>
  2842. [HttpPost]
  2843. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2844. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2845. {
  2846. try
  2847. {
  2848. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2849. if (groupData.Code != 0)
  2850. {
  2851. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2852. }
  2853. else
  2854. {
  2855. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2856. if (AirTicketReservations.Count != 0)
  2857. {
  2858. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2859. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2860. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2861. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2862. WorkbookDesigner designer = new WorkbookDesigner();
  2863. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2864. decimal countCost = 0;
  2865. foreach (var item in AirTicketReservations)
  2866. {
  2867. #region 处理客人姓名
  2868. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2869. item.ClientName = clientNames;
  2870. #endregion
  2871. if (item.BankType == "其他")
  2872. {
  2873. item.BankNo = "--";
  2874. }
  2875. else
  2876. {
  2877. if (!string.IsNullOrEmpty(item.BankType))
  2878. {
  2879. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2880. }
  2881. }
  2882. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2883. item.Price = System.Decimal.Round(item.Price, 2);
  2884. countCost += Convert.ToDecimal(item.Price);
  2885. }
  2886. designer.SetDataSource("Export", AirTicketReservations);
  2887. designer.SetDataSource("ExportDiCode", diCode);
  2888. designer.SetDataSource("ExportDiName", diName);
  2889. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2890. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2891. designer.Process();
  2892. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2893. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2894. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2895. return Ok(JsonView(true, "成功", url = rst));
  2896. }
  2897. else
  2898. {
  2899. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2900. }
  2901. }
  2902. }
  2903. catch (Exception ex)
  2904. {
  2905. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2906. throw;
  2907. }
  2908. }
  2909. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2910. /// <summary>
  2911. /// 行程单导出
  2912. /// </summary>
  2913. /// <param name="dto"></param>
  2914. /// <returns></returns>
  2915. [HttpPost]
  2916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2917. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2918. {
  2919. try
  2920. {
  2921. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2922. if (groupData.Code != 0)
  2923. {
  2924. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2925. }
  2926. else
  2927. {
  2928. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2929. if (dto.Language == "CN")
  2930. {
  2931. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2932. DocumentBuilder builder = new DocumentBuilder(doc);
  2933. int tableIndex = 0;//表格索引
  2934. //得到文档中的第一个表格
  2935. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2936. foreach (var item in _AirTicketReservations)
  2937. {
  2938. #region 处理固定数据
  2939. string[] FlightsCode = item.FlightsCode.Split('/');
  2940. if (FlightsCode.Length != 0)
  2941. {
  2942. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2943. if (_AirCompany != null)
  2944. {
  2945. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2946. }
  2947. else
  2948. {
  2949. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2950. }
  2951. }
  2952. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2953. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2954. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2955. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2956. string name = "";
  2957. foreach (string clientName in nameArray)
  2958. {
  2959. if (!name.Contains(clientName))
  2960. {
  2961. name += clientName + ",";
  2962. }
  2963. }
  2964. if (!string.IsNullOrWhiteSpace(name))
  2965. {
  2966. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2967. }
  2968. else
  2969. {
  2970. table.Range.Bookmarks["ClientName"].Text = "--";
  2971. }
  2972. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2973. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2974. table.Range.Bookmarks["JointTicket"].Text = "--";
  2975. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2976. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2977. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2978. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2979. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2980. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2981. #endregion
  2982. #region 循环数据处理
  2983. List<AirInfo> airs = new List<AirInfo>();
  2984. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2985. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2986. for (int i = 0; i < FlightsCode.Length; i++)
  2987. {
  2988. AirInfo air = new AirInfo();
  2989. string[] tempstr = DayArray[i]
  2990. .Replace("\r\n", string.Empty)
  2991. .Replace("\\r\\n", string.Empty)
  2992. .TrimStart().TrimEnd()
  2993. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2994. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2995. string starCity = "";
  2996. if (star_Three != null)
  2997. {
  2998. starCity = star_Three.AirPort;
  2999. }
  3000. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3001. string EndCity = "";
  3002. if (End_Three != null)
  3003. {
  3004. EndCity = End_Three.AirPort;
  3005. }
  3006. air.Destination = starCity + "/" + EndCity;
  3007. air.Flight = FlightsCode[i];
  3008. air.SeatingClass = item.CTypeName;
  3009. string dateTime = tempstr[2];
  3010. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3011. air.FlightDate = DateTemp;
  3012. air.DepartureTime = tempstr[5];
  3013. air.LandingTime = tempstr[6];
  3014. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3015. air.TicketStatus = "--";
  3016. air.Luggage = "--";
  3017. air.DepartureTerminal = "--";
  3018. air.LandingTerminal = "--";
  3019. airs.Add(air);
  3020. }
  3021. int row = 13;
  3022. for (int i = 0; i < airs.Count; i++)
  3023. {
  3024. if (airs.Count > 2)
  3025. {
  3026. for (int j = 0; j < airs.Count - 2; j++)
  3027. {
  3028. var CopyRow = table.Rows[12].Clone(true);
  3029. table.Rows.Add(CopyRow);
  3030. }
  3031. }
  3032. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3033. int index = 0;
  3034. foreach (PropertyInfo property in properties)
  3035. {
  3036. string value = property.GetValue(airs[i]).ToString();
  3037. Cell ishcel0 = table.Rows[row].Cells[index];
  3038. Paragraph p = new Paragraph(doc);
  3039. string s = value;
  3040. p.AppendChild(new Run(doc, s));
  3041. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3042. ishcel0.AppendChild(p);
  3043. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3044. index++;
  3045. }
  3046. row++;
  3047. }
  3048. #endregion
  3049. Paragraph lastParagraph = new Paragraph(doc);
  3050. //第一个表格末尾加段落
  3051. table.ParentNode.InsertAfter(lastParagraph, table);
  3052. //复制第一个表格
  3053. Table cloneTable = (Table)table.Clone(true);
  3054. //在文档末尾段落后面加入复制的表格
  3055. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3056. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3057. {
  3058. int rownewsIndex = 13;
  3059. for (int i = 0; i < 2; i++)
  3060. {
  3061. var CopyRow = table.Rows[12].Clone(true);
  3062. table.Rows.RemoveAt(13);
  3063. table.Rows.Add(CopyRow);
  3064. rownewsIndex++;
  3065. }
  3066. }
  3067. else
  3068. {
  3069. table.Rows.RemoveAt(12);
  3070. }
  3071. cloneTable.Rows.RemoveAt(12);
  3072. }
  3073. if (_AirTicketReservations.Count != 0)
  3074. {
  3075. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3076. if (FlightsCode.Length != 0)
  3077. {
  3078. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3079. if (_AirCompany != null)
  3080. {
  3081. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3082. }
  3083. else
  3084. {
  3085. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3086. }
  3087. }
  3088. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3089. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3090. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3091. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3092. string name = "";
  3093. foreach (string clientName in nameArray)
  3094. {
  3095. if (!name.Contains(clientName))
  3096. {
  3097. name += clientName + ",";
  3098. }
  3099. }
  3100. if (!string.IsNullOrWhiteSpace(name))
  3101. {
  3102. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3103. }
  3104. else
  3105. {
  3106. table.Range.Bookmarks["ClientName"].Text = "--";
  3107. }
  3108. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3109. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3110. table.Range.Bookmarks["JointTicket"].Text = "--";
  3111. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3112. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3113. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3114. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3115. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3116. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3117. }
  3118. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3119. //保存合并后的文档
  3120. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3121. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3122. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3123. return Ok(JsonView(true, "成功!", rst));
  3124. }
  3125. else
  3126. {
  3127. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3128. DocumentBuilder builder = new DocumentBuilder(doc);
  3129. int tableIndex = 0;//表格索引
  3130. //得到文档中的第一个表格
  3131. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3132. List<string> texts = new List<string>();
  3133. foreach (var item in _AirTicketReservations)
  3134. {
  3135. string[] FlightsCode = item.FlightsCode.Split('/');
  3136. if (FlightsCode.Length != 0)
  3137. {
  3138. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3139. if (_AirCompany != null)
  3140. {
  3141. if (!transDic.ContainsKey(_AirCompany.CnName))
  3142. {
  3143. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3144. }
  3145. }
  3146. else
  3147. {
  3148. if (!transDic.ContainsKey("--"))
  3149. {
  3150. transDic.Add("--", "--");
  3151. }
  3152. }
  3153. }
  3154. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3155. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3156. string name = "";
  3157. foreach (string clientName in nameArray)
  3158. {
  3159. name += clientName + ",";
  3160. }
  3161. if (!texts.Contains(name))
  3162. {
  3163. texts.Add(name);
  3164. }
  3165. List<AirInfo> airs = new List<AirInfo>();
  3166. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3167. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3168. for (int i = 0; i < FlightsCode.Length; i++)
  3169. {
  3170. AirInfo air = new AirInfo();
  3171. string[] tempstr = DayArray[i]
  3172. .Replace("\r\n", string.Empty)
  3173. .Replace("\\r\\n", string.Empty)
  3174. .TrimStart().TrimEnd()
  3175. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3176. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3177. if (star_Three != null)
  3178. {
  3179. if (!transDic.ContainsKey(star_Three.AirPort))
  3180. {
  3181. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3182. }
  3183. }
  3184. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3185. if (End_Three != null)
  3186. {
  3187. if (!transDic.ContainsKey(End_Three.AirPort))
  3188. {
  3189. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3190. }
  3191. }
  3192. if (!texts.Contains(item.CTypeName))
  3193. {
  3194. texts.Add(item.CTypeName);
  3195. }
  3196. }
  3197. }
  3198. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3199. if (transData.Count > 0)
  3200. {
  3201. foreach (TranslateResult item in transData)
  3202. {
  3203. if (!transDic.ContainsKey(item.Query))
  3204. {
  3205. transDic.Add(item.Query, item.Translation);
  3206. }
  3207. }
  3208. }
  3209. foreach (var item in _AirTicketReservations)
  3210. {
  3211. #region 处理固定数据
  3212. string[] FlightsCode = item.FlightsCode.Split('/');
  3213. if (FlightsCode.Length != 0)
  3214. {
  3215. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3216. if (_AirCompany != null)
  3217. {
  3218. string str = "--";
  3219. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3220. if (!string.IsNullOrEmpty(translateResult))
  3221. {
  3222. str = translateResult;
  3223. str = _airTicketResRep.Processing(str);
  3224. }
  3225. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3226. }
  3227. else
  3228. {
  3229. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3230. }
  3231. }
  3232. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3233. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3234. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3235. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3236. string names = "";
  3237. foreach (string clientName in nameArray)
  3238. {
  3239. names += clientName + ",";
  3240. }
  3241. if (!string.IsNullOrWhiteSpace(names))
  3242. {
  3243. string str = "--";
  3244. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3245. if (!string.IsNullOrEmpty(translateResult))
  3246. {
  3247. str = translateResult;
  3248. str = _airTicketResRep.Processing(str);
  3249. }
  3250. table.Range.Bookmarks["ClientName"].Text = str;
  3251. }
  3252. else
  3253. {
  3254. table.Range.Bookmarks["ClientName"].Text = "--";
  3255. }
  3256. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3257. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3258. table.Range.Bookmarks["JointTicket"].Text = "--";
  3259. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3260. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3261. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3262. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3263. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3264. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3265. #endregion
  3266. #region 循环数据处理
  3267. List<AirInfo> airs = new List<AirInfo>();
  3268. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3269. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3270. for (int i = 0; i < FlightsCode.Length; i++)
  3271. {
  3272. AirInfo air = new AirInfo();
  3273. string[] tempstr = DayArray[i]
  3274. .Replace("\r\n", string.Empty)
  3275. .Replace("\\r\\n", string.Empty)
  3276. .TrimStart().TrimEnd()
  3277. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3278. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3279. string starCity = "";
  3280. if (star_Three != null)
  3281. {
  3282. string str2 = "--";
  3283. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3284. if (!string.IsNullOrEmpty(translateResult2))
  3285. {
  3286. str2 = translateResult2;
  3287. str2 = _airTicketResRep.Processing(str2);
  3288. }
  3289. starCity = str2;
  3290. }
  3291. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3292. string EndCity = "";
  3293. if (End_Three != null)
  3294. {
  3295. string str1 = "--";
  3296. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3297. if (!string.IsNullOrEmpty(translateResult1))
  3298. {
  3299. str1 = translateResult1;
  3300. str1 = _airTicketResRep.Processing(str1);
  3301. }
  3302. EndCity = str1;
  3303. }
  3304. air.Destination = starCity + "/" + EndCity;
  3305. air.Flight = FlightsCode[i];
  3306. string str = "--";
  3307. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3308. if (!string.IsNullOrEmpty(translateResult))
  3309. {
  3310. str = translateResult;
  3311. str = _airTicketResRep.Processing(str);
  3312. }
  3313. air.SeatingClass = str;
  3314. string dateTime = tempstr[2];
  3315. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3316. air.FlightDate = DateTemp;
  3317. air.DepartureTime = tempstr[5];
  3318. air.LandingTime = tempstr[6];
  3319. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3320. air.TicketStatus = "--";
  3321. air.Luggage = "--";
  3322. air.DepartureTerminal = "--";
  3323. air.LandingTerminal = "--";
  3324. airs.Add(air);
  3325. }
  3326. int row = 13;
  3327. for (int i = 0; i < airs.Count; i++)
  3328. {
  3329. if (airs.Count > 2)
  3330. {
  3331. for (int j = 0; j < airs.Count - 2; j++)
  3332. {
  3333. var CopyRow = table.Rows[12].Clone(true);
  3334. table.Rows.Add(CopyRow);
  3335. }
  3336. }
  3337. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3338. int index = 0;
  3339. foreach (PropertyInfo property in properties)
  3340. {
  3341. string value = property.GetValue(airs[i]).ToString();
  3342. Cell ishcel0 = table.Rows[row].Cells[index];
  3343. Paragraph p = new Paragraph(doc);
  3344. string s = value;
  3345. p.AppendChild(new Run(doc, s));
  3346. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3347. ishcel0.AppendChild(p);
  3348. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3349. //ishcel0.CellFormat.VerticalAlignment=
  3350. index++;
  3351. }
  3352. row++;
  3353. }
  3354. #endregion
  3355. Paragraph lastParagraph = new Paragraph(doc);
  3356. //第一个表格末尾加段落
  3357. table.ParentNode.InsertAfter(lastParagraph, table);
  3358. //复制第一个表格
  3359. Table cloneTable = (Table)table.Clone(true);
  3360. //在文档末尾段落后面加入复制的表格
  3361. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3362. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3363. {
  3364. int rownewsIndex = 13;
  3365. for (int i = 0; i < 2; i++)
  3366. {
  3367. var CopyRow = table.Rows[12].Clone(true);
  3368. table.Rows.RemoveAt(13);
  3369. table.Rows.Add(CopyRow);
  3370. rownewsIndex++;
  3371. }
  3372. }
  3373. else
  3374. {
  3375. table.Rows.RemoveAt(12);
  3376. }
  3377. cloneTable.Rows.RemoveAt(12);
  3378. }
  3379. if (_AirTicketReservations.Count != 0)
  3380. {
  3381. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3382. if (FlightsCode.Length != 0)
  3383. {
  3384. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3385. if (_AirCompany != null)
  3386. {
  3387. string str = "--";
  3388. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3389. if (!string.IsNullOrEmpty(translateResult))
  3390. {
  3391. str = translateResult;
  3392. str = _airTicketResRep.Processing(str);
  3393. }
  3394. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3395. }
  3396. else
  3397. {
  3398. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3399. }
  3400. }
  3401. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3402. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3403. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3404. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3405. string names = "";
  3406. foreach (string clientName in nameArray)
  3407. {
  3408. names += clientName + ",";
  3409. }
  3410. if (!string.IsNullOrWhiteSpace(names))
  3411. {
  3412. string str = "--";
  3413. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3414. if (!string.IsNullOrEmpty(translateResult))
  3415. {
  3416. str = translateResult;
  3417. str = _airTicketResRep.Processing(str);
  3418. }
  3419. table.Range.Bookmarks["ClientName"].Text = str;
  3420. }
  3421. else
  3422. {
  3423. table.Range.Bookmarks["ClientName"].Text = "--";
  3424. }
  3425. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3426. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3427. table.Range.Bookmarks["JointTicket"].Text = "--";
  3428. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3429. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3430. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3431. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3432. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3433. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3434. }
  3435. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3436. //保存合并后的文档
  3437. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3438. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3439. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3440. return Ok(JsonView(true, "成功!", rst));
  3441. }
  3442. }
  3443. }
  3444. catch (Exception ex)
  3445. {
  3446. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3447. throw;
  3448. }
  3449. }
  3450. #endregion
  3451. #region 团组增减款项 --> 其他款项
  3452. /// <summary>
  3453. /// 团组增减款项下拉框绑定
  3454. /// </summary>
  3455. /// <param name="dto"></param>
  3456. /// <returns></returns>
  3457. [HttpPost]
  3458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3459. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3460. {
  3461. #region 参数验证
  3462. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3463. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3464. #endregion
  3465. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3466. }
  3467. /// <summary>
  3468. /// 根据团组Id查询团组增减款项
  3469. /// </summary>
  3470. /// <param name="dto"></param>
  3471. /// <returns></returns>
  3472. [HttpPost]
  3473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3474. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3475. {
  3476. #region 参数验证
  3477. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3478. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3479. #endregion
  3480. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3481. }
  3482. /// <summary>
  3483. /// 团组增减款项操作(Status:1.新增,2.修改)
  3484. /// </summary>
  3485. /// <param name="dto"></param>
  3486. /// <returns></returns>
  3487. [HttpPost]
  3488. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3489. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3490. {
  3491. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3492. if (groupData.Code != 200)
  3493. {
  3494. return Ok(JsonView(false, groupData.Msg));
  3495. }
  3496. #region 应用推送
  3497. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3498. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3499. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3500. //自动审核
  3501. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3502. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3503. //2024-10-21 新增LZ UID
  3504. var userIds = new List<int>() { 21 };
  3505. string title = $"系统通知";
  3506. string content = "";
  3507. var diId = dto.DiId;
  3508. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3509. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3510. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3511. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3512. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3513. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3514. #endregion
  3515. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3516. }
  3517. /// <summary>
  3518. /// 团组增减款项操作 删除
  3519. /// </summary>
  3520. /// <param name="dto"></param>
  3521. /// <returns></returns>
  3522. [HttpPost]
  3523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3524. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3525. {
  3526. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3527. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3528. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3529. if (res.Code == 0)
  3530. {
  3531. return Ok(JsonView(true, "删除成功!"));
  3532. }
  3533. return Ok(JsonView(false, "删除失败!"));
  3534. }
  3535. /// <summary>
  3536. /// 根据团组增减款项Id查询
  3537. /// </summary>
  3538. /// <param name="dto"></param>
  3539. /// <returns></returns>
  3540. [HttpPost]
  3541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3542. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3543. {
  3544. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3545. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3546. }
  3547. /// <summary>
  3548. /// 查询供应商名称
  3549. /// </summary>
  3550. /// <param name="dto"></param>
  3551. /// <returns></returns>
  3552. [HttpPost]
  3553. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3554. {
  3555. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3556. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3557. ?? new List<Grp_DecreasePayments>();
  3558. dbResult = dbResult.Distinct(new
  3559. ProductComparer()).ToList();
  3560. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3561. {
  3562. x.Id,
  3563. x.SupplierAddress,
  3564. x.SupplierArea,
  3565. x.SupplierContact,
  3566. x.SupplierContactNumber,
  3567. x.SupplierEmail,
  3568. x.SupplierName,
  3569. x.SupplierSocialAccount,
  3570. x.SupplierTypeId,
  3571. }).ToList());
  3572. return Ok(jw);
  3573. }
  3574. /// <summary>
  3575. /// 团组增减款项 OTA匹配
  3576. /// </summary>
  3577. /// <param name="file"></param>
  3578. /// <returns></returns>
  3579. [HttpPost]
  3580. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3581. {
  3582. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3583. string fileName = file.FileName;
  3584. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3585. {
  3586. return Ok(JsonView(false, "请上传Excel文件!"));
  3587. }
  3588. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3589. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3590. if (!Directory.Exists(path))
  3591. {
  3592. Directory.CreateDirectory(path);
  3593. }
  3594. var filePath = @$"{path}/{fileName}";
  3595. //保存文件
  3596. using (FileStream fs = System.IO.File.Create(filePath))
  3597. {
  3598. file.CopyTo(fs);
  3599. fs.Flush();
  3600. }
  3601. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3602. //读取ExcelFile
  3603. DataTable dt = ConvertExcelToDataTable(filePath);
  3604. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3605. dt.TableName = "TB";
  3606. //修改table列名
  3607. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3608. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3609. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3610. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3611. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3612. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3613. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3614. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3615. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3616. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3617. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3618. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3619. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3620. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3621. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3622. var otaOrderNos = new List<string>();
  3623. foreach (DataRow item in dt.Rows)
  3624. {
  3625. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3626. }
  3627. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3628. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3629. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3630. .Select((dp, di) => new
  3631. {
  3632. dp.PriceName,
  3633. dp.OTAOrderNo,
  3634. dp.FeeTotal,
  3635. di.TeamName,
  3636. })
  3637. .ToListAsync();
  3638. foreach (DataRow item in dt.Rows)
  3639. {
  3640. var otaOrderNo = item["OTAOrderNo"].ToString();
  3641. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3642. if (oaData == null) continue;
  3643. item["GroupName"] = oaData.TeamName;
  3644. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3645. }
  3646. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3647. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3648. List<DataTable> datas = new List<DataTable>();
  3649. datas.Add(dt);
  3650. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3651. return Ok(JsonView(true, "操作成功", new { url = url }));
  3652. }
  3653. #region
  3654. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3655. {
  3656. // 创建Workbook对象
  3657. Workbook workbook = new Workbook(excelFilePath);
  3658. // 获取第一个工作表
  3659. Worksheet worksheet = workbook.Worksheets[0];
  3660. // 将工作表转换为DataTable
  3661. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3662. return dataTable;
  3663. }
  3664. #endregion
  3665. #endregion
  3666. #region 文件上传、删除
  3667. /// <summary>
  3668. /// region 文件上传 可以带参数
  3669. /// </summary>
  3670. /// <param name="file"></param>
  3671. /// <returns></returns>
  3672. [HttpPost]
  3673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3674. public async Task<IActionResult> UploadProject(IFormFile file)
  3675. {
  3676. //var TypeName = Request.Headers["TypeName"].ToString();
  3677. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3678. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3679. ////文件名称
  3680. //string projectFileName = file.FileName;
  3681. ////上传的文件的路径
  3682. //string filePath = $"{fileDir}/{projectFileName}";
  3683. //if (TypeName == "A")//A代表团组增减款项
  3684. //{
  3685. // filePath = fileDir + $@"\团组增减款项相关文件";
  3686. // if (!Directory.Exists(filePath))
  3687. // {
  3688. // Directory.CreateDirectory(filePath);
  3689. // }
  3690. // //上传的文件的路径
  3691. // filePath += $@"\{projectFileName}";
  3692. //}
  3693. //else if (TypeName == "B")//B代表商邀相关文件
  3694. //{
  3695. // //上传的文件的路径
  3696. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3697. // if (!Directory.Exists(filePath))
  3698. // {
  3699. // Directory.CreateDirectory(filePath);
  3700. // }
  3701. // //上传的文件的路径
  3702. // filePath = $@"\{projectFileName}";
  3703. //}
  3704. //try
  3705. //{
  3706. // using (FileStream fs = System.IO.File.Create(filePath))
  3707. // {
  3708. // file.CopyTo(fs);
  3709. // fs.Flush();
  3710. // }
  3711. //}
  3712. //catch (Exception ex)
  3713. //{
  3714. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3715. //}
  3716. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3717. try
  3718. {
  3719. var TypeName = Request.Headers["TypeName"].ToString();
  3720. if (file != null)
  3721. {
  3722. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3723. //文件名称
  3724. string projectFileName = file.FileName;
  3725. //上传的文件的路径
  3726. string filePath = $"{fileDir}/{projectFileName}";
  3727. if (TypeName == "A")//A代表团组增减款项
  3728. {
  3729. if (!Directory.Exists(fileDir))
  3730. {
  3731. Directory.CreateDirectory(fileDir);
  3732. }
  3733. //上传的文件的路径
  3734. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3735. }
  3736. else if (TypeName == "B")//B代表商邀相关文件
  3737. {
  3738. if (!Directory.Exists(fileDir))
  3739. {
  3740. Directory.CreateDirectory(fileDir);
  3741. }
  3742. //上传的文件的路径
  3743. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3744. }
  3745. using (FileStream fs = System.IO.File.Create(filePath))
  3746. {
  3747. file.CopyTo(fs);
  3748. fs.Flush();
  3749. }
  3750. return Ok(JsonView(true, "上传成功!", projectFileName));
  3751. }
  3752. else
  3753. {
  3754. return Ok(JsonView(false, "上传失败!"));
  3755. }
  3756. }
  3757. catch (Exception ex)
  3758. {
  3759. return Ok(JsonView(false, "程序错误!"));
  3760. }
  3761. }
  3762. /// <summary>
  3763. /// 删除指定文件
  3764. /// </summary>
  3765. /// <param name="dto"></param>
  3766. /// <returns></returns>
  3767. [HttpPost]
  3768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3769. public async Task<IActionResult> DelFile(DelFileDto dto)
  3770. {
  3771. try
  3772. {
  3773. var TypeName = Request.Headers["TypeName"].ToString();
  3774. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3775. string filePath = "";
  3776. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3777. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3778. int id = 0;
  3779. if (TypeName == "A")
  3780. {
  3781. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3782. // 删除该文件
  3783. System.IO.File.Delete(filePath);
  3784. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3785. .Where(a => a.Id == dto.Id)
  3786. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3787. .ExecuteCommandAsync();
  3788. }
  3789. else if (TypeName == "B")
  3790. {
  3791. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3792. // 删除该文件
  3793. System.IO.File.Delete(filePath);
  3794. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3795. if (info != null)
  3796. {
  3797. string[] files = new string[] { };
  3798. if (!string.IsNullOrEmpty(info.Attachment))
  3799. {
  3800. try
  3801. {
  3802. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3803. }
  3804. catch (Exception)
  3805. {
  3806. files = new List<string>() { info.Attachment }.ToArray();
  3807. }
  3808. }
  3809. if (files.Length > 0)
  3810. {
  3811. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3812. string filePath2 = string.Empty;
  3813. if (files1.Length > 0)
  3814. {
  3815. filePath2 = JsonConvert.SerializeObject(files1);
  3816. }
  3817. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3818. .Where(a => a.Id == dto.Id)
  3819. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3820. .ExecuteCommandAsync();
  3821. }
  3822. }
  3823. }
  3824. if (id != 0)
  3825. {
  3826. return Ok(JsonView(true, "成功!"));
  3827. }
  3828. else
  3829. {
  3830. return Ok(JsonView(false, "失败!"));
  3831. }
  3832. }
  3833. catch (Exception ex)
  3834. {
  3835. return Ok(JsonView(false, "程序错误!"));
  3836. throw;
  3837. }
  3838. }
  3839. /// <summary>
  3840. /// 文件上传多个文件 可以带参数
  3841. /// </summary>
  3842. /// <param name="file"></param>
  3843. /// <returns></returns>
  3844. [HttpPost]
  3845. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3846. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3847. {
  3848. try
  3849. {
  3850. var TypeName = Request.Headers["TypeName"].ToString();
  3851. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3852. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3853. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3854. var filePahts = new List<string>();
  3855. foreach (var file in files)
  3856. {
  3857. //文件名称
  3858. string projectFileName = file.FileName;
  3859. //上传的文件的路径
  3860. string filePath = $"{fileDir}/{projectFileName}";
  3861. if (TypeName == "A")//A代表团组增减款项
  3862. {
  3863. if (!Directory.Exists(fileDir))
  3864. {
  3865. Directory.CreateDirectory(fileDir);
  3866. }
  3867. //上传的文件的路径
  3868. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3869. }
  3870. else if (TypeName == "B")//B代表商邀相关文件
  3871. {
  3872. if (!Directory.Exists(fileDir))
  3873. {
  3874. Directory.CreateDirectory(fileDir);
  3875. }
  3876. //上传的文件的路径
  3877. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3878. }
  3879. using (FileStream fs = System.IO.File.Create(filePath))
  3880. {
  3881. file.CopyTo(fs);
  3882. fs.Flush();
  3883. }
  3884. filePahts.Add(projectFileName);
  3885. }
  3886. return Ok(JsonView(true, "上传成功!", filePahts));
  3887. }
  3888. catch (Exception ex)
  3889. {
  3890. return Ok(JsonView(false, "程序错误!"));
  3891. }
  3892. }
  3893. #endregion
  3894. #region 商邀费用录入
  3895. /// <summary>
  3896. /// 根据团组Id查询商邀费用列表
  3897. /// </summary>
  3898. /// <param name="dto"></param>
  3899. /// <returns></returns>
  3900. [HttpPost]
  3901. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3902. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3903. {
  3904. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3905. if (groupData.Code != 0)
  3906. {
  3907. return Ok(JsonView(false, groupData.Msg));
  3908. }
  3909. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3910. }
  3911. /// <summary>
  3912. /// 商邀费用列表
  3913. /// 下载文件
  3914. /// </summary>
  3915. /// <param name="dto"></param>
  3916. /// <returns></returns>
  3917. [HttpGet("{id}")]
  3918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3919. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3920. {
  3921. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3922. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3923. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3924. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3925. var filePaths = new List<string>();
  3926. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3927. try
  3928. {
  3929. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3930. }
  3931. catch (Exception ex)
  3932. {
  3933. filePaths.Add(info.Attachment);
  3934. }
  3935. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3936. for (int i = 0; i < filePaths.Count; i++)
  3937. {
  3938. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3939. }
  3940. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3941. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3942. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3943. {
  3944. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3945. {
  3946. foreach (string filePath in filePaths)
  3947. {
  3948. if (System.IO.File.Exists(filePath))
  3949. {
  3950. // 获取文件名
  3951. string fileName = Path.GetFileName(filePath);
  3952. // 将文件添加到ZIP归档中
  3953. zipArchive.CreateEntryFromFile(filePath, fileName);
  3954. }
  3955. }
  3956. }
  3957. }
  3958. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3959. }
  3960. /// <summary>
  3961. /// 商邀费用 Info Page 基础数据源
  3962. /// </summary>
  3963. /// <param name="dto"></param>
  3964. /// <returns></returns>
  3965. [HttpPost]
  3966. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3967. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3968. {
  3969. try
  3970. {
  3971. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3972. if (groupData.Code != 0)
  3973. {
  3974. return Ok(JsonView(false, groupData.Msg));
  3975. }
  3976. return Ok(JsonView(true, "操作成功", groupData.Data));
  3977. }
  3978. catch (Exception ex)
  3979. {
  3980. return Ok(JsonView(false, ex.Message));
  3981. throw;
  3982. }
  3983. }
  3984. /// <summary>
  3985. /// 根据商邀费用ID查询C表和商邀费用数据
  3986. /// </summary>
  3987. /// <param name="dto"></param>
  3988. /// <returns></returns>
  3989. [HttpPost]
  3990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3991. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3992. {
  3993. try
  3994. {
  3995. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3996. if (groupData.Code != 0)
  3997. {
  3998. return Ok(JsonView(false, groupData.Msg));
  3999. }
  4000. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4001. }
  4002. catch (Exception ex)
  4003. {
  4004. return Ok(JsonView(false, ex.Message));
  4005. throw;
  4006. }
  4007. }
  4008. /// <summary>
  4009. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4010. /// </summary>
  4011. /// <param name="dto"></param>
  4012. /// <returns></returns>
  4013. [HttpPost]
  4014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4015. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4016. {
  4017. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4018. if (groupData.Code != 0)
  4019. {
  4020. return Ok(JsonView(false, groupData.Msg));
  4021. }
  4022. #region 应用推送
  4023. try
  4024. {
  4025. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4026. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4027. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4028. //2024-10-21 新增LZ UID
  4029. var userIds = new List<int>() { 21 };
  4030. string title = $"系统通知";
  4031. string content = "";
  4032. var diId = dto.DiId;
  4033. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4034. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4035. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4036. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4037. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4038. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4039. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4040. }
  4041. catch (Exception ex)
  4042. {
  4043. }
  4044. #endregion
  4045. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4046. }
  4047. /// <summary>
  4048. /// 商邀删除
  4049. /// </summary>
  4050. /// <param name="dto"></param>
  4051. /// <returns></returns>
  4052. [HttpPost]
  4053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4054. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4055. {
  4056. try
  4057. {
  4058. _sqlSugar.BeginTran();
  4059. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4060. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4061. {
  4062. IsDel = 1,
  4063. DeleteUserId = dto.DeleteUserId,
  4064. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4065. })
  4066. .Where(it => it.Id == dto.Id)
  4067. .ExecuteCommand();
  4068. if (res1 > 0)
  4069. {
  4070. int _diId = 0;
  4071. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4072. if (_ioaInfo != null)
  4073. {
  4074. _diId = _ioaInfo.DiId;
  4075. }
  4076. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4077. .SetColumns(a => new Grp_CreditCardPayment()
  4078. {
  4079. IsDel = 1,
  4080. DeleteUserId = dto.DeleteUserId,
  4081. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4082. })
  4083. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4084. .ExecuteCommand();
  4085. if (res2 > 0)
  4086. {
  4087. _sqlSugar.CommitTran();
  4088. return Ok(JsonView(true, "删除成功!"));
  4089. }
  4090. }
  4091. _sqlSugar.RollbackTran();
  4092. return Ok(JsonView(false, "删除失败"));
  4093. }
  4094. catch (Exception ex)
  4095. {
  4096. _sqlSugar.RollbackTran();
  4097. return Ok(JsonView(false, ex.Message));
  4098. }
  4099. }
  4100. /// <summary>
  4101. /// 团组模块文件上传
  4102. /// </summary>
  4103. /// <param name="dto"></param>
  4104. /// <returns></returns>
  4105. [HttpPost]
  4106. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4107. {
  4108. var jw = JsonView(false);
  4109. long M = 1024 * 1024;
  4110. if (dto.Files == null || dto.Files.Count == 0)
  4111. {
  4112. jw.Msg = "无文件信息!";
  4113. return Ok(jw);
  4114. }
  4115. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4116. {
  4117. jw.Msg = "文件大小超过20M!";
  4118. return Ok(jw);
  4119. }
  4120. //var nameSp = dto.File.FileName.Split(".");
  4121. //if (nameSp.Length < 2)
  4122. //{
  4123. // jw.Msg = "拓展名称有误!";
  4124. // return Ok(jw);
  4125. //}
  4126. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4127. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4128. //{
  4129. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4130. // return Ok(jw);
  4131. //}
  4132. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4133. if (Ctable == null)
  4134. {
  4135. jw.Msg = "Ctable指向有误!";
  4136. return Ok(jw);
  4137. }
  4138. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4139. if (groupInfo == null)
  4140. {
  4141. jw.Msg = "团组信息不存在!";
  4142. return Ok(jw);
  4143. }
  4144. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4145. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4146. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4147. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4148. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4149. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4150. try
  4151. {
  4152. if (!Directory.Exists(fileBase))
  4153. {
  4154. Directory.CreateDirectory(fileBase);
  4155. }
  4156. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4157. foreach (var fileStream in dto.Files)
  4158. {
  4159. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4160. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4161. {
  4162. Cid = dto.Cid,
  4163. CreateTime = DateTime.Now,
  4164. CreateUserId = dto.Userid,
  4165. Ctable = dto.Ctable,
  4166. Diid = dto.Diid,
  4167. IsDel = 0,
  4168. FilePath = saveFilePath,
  4169. FileName = fileStream.FileName
  4170. };
  4171. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4172. {
  4173. fileStream.CopyTo(fs);
  4174. fs.Flush();
  4175. }
  4176. saveArr.Add(file);
  4177. }
  4178. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4179. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4180. jw = JsonView(true, "保存成功!", new
  4181. {
  4182. count = addResult,
  4183. filesName = saveArr.Select(x => x.FileName)
  4184. });
  4185. }
  4186. catch (Exception ex)
  4187. {
  4188. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4189. {
  4190. count = 0,
  4191. filesName = new string[0],
  4192. });
  4193. }
  4194. return Ok(jw);
  4195. }
  4196. /// <summary>
  4197. /// 查询各模块已保存文件
  4198. /// </summary>
  4199. /// <param name="dto"></param>
  4200. /// <returns></returns>
  4201. [HttpPost]
  4202. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4203. {
  4204. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4205. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4206. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4207. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4208. {
  4209. expression = Expressionable.Create<Grp_GroupModelFile>()
  4210. .And(x => visaIds.Contains(x.CreateUserId));
  4211. }
  4212. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4213. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4214. .Where(expression.ToExpression())
  4215. .ToList();
  4216. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4217. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4218. {
  4219. x.FileName,
  4220. x.Id,
  4221. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4222. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4223. })));
  4224. }
  4225. /// <summary>
  4226. /// 下载该团组下的所有文件
  4227. /// </summary>
  4228. /// <param name="dto"></param>
  4229. /// <returns></returns>
  4230. [HttpPost]
  4231. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4232. {
  4233. var jw = JsonView(false);
  4234. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4235. if (groupInfo == null)
  4236. {
  4237. jw.Msg = "团组信息不存在!";
  4238. return Ok(jw);
  4239. }
  4240. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4241. var isModule = Convert.ToBoolean(dto.isModule);
  4242. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4243. IOOperatorHelper io = new IOOperatorHelper();
  4244. if (isModule)
  4245. {
  4246. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4247. foreach (var moduleArr in moduleGroup)
  4248. {
  4249. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4250. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4251. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4252. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4253. foreach (var item in moduleArr)
  4254. {
  4255. if (System.IO.File.Exists(item.FilePath))
  4256. {
  4257. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4258. {
  4259. byte[] bytes = new byte[fileStream.Length];
  4260. fileStream.Read(bytes, 0, bytes.Length);
  4261. fileStream.Close();
  4262. Stream stream = new MemoryStream(bytes);
  4263. chiZips.Add(item.FileName, stream);
  4264. }
  4265. }
  4266. }
  4267. if (chiZips.Count > 0)
  4268. {
  4269. var byts = io.ConvertZipStream(chiZips);
  4270. Stream stream = new MemoryStream(byts);
  4271. Zips.Add(key.Name + "_.zip", stream);
  4272. }
  4273. }
  4274. }
  4275. else
  4276. {
  4277. foreach (var item in dbQuery)
  4278. {
  4279. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4280. {
  4281. byte[] bytes = new byte[fileStream.Length];
  4282. fileStream.Read(bytes, 0, bytes.Length);
  4283. fileStream.Close();
  4284. Stream stream = new MemoryStream(bytes);
  4285. while (Zips.Keys.Contains(item.FileName))
  4286. {
  4287. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4288. }
  4289. Zips.Add(item.FileName, stream);
  4290. }
  4291. }
  4292. }
  4293. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4294. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4295. if (Zips.Count > 0)
  4296. {
  4297. var byts = io.ConvertZipStream(Zips);
  4298. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4299. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4300. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4301. }
  4302. else
  4303. {
  4304. jw.Msg = "暂无生成文件!";
  4305. }
  4306. return Ok(jw);
  4307. }
  4308. /// <summary>
  4309. /// 下载该团组下此模块的所有文件
  4310. /// </summary>
  4311. /// <param name="dto"></param>
  4312. /// <returns></returns>
  4313. [HttpPost]
  4314. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4315. {
  4316. var jw = JsonView(false);
  4317. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4318. if (groupInfo == null)
  4319. {
  4320. jw.Msg = "团组信息不存在!";
  4321. return Ok(jw);
  4322. }
  4323. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4324. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4325. && x.IsDel == 0);
  4326. if (key == null)
  4327. {
  4328. jw.Msg = "Ctable指向错误!";
  4329. return Ok(jw);
  4330. }
  4331. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4332. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4333. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4334. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4335. IOOperatorHelper io = new IOOperatorHelper();
  4336. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4337. foreach (var item in dbQuery)
  4338. {
  4339. if (System.IO.File.Exists(item.FilePath))
  4340. {
  4341. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4342. {
  4343. byte[] bytes = new byte[fileStream.Length];
  4344. fileStream.Read(bytes, 0, bytes.Length);
  4345. fileStream.Close();
  4346. Stream stream = new MemoryStream(bytes);
  4347. while (Zips.Keys.Contains(item.FileName))
  4348. {
  4349. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4350. }
  4351. Zips.Add(item.FileName, stream);
  4352. }
  4353. }
  4354. }
  4355. if (Zips.Count > 0)
  4356. {
  4357. var byts = io.ConvertZipStream(Zips);
  4358. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4359. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4360. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4361. }
  4362. else
  4363. {
  4364. jw.Msg = "暂无生成文件!";
  4365. }
  4366. return Ok(jw);
  4367. }
  4368. /// <summary>
  4369. /// 删除该团组下的指定文件
  4370. /// </summary>
  4371. /// <param name="dto"></param>
  4372. /// <returns></returns>
  4373. [HttpPost]
  4374. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4375. {
  4376. var jw = JsonView(false);
  4377. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4378. if (sing == null)
  4379. {
  4380. jw.Msg = "暂无";
  4381. return Ok(jw);
  4382. }
  4383. if (System.IO.File.Exists(sing.FilePath))
  4384. {
  4385. try
  4386. {
  4387. System.IO.File.Delete(sing.FilePath);
  4388. }
  4389. catch (Exception ex)
  4390. {
  4391. jw.Msg = "删除失败!" + ex.Message;
  4392. return Ok(jw);
  4393. }
  4394. }
  4395. sing.IsDel = 1;
  4396. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4397. sing.DeleteUserId = dto.UserId;
  4398. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4399. jw = JsonView(true, "删除成功!");
  4400. return Ok(jw);
  4401. }
  4402. #endregion
  4403. #region 团组英文资料
  4404. /// <summary>
  4405. /// 查询团组英文所有资料
  4406. /// </summary>
  4407. /// <param name="dto"></param>
  4408. /// <returns></returns>
  4409. [HttpPost]
  4410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4411. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4412. {
  4413. try
  4414. {
  4415. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4416. if (groupData.Code != 0)
  4417. {
  4418. return Ok(JsonView(false, groupData.Msg));
  4419. }
  4420. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4421. }
  4422. catch (Exception ex)
  4423. {
  4424. return Ok(JsonView(false, "程序错误!"));
  4425. throw;
  4426. }
  4427. }
  4428. /// <summary>
  4429. /// 团组英文资料操作(Status:1.新增,2.修改)
  4430. /// </summary>
  4431. /// <param name="dto"></param>
  4432. /// <returns></returns>
  4433. [HttpPost]
  4434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4435. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4436. {
  4437. try
  4438. {
  4439. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4440. if (groupData.Code != 0)
  4441. {
  4442. return Ok(JsonView(false, groupData.Msg));
  4443. }
  4444. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4445. }
  4446. catch (Exception ex)
  4447. {
  4448. return Ok(JsonView(false, "程序错误!"));
  4449. throw;
  4450. }
  4451. }
  4452. /// <summary>
  4453. /// 团组英文资料Id查询数据
  4454. /// </summary>
  4455. /// <param name="dto"></param>
  4456. /// <returns></returns>
  4457. [HttpPost]
  4458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4459. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4460. {
  4461. try
  4462. {
  4463. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4464. if (_DelegationEnData != null)
  4465. {
  4466. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4467. }
  4468. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4469. }
  4470. catch (Exception ex)
  4471. {
  4472. return Ok(JsonView(false, "程序错误!"));
  4473. throw;
  4474. }
  4475. }
  4476. /// <summary>
  4477. /// 团组英文资料删除
  4478. /// </summary>
  4479. /// <param name="dto"></param>
  4480. /// <returns></returns>
  4481. [HttpPost]
  4482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4483. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4484. {
  4485. try
  4486. {
  4487. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4488. if (!res)
  4489. {
  4490. return Ok(JsonView(false, "删除失败"));
  4491. }
  4492. return Ok(JsonView(true, "删除成功!"));
  4493. }
  4494. catch (Exception ex)
  4495. {
  4496. return Ok(JsonView(false, "程序错误!"));
  4497. throw;
  4498. }
  4499. }
  4500. #endregion
  4501. #region 导出邀请函
  4502. /// <summary>
  4503. /// 导出邀请函页面初始化
  4504. /// </summary>
  4505. /// <param name="dto"></param>
  4506. /// <returns></returns>
  4507. [HttpPost]
  4508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4509. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4510. {
  4511. try
  4512. {
  4513. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4514. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4515. if (dto.DiId == 0)
  4516. {
  4517. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4518. }
  4519. else
  4520. {
  4521. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4522. }
  4523. return Ok(JsonView(true, "查询成功!", new
  4524. {
  4525. deleClient = crm_Deles,
  4526. delegations = grp_Delegations
  4527. }));
  4528. }
  4529. catch (Exception ex)
  4530. {
  4531. return Ok(JsonView(false, "程序错误!"));
  4532. throw;
  4533. }
  4534. }
  4535. /// <summary>
  4536. /// 导出邀请函
  4537. /// </summary>
  4538. /// <param name="dto"></param>
  4539. /// <returns></returns>
  4540. [HttpPost]
  4541. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4542. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4543. {
  4544. #region 参数验证
  4545. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4546. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4547. #endregion
  4548. try
  4549. {
  4550. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4551. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4552. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4553. From Grp_TourClientList tcl
  4554. Left Join
  4555. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4556. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4557. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4558. From Crm_DeleClient dc
  4559. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4560. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4561. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4562. Where dc.IsDel = 0) temp
  4563. On temp.DcId =tcl.ClientId
  4564. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4565. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4566. List<string> texts = new List<string>();
  4567. if (datas.Count != 0)
  4568. {
  4569. foreach (TourClientListDetailsView item in datas)
  4570. {
  4571. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4572. {
  4573. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4574. }
  4575. else
  4576. {
  4577. string name = item.LastName + item.FirstName;
  4578. texts.Add(name);
  4579. }
  4580. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4581. {
  4582. if (!transDic.ContainsKey(item.Job))
  4583. {
  4584. texts.Add(item.Job);
  4585. }
  4586. }
  4587. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4588. {
  4589. texts.Add(item.CompanyFullName);
  4590. }
  4591. }
  4592. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4593. if (transData.Count > 0)
  4594. {
  4595. foreach (TranslateResult item in transData)
  4596. {
  4597. if (!transDic.ContainsKey(item.Query))
  4598. {
  4599. transDic.Add(item.Query, item.Translation);
  4600. }
  4601. }
  4602. }
  4603. List<GuestList> list = new List<GuestList>();
  4604. foreach (TourClientListDetailsView dele in datas)
  4605. {
  4606. GuestList guestList = new GuestList();
  4607. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4608. {
  4609. guestList.Name = dele.Pinyin;
  4610. }
  4611. else
  4612. {
  4613. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4614. guestList.Name = Name;
  4615. }
  4616. if (dele.Sex == 0)
  4617. {
  4618. guestList.Sex = "Male";
  4619. }
  4620. else if (dele.Sex == 1)
  4621. {
  4622. guestList.Sex = "Female";
  4623. }
  4624. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4625. if (!string.IsNullOrEmpty(dele.Job))
  4626. {
  4627. guestList.Job = dele.Job;
  4628. }
  4629. list.Add(guestList);
  4630. }
  4631. //载入模板
  4632. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4633. DocumentBuilder builder = new DocumentBuilder(doc);
  4634. //获取word里所有表格
  4635. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4636. //获取所填表格的序数
  4637. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4638. var rowStart = tableOne.Rows[0]; //获取第1行
  4639. //循环赋值
  4640. for (int i = 0; i < list.Count; i++)
  4641. {
  4642. builder.MoveToCell(0, i + 1, 0, 0);
  4643. builder.Write(list[i].Name.ToString());
  4644. builder.MoveToCell(0, i + 1, 1, 0);
  4645. builder.Write(list[i].Sex.ToString());
  4646. builder.MoveToCell(0, i + 1, 2, 0);
  4647. builder.Write(list[i].DOB.ToString());
  4648. builder.MoveToCell(0, i + 1, 3, 0);
  4649. builder.Write(list[i].Job.ToString());
  4650. }
  4651. //删除多余行
  4652. while (tableOne.Rows.Count > list.Count + 1)
  4653. {
  4654. tableOne.Rows.RemoveAt(list.Count + 1);
  4655. }
  4656. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4657. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4658. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4659. doc.Save(filePath);
  4660. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4661. return Ok(JsonView(true, "操作成功!", Url));
  4662. }
  4663. else
  4664. {
  4665. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4666. }
  4667. }
  4668. catch (Exception ex)
  4669. {
  4670. return Ok(JsonView(false, ex.Message));
  4671. throw;
  4672. }
  4673. }
  4674. #endregion
  4675. #region 团组经理模块 出入境费用
  4676. /// <summary>
  4677. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4678. /// </summary>
  4679. /// <returns></returns>
  4680. [HttpPost]
  4681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4682. public async Task<IActionResult> SetDayAndCostAreaChange()
  4683. {
  4684. try
  4685. {
  4686. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4687. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4688. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4689. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4690. foreach (var item in unite) //处理交集数据
  4691. {
  4692. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4693. }
  4694. foreach (var item in merge) //处理差集数据
  4695. {
  4696. int nationalTravelFeeId = 0;
  4697. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4698. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4699. else
  4700. {
  4701. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4702. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4703. }
  4704. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4705. }
  4706. //只更新dayAndCost 的 nationalTravelFeeId;
  4707. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4708. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4709. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4710. }
  4711. catch (Exception ex)
  4712. {
  4713. return Ok(JsonView(false, ex.Message));
  4714. throw;
  4715. }
  4716. }
  4717. /// <summary>
  4718. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4719. /// </summary>
  4720. /// <returns></returns>
  4721. [HttpPost]
  4722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4723. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4724. {
  4725. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4726. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4727. //SetDataInfoView
  4728. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4729. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4730. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4731. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4732. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4733. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4734. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4735. //默认币种显示
  4736. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4737. {
  4738. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4739. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4740. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4741. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4742. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4743. };
  4744. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4745. if (_currencyRate.Count > 0)
  4746. {
  4747. foreach (var item in _currencyInfos)
  4748. {
  4749. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4750. if (rateInfo != null)
  4751. {
  4752. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4753. rate1 *= 1.035M;
  4754. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4755. }
  4756. }
  4757. }
  4758. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4759. return Ok(JsonView(true, "查询成功!", new
  4760. {
  4761. GroupNameData = groupNameData.Data,
  4762. CurrencyData = _CurrencyData,
  4763. WordTypeData = _WordTypeData,
  4764. ExcelTypeData = _ExcelTypeData,
  4765. CurrencyInit = _currencyInfos,
  4766. ViewPermissionData = viewPermissionData
  4767. }));
  4768. }
  4769. /// <summary>
  4770. /// 团组模块 - 出入境费用
  4771. /// 实时汇率 tips
  4772. /// 签证费用 tips
  4773. /// 机票费用 tips
  4774. /// </summary>
  4775. /// <returns></returns>
  4776. [HttpPost]
  4777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4778. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4779. {
  4780. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4781. //默认币种显示
  4782. var _currencyInfos = _currencyInit;
  4783. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4784. List<dynamic> reteInfos = new List<dynamic>();
  4785. if (_currencyRate.Count > 0)
  4786. {
  4787. foreach (var item in _currencyInfos)
  4788. {
  4789. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4790. if (rateInfo != null)
  4791. {
  4792. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4793. decimal rate1 = item.Rate;
  4794. rate1 *= 1.03M;
  4795. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4796. reteInfos.Add(new
  4797. {
  4798. currCode = item.CurrencyCode,
  4799. currName = item.CurrencyName,
  4800. rate = rate2,
  4801. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4802. });
  4803. }
  4804. }
  4805. }
  4806. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4807. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4808. return Ok(JsonView(true, "查询成功!", new
  4809. {
  4810. //GroupNameData = groupNameData.Data,
  4811. visaData = visaData.Data,
  4812. airData = airData.Data,
  4813. reteInfos = reteInfos
  4814. }));
  4815. }
  4816. /// <summary>
  4817. /// 团组模块 - 出入境费用 - Info
  4818. /// </summary>
  4819. /// <returns></returns>
  4820. [HttpPost]
  4821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4822. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4823. {
  4824. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4825. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4826. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4827. }
  4828. /// <summary>
  4829. /// 团组模块 - 出入境费用 - 设置view权限
  4830. /// </summary>
  4831. /// <returns></returns>
  4832. [HttpPost]
  4833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4834. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4835. {
  4836. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4837. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4838. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4839. var permissions = new List<Grp_EnterExitCostPermission>();
  4840. foreach (var userId in dto.UserIds)
  4841. {
  4842. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4843. }
  4844. if (permissions.Any())
  4845. {
  4846. _sqlSugar.BeginTran();
  4847. try
  4848. {
  4849. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4850. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4851. if (result < 1)
  4852. {
  4853. _sqlSugar.RollbackTran();
  4854. return Ok(JsonView(false));
  4855. }
  4856. }
  4857. catch (Exception ex)
  4858. {
  4859. _sqlSugar.RollbackTran();
  4860. return Ok(JsonView(false, ex.Message));
  4861. }
  4862. _sqlSugar.CommitTran();
  4863. return Ok(JsonView(true));
  4864. }
  4865. return Ok(JsonView(false));
  4866. }
  4867. /// <summary>
  4868. /// 团组模块 - 出入境费用 - Add And Update
  4869. /// </summary>
  4870. /// <returns></returns>
  4871. [HttpPost]
  4872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4873. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4874. {
  4875. try
  4876. {
  4877. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4878. if (dto.DayOtherPriceData.Any())
  4879. {
  4880. var inserList = dto.DayOtherPriceData
  4881. .Where(x => x.Id == 0)
  4882. .Select(x => new Grp_DayOtherPrice
  4883. {
  4884. Cost = x.Cost,
  4885. Id = x.Id,
  4886. CreateTime = DateTime.Now,
  4887. CreateUserId = dto.UserId,
  4888. Currency = x.Currency,
  4889. Diid = x.DiId,
  4890. Index = x.Index,
  4891. IsDel = 0,
  4892. SetDataId = x.SetDataId,
  4893. SubTotal = x.SubTotal,
  4894. Remark = x.Remark
  4895. })
  4896. .ToList();
  4897. var updateList = dto.DayOtherPriceData
  4898. .Where(x => x.Id != 0)
  4899. .Select(x => new Grp_DayOtherPrice
  4900. {
  4901. Cost = x.Cost,
  4902. Id = x.Id,
  4903. CreateTime = DateTime.Now,
  4904. CreateUserId = dto.UserId,
  4905. Currency = x.Currency,
  4906. Diid = x.DiId,
  4907. Index = x.Index,
  4908. IsDel = 0,
  4909. SetDataId = x.SetDataId,
  4910. SubTotal = x.SubTotal,
  4911. Remark = x.Remark
  4912. })
  4913. .ToList();
  4914. //添加
  4915. _sqlSugar.BeginTran();
  4916. if (inserList.Any())
  4917. {
  4918. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4919. }
  4920. if (updateList.Any())
  4921. {
  4922. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4923. }
  4924. _sqlSugar.CommitTran();
  4925. }
  4926. if (data.Code != 0)
  4927. {
  4928. return Ok(JsonView(false, data.Msg));
  4929. }
  4930. //生成默认文件pdf并且通知人员
  4931. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4932. {
  4933. DiId = dto.DiId,
  4934. ExportType = 1,
  4935. SubTypeId = 1005
  4936. }, "pdf");
  4937. //发送通知
  4938. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4939. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4940. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4941. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4942. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4943. //汇率信息记录
  4944. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4945. return Ok(JsonView(true, data.Msg, data.Data));
  4946. }
  4947. catch (Exception ex)
  4948. {
  4949. return Ok(JsonView(false, ex.Message));
  4950. }
  4951. }
  4952. /// <summary>
  4953. /// 团组模块 - 出入境费用 - Confirm 费用
  4954. /// </summary>
  4955. /// <returns></returns>
  4956. [HttpPost]
  4957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4958. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4959. {
  4960. //TODO:测试完毕需把对应的用户ID更改
  4961. //1、数据表添加字段
  4962. //2、更改字段接口()
  4963. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4964. //3、确认成功 给财务发送消息
  4965. if (_view.Code == 200)
  4966. {
  4967. if (dto.Type == 1)
  4968. {
  4969. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4970. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4971. }
  4972. }
  4973. return Ok(_view);
  4974. }
  4975. /// <summary>
  4976. /// 团组模块 - 出入境费用 - File download
  4977. /// </summary>
  4978. /// <param name="dto"></param>
  4979. /// <returns></returns>
  4980. [HttpPost]
  4981. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4982. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4983. {
  4984. try
  4985. {
  4986. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4987. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4988. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4989. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4990. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4991. 3 团组成员名单 1 团组成员名单", ""));
  4992. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4993. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4994. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4995. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  4996. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  4997. //数据源
  4998. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4999. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  5000. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  5001. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  5002. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  5003. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  5004. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  5005. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5006. .Select((x, a, b) => new
  5007. {
  5008. x.Index,
  5009. itemName = a.Name,
  5010. CurrencyStr = b.Name,
  5011. x.Cost,
  5012. x.SubTotal,
  5013. x.Remark
  5014. })
  5015. .OrderBy((x) => x.Index)
  5016. .ToList(); //其他款项费用
  5017. var peiceItemCurrencys = new List<string>();
  5018. if (_DayAndCosts.Any()) {
  5019. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  5020. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  5021. }
  5022. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  5023. var peiceItemCurrencyInfos= new List<CurrencyInfo>();
  5024. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  5025. {
  5026. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  5027. }
  5028. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5029. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5030. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5031. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5032. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5033. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5034. .Select((tcl, dc, cc) => new ClientInfo
  5035. {
  5036. LastName = dc.LastName,
  5037. FirstName = dc.FirstName,
  5038. Sex = dc.Sex,
  5039. Birthday = dc.BirthDay,
  5040. Company = cc.CompanyFullName,
  5041. Job = dc.Job
  5042. })
  5043. .ToList();
  5044. foreach (var item in DeleClientList)
  5045. {
  5046. EncryptionProcessor.DecryptProperties(item);
  5047. }
  5048. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5049. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5050. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5051. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5052. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5053. if (dto.ExportType == 1) //明细表
  5054. {
  5055. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5056. {
  5057. //获取模板
  5058. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5059. //载入模板
  5060. Document doc = new Document(tempPath);
  5061. DocumentBuilder builder = new DocumentBuilder(doc);
  5062. //利用键值对存放数据
  5063. Dictionary<string, string> dic = new Dictionary<string, string>();
  5064. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5065. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5066. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5067. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5068. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5069. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5070. //境内费用(其他费用)
  5071. if (_EnterExitCosts.ChoiceOne == 1)
  5072. {
  5073. string row1_1 = "";
  5074. if (_EnterExitCosts.Visa > 0)
  5075. {
  5076. //insidePayTotal += _EnterExitCosts.Visa;
  5077. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5078. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5079. {
  5080. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5081. }
  5082. }
  5083. string row1_2 = "";
  5084. if (_EnterExitCosts.YiMiao > 0)
  5085. {
  5086. //insidePayTotal += _EnterExitCosts.YiMiao;
  5087. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5088. }
  5089. if (_EnterExitCosts.HeSuan > 0)
  5090. {
  5091. //insidePayTotal += _EnterExitCosts.HeSuan;
  5092. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5093. }
  5094. if (_EnterExitCosts.Service > 0)
  5095. {
  5096. //insidePayTotal += _EnterExitCosts.Service;
  5097. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5098. }
  5099. string row1_3 = "";
  5100. if (_EnterExitCosts.Safe > 0)
  5101. {
  5102. //insidePayTotal += _EnterExitCosts.Safe;
  5103. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5104. }
  5105. if (_EnterExitCosts.Ticket > 0)
  5106. {
  5107. //insidePayTotal += _EnterExitCosts.Ticket;
  5108. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5109. }
  5110. string row1 = "";
  5111. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5112. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5113. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5114. row1 += $"备注:{_EnterExitCosts.Remark}";
  5115. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5116. dic.Add("Row1Str", row1);
  5117. }
  5118. string airTotalStr = string.Empty,
  5119. airPriceStr = string.Empty;
  5120. //经济舱
  5121. if (_EnterExitCosts.SumJJC == 1)
  5122. {
  5123. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5124. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5125. }
  5126. //公务舱
  5127. if (_EnterExitCosts.SumGWC == 1)
  5128. {
  5129. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5130. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5131. }
  5132. //头等舱
  5133. if (_EnterExitCosts.SumTDC == 1)
  5134. {
  5135. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5136. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5137. }
  5138. //汇率描述
  5139. string rateStr = "";
  5140. if (peiceItemCurrencyInfos.Any())
  5141. {
  5142. rateStr = "\r\n汇率描述:";
  5143. foreach (var item in peiceItemCurrencyInfos)
  5144. {
  5145. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  5146. }
  5147. }
  5148. string twoItemRemark = "备注:";
  5149. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5150. {
  5151. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5152. }
  5153. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  5154. dic.Add("AirTotalStr", airTotalStr);
  5155. dic.Add("AirPriceStr", airPriceStr);
  5156. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5157. dic.Add("TwoItemRemark", twoItemRemark);
  5158. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5159. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5160. int table1Row = 0,
  5161. table2Row = 0,
  5162. table3Row = 0,
  5163. table4Row = 0,
  5164. table5Row = 0;
  5165. //住宿费
  5166. if (_EnterExitCosts.ChoiceThree == 1)
  5167. {
  5168. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5169. table1Row = dac1.Count;
  5170. #region 填充word表格内容
  5171. for (int i = 0; i < dac1.Count; i++)
  5172. {
  5173. Grp_DayAndCost dac = dac1[i];
  5174. if (dac == null) continue;
  5175. builder.MoveToCell(0, i, 0, 0);
  5176. builder.Write("第" + dac.Days.ToString() + "晚:");
  5177. builder.MoveToCell(0, i, 1, 0);
  5178. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5179. //builder.Write(dac.Place == null ? "" : dac.Place);
  5180. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5181. builder.MoveToCell(0, i, 2, 0);
  5182. builder.Write("费用标准:");
  5183. string curr = "";
  5184. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5185. if (currData != null)
  5186. {
  5187. curr = currData.Name;
  5188. }
  5189. builder.MoveToCell(0, i, 3, 0);
  5190. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5191. builder.MoveToCell(0, i, 4, 0);
  5192. builder.Write("费用小计:");
  5193. builder.MoveToCell(0, i, 5, 0);
  5194. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5195. }
  5196. #endregion
  5197. }
  5198. else dic.Add("SubZS", "0.00");
  5199. //删除多余行
  5200. while (table1.Rows.Count > table1Row)
  5201. {
  5202. table1.Rows.RemoveAt(table1Row);
  5203. }
  5204. //伙食费
  5205. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5206. if (_EnterExitCosts.ChoiceFour == 1)
  5207. {
  5208. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5209. table2Row = dac2.Count;
  5210. #region 填充word表格内容
  5211. for (int i = 0; i < dac2.Count; i++)
  5212. {
  5213. Grp_DayAndCost dac = dac2[i];
  5214. if (dac == null) continue;
  5215. builder.MoveToCell(1, i, 0, 0);
  5216. builder.Write("第" + dac.Days.ToString() + "天:");
  5217. builder.MoveToCell(1, i, 1, 0);
  5218. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5219. builder.MoveToCell(1, i, 2, 0);
  5220. builder.Write("费用标准:");
  5221. string curr = "";
  5222. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5223. if (currData != null)
  5224. {
  5225. curr = currData.Name;
  5226. }
  5227. builder.MoveToCell(1, i, 3, 0);
  5228. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5229. builder.MoveToCell(1, i, 4, 0);
  5230. builder.Write("费用小计:");
  5231. builder.MoveToCell(1, i, 5, 0);
  5232. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5233. }
  5234. #endregion
  5235. }
  5236. else dic.Add("SubHS", "0.00");
  5237. //删除多余行
  5238. while (table2.Rows.Count > table2Row)
  5239. {
  5240. table2.Rows.RemoveAt(table2Row);
  5241. }
  5242. //公杂费
  5243. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5244. if (_EnterExitCosts.ChoiceFive == 1)
  5245. {
  5246. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5247. table3Row = dac3.Count;
  5248. #region 填充word表格内容
  5249. for (int i = 0; i < dac3.Count; i++)
  5250. {
  5251. Grp_DayAndCost dac = dac3[i];
  5252. if (dac == null) continue;
  5253. builder.MoveToCell(2, i, 0, 0);
  5254. builder.Write("第" + dac.Days.ToString() + "天:");
  5255. builder.MoveToCell(2, i, 1, 0);
  5256. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5257. builder.MoveToCell(2, i, 2, 0);
  5258. builder.Write("费用标准:");
  5259. string curr = "";
  5260. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5261. if (currData != null)
  5262. {
  5263. curr = currData.Name;
  5264. }
  5265. builder.MoveToCell(2, i, 3, 0);
  5266. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5267. builder.MoveToCell(2, i, 4, 0);
  5268. builder.Write("费用小计:");
  5269. builder.MoveToCell(2, i, 5, 0);
  5270. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5271. }
  5272. //删除多余行
  5273. while (table3.Rows.Count > table3Row)
  5274. {
  5275. table3.Rows.RemoveAt(table3Row);
  5276. }
  5277. #endregion
  5278. }
  5279. else dic.Add("SubGZF", "0.00");
  5280. //删除多余行
  5281. while (table3.Rows.Count > table3Row)
  5282. {
  5283. table3.Rows.RemoveAt(table3Row);
  5284. }
  5285. //培训费
  5286. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5287. if (_EnterExitCosts.ChoiceSix == 1)
  5288. {
  5289. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5290. dic.Add("SubPX", pxStr);
  5291. table4Row = dac4.Count;
  5292. #region 填充word表格内容
  5293. for (int i = 0; i < dac4.Count; i++)
  5294. {
  5295. Grp_DayAndCost dac = dac4[i];
  5296. if (dac == null) continue;
  5297. builder.MoveToCell(3, i, 0, 0);
  5298. builder.Write("第" + dac.Days.ToString() + "天:");
  5299. builder.MoveToCell(3, i, 1, 0);
  5300. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5301. builder.MoveToCell(3, i, 2, 0);
  5302. builder.Write("费用标准:");
  5303. string curr = "";
  5304. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5305. if (currData != null)
  5306. {
  5307. curr = currData.Name;
  5308. }
  5309. builder.MoveToCell(3, i, 3, 0);
  5310. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5311. builder.MoveToCell(3, i, 4, 0);
  5312. builder.Write("费用小计:");
  5313. builder.MoveToCell(3, i, 5, 0);
  5314. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5315. }
  5316. #endregion
  5317. }
  5318. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5319. //删除多余行
  5320. while (table4.Rows.Count > table4Row)
  5321. {
  5322. table4.Rows.RemoveAt(table4Row);
  5323. }
  5324. //其他费用
  5325. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5326. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5327. {
  5328. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5329. dic.Add("titleQi", qtStr);
  5330. table5Row = dac5.Count;
  5331. #region 填充word表格内容
  5332. for (int i = 0; i < dac5.Count; i++)
  5333. {
  5334. var dac = dac5[i];
  5335. if (dac == null) continue;
  5336. builder.MoveToCell(4, i, 0, 0);
  5337. builder.Write("第" + dac.Index.ToString() + "项:");
  5338. builder.MoveToCell(4, i, 1, 0);
  5339. builder.Write(dac.itemName);
  5340. builder.MoveToCell(4, i, 2, 0);
  5341. builder.Write("费用标准:");
  5342. builder.MoveToCell(4, i, 3, 0);
  5343. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5344. builder.MoveToCell(4, i, 4, 0);
  5345. builder.Write("费用小计:");
  5346. builder.MoveToCell(4, i, 5, 0);
  5347. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5348. builder.MoveToCell(4, i, 6, 0);
  5349. builder.Write("备注:");
  5350. builder.MoveToCell(4, i, 7, 0);
  5351. builder.Write(dac.Remark);
  5352. }
  5353. #endregion
  5354. }
  5355. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5356. //删除多余行
  5357. while (table5.Rows.Count > table5Row)
  5358. {
  5359. table5.Rows.RemoveAt(table5Row);
  5360. }
  5361. //加上其他费用
  5362. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5363. decimal subJJC = 0.00M,
  5364. subGWC = 0.00M,
  5365. subTDC = 0.00M;
  5366. //经济舱
  5367. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5368. //公务舱
  5369. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5370. //头等舱
  5371. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5372. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5373. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5374. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5375. #region 填充word模板书签内容
  5376. foreach (var key in dic.Keys)
  5377. {
  5378. Bookmark bookmark = doc.Range.Bookmarks[key];
  5379. if (bookmark != null)
  5380. {
  5381. builder.MoveToBookmark(key);
  5382. builder.Write(dic[key]);
  5383. }
  5384. }
  5385. #endregion
  5386. #region 设置页眉
  5387. string userLabel = string.Empty;
  5388. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5389. if (currUserInfo != null)
  5390. {
  5391. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5392. if (userInfo != null)
  5393. {
  5394. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5395. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5396. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5397. }
  5398. }
  5399. //设置页脚
  5400. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5401. #endregion
  5402. //文件名
  5403. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5404. AsposeHelper.removewatermark_v2180();
  5405. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5406. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5407. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5408. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5409. }
  5410. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5411. {
  5412. //获取模板
  5413. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5414. //载入模板
  5415. Document doc = new Document(tempPath);
  5416. DocumentBuilder builder = new DocumentBuilder(doc);
  5417. Dictionary<string, string> dic = new Dictionary<string, string>();
  5418. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5419. {
  5420. List<string> list = new List<string>();
  5421. try
  5422. {
  5423. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5424. foreach (var item in spilitArr)
  5425. {
  5426. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5427. var depCode = spDotandEmpty[2].Substring(0, 3);
  5428. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5429. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5430. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5431. list.Add(depName);
  5432. list.Add(arrName);
  5433. }
  5434. list = list.Distinct().ToList();
  5435. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5436. }
  5437. catch (Exception)
  5438. {
  5439. dic.Add("ReturnCode", "行程录入不正确!");
  5440. }
  5441. }
  5442. else
  5443. {
  5444. dic.Add("ReturnCode", "未录入行程!");
  5445. }
  5446. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5447. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5448. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5449. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5450. {
  5451. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5452. dic.Add("Day", sp.Days.ToString());
  5453. }
  5454. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5455. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5456. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5457. //dic.Add("Names", Names);
  5458. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5459. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5460. decimal dac1totalPrice = 0.00M;
  5461. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5462. foreach (var dac in dac1)
  5463. {
  5464. if (dac.SubTotal == 0.00M)
  5465. {
  5466. continue;
  5467. }
  5468. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5469. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5470. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5471. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5472. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5473. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5474. builder.Write(currency);//币种
  5475. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5476. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5477. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5478. builder.Write("");//人数
  5479. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5480. builder.Write("");//天数
  5481. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5482. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5483. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5484. decimal rate = 0.00M;
  5485. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5486. builder.Write(rate.ToString("#0.0000"));//汇率
  5487. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5488. decimal rbmPrice = dac.SubTotal;
  5489. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5490. accommodationStartIndex++;
  5491. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5492. }
  5493. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5494. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5495. {
  5496. table1.Rows.RemoveAt(i - 1);
  5497. foodandotherStartIndex--;
  5498. }
  5499. if (dac2.Count == dac3.Count)//国家 币种 金额
  5500. {
  5501. for (int i = 0; i < dac2.Count; i++)
  5502. {
  5503. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5504. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5505. }
  5506. }
  5507. decimal dac2totalPrice = 0.00M;
  5508. foreach (var dac in dac2)
  5509. {
  5510. if (dac.SubTotal == 0)
  5511. {
  5512. continue;
  5513. }
  5514. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5515. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5516. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5517. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5518. builder.Write(currency);//币种
  5519. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5520. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5521. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5522. builder.Write("");//人数
  5523. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5524. builder.Write("");//天数
  5525. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5526. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5527. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5528. decimal rate = 0.00M;
  5529. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5530. builder.Write(rate.ToString("#0.0000"));//汇率
  5531. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5532. decimal rbmPrice = dac.SubTotal;
  5533. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5534. foodandotherStartIndex++;
  5535. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5536. }
  5537. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5538. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5539. {
  5540. table1.Rows.RemoveAt(i - 1);
  5541. }
  5542. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5543. string otherFeeStr = "";
  5544. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5545. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5546. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5547. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5548. foreach (var otherInfo in dac5)
  5549. {
  5550. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5551. }
  5552. #endregion
  5553. if (otherFeeStr.Length > 0)
  5554. {
  5555. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5556. otherFeeStr = $"({otherFeeStr})";
  5557. dic.Add("OtherFeeStr", otherFeeStr);
  5558. }
  5559. //总计
  5560. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5561. //国际旅费
  5562. string outsideAir = string.Empty;
  5563. string allPriceAir = string.Empty;
  5564. if (_EnterExitCosts.SumJJC == 1)
  5565. {
  5566. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5567. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5568. }
  5569. if (_EnterExitCosts.SumGWC == 1)
  5570. {
  5571. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5572. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5573. }
  5574. if (_EnterExitCosts.SumTDC == 1)
  5575. {
  5576. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5577. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5578. }
  5579. dic.Add("InTravelPrice", $"({outsideAir})");
  5580. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5581. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5582. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5583. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5584. foreach (var key in dic.Keys)
  5585. {
  5586. builder.MoveToBookmark(key);
  5587. builder.Write(dic[key]);
  5588. }
  5589. //模板文件名
  5590. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5591. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5592. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5593. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5594. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5595. }
  5596. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5597. {
  5598. //获取模板
  5599. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5600. //载入模板
  5601. WorkbookDesigner designer = new WorkbookDesigner();
  5602. designer.Workbook = new Workbook(tempPath);
  5603. Dictionary<string, string> dic = new Dictionary<string, string>();
  5604. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5605. {
  5606. List<string> list = new List<string>();
  5607. try
  5608. {
  5609. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5610. foreach (var item in spilitArr)
  5611. {
  5612. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5613. var depCode = spDotandEmpty[2].Substring(0, 3);
  5614. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5615. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5616. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5617. list.Add(depName);
  5618. list.Add(arrName);
  5619. }
  5620. list = list.Distinct().ToList();
  5621. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5622. }
  5623. catch (Exception)
  5624. {
  5625. dic.Add("ReturnCode", "行程录入不正确!");
  5626. }
  5627. }
  5628. else
  5629. {
  5630. dic.Add("ReturnCode", "未录入行程!");
  5631. }
  5632. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5633. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5634. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5635. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5636. {
  5637. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5638. dic.Add("Day", sp.Days.ToString());
  5639. }
  5640. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5641. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5642. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5643. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5644. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5645. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5646. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5647. designer.SetDataSource("Name", Names);
  5648. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5649. designer.SetDataSource("Day", dic["Day"] + "天");
  5650. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5651. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5652. int startIndex = 10;
  5653. const int startIndexcopy = 10;
  5654. if (dac2.Count == dac3.Count)//国家 币种 金额
  5655. {
  5656. for (int i = 0; i < dac2.Count; i++)
  5657. {
  5658. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5659. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5660. }
  5661. }
  5662. DataTable dtdac1 = new DataTable();
  5663. List<string> place = new List<string>();
  5664. dtdac1.Columns.AddRange(new DataColumn[] {
  5665. new DataColumn(){ ColumnName = "city"},
  5666. new DataColumn(){ ColumnName = "curr"},
  5667. new DataColumn(){ ColumnName = "criterion"},
  5668. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5669. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5670. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5671. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5672. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5673. });
  5674. DataTable dtdac2 = new DataTable();
  5675. dtdac2.Columns.AddRange(new DataColumn[] {
  5676. new DataColumn(){ ColumnName = "city"},
  5677. new DataColumn(){ ColumnName = "curr"},
  5678. new DataColumn(){ ColumnName = "criterion"},
  5679. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5680. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5681. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5682. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5683. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5684. });
  5685. dtdac1.TableName = "tb1";
  5686. dtdac2.TableName = "tb2";
  5687. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5688. foreach (var item in dac1)
  5689. {
  5690. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5691. if (place.Contains(item.Place))
  5692. {
  5693. continue;
  5694. }
  5695. DataRow row = dtdac1.NewRow();
  5696. row["city"] = item.Place;
  5697. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5698. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5699. row["curr"] = currency;
  5700. row["rate"] = rate.ToString("#0.0000");
  5701. row["criterion"] = item.Cost.ToString("#0.00");
  5702. row["number"] = 1;
  5703. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5704. //row["costRMB"] = rbmPrice;
  5705. dtdac1.Rows.Add(row);
  5706. place.Add(item.Place);
  5707. }
  5708. place = new List<string>();
  5709. foreach (var item in dac2)
  5710. {
  5711. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5712. if (place.Contains(item.Place))
  5713. {
  5714. continue;
  5715. }
  5716. DataRow row = dtdac2.NewRow();
  5717. row["city"] = item.Place;
  5718. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5719. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5720. row["curr"] = currency;
  5721. row["rate"] = rate.ToString("#0.0000");
  5722. row["criterion"] = item.Cost.ToString("#0.00");
  5723. row["number"] = 1;
  5724. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5725. //row["cost"] = item.SubTotal;
  5726. //row["costRMB"] = rbmPrice;
  5727. dtdac2.Rows.Add(row);
  5728. place.Add(item.Place);
  5729. //dac2totalPrice += rbmPrice;
  5730. }
  5731. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5732. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5733. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5734. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5735. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5736. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5737. string cell4Str1 = string.Empty;
  5738. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5739. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5740. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5741. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5742. string cellStr = $" 5.其他费用(";
  5743. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5744. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5745. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5746. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5747. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5748. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5749. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5750. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5751. foreach (var otherInfo in dac5)
  5752. {
  5753. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5754. }
  5755. #endregion
  5756. if (cellStr.Length > 8)
  5757. {
  5758. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5759. }
  5760. cellStr += ")";
  5761. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5762. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5763. decimal pxFee = dac4.Sum(it => it.Cost);
  5764. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5765. string celllastStr1 = "";
  5766. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5767. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5768. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5769. celllastStr1 += $",国际旅费 元";
  5770. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5771. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5772. designer.SetDataSource("cell4Str", cell4Str);
  5773. designer.SetDataSource("cellStr", cellStr);
  5774. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5775. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5776. designer.SetDataSource("celllastStr", celllastStr);
  5777. Workbook wb = designer.Workbook;
  5778. var sheet = wb.Worksheets[0];
  5779. //绑定datatable数据集
  5780. designer.SetDataSource(dtdac1);
  5781. designer.SetDataSource(dtdac2);
  5782. designer.Process();
  5783. var rowStart = dtdac1.Rows.Count;
  5784. while (rowStart > 0)
  5785. {
  5786. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5787. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5788. startIndex++;
  5789. rowStart--;
  5790. }
  5791. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5792. startIndex += 1; //总计行
  5793. rowStart = dtdac2.Rows.Count;
  5794. while (rowStart > 0)
  5795. {
  5796. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5797. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5798. startIndex++;
  5799. rowStart--;
  5800. }
  5801. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5802. wb.CalculateFormula(true);
  5803. //模板文件名
  5804. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5805. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5806. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5807. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5808. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5809. }
  5810. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5811. {
  5812. //获取模板
  5813. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5814. //载入模板
  5815. Document doc = new Document(tempPath);
  5816. DocumentBuilder builder = new DocumentBuilder(doc);
  5817. Dictionary<string, string> dic = new Dictionary<string, string>();
  5818. dic.Add("GroupName", _DelegationInfo.TeamName);
  5819. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5820. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5821. string missionLeaderJob = "";//负责人job
  5822. int groupNumber = 0; //团人数
  5823. if (DeleClientList.Count > 0)
  5824. {
  5825. missionLeader = DeleClientList[0]?.Name ?? "";
  5826. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5827. }
  5828. dic.Add("MissionLeader", missionLeader); //团负责人
  5829. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5830. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5831. #region MyRegion
  5832. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5833. //{
  5834. // List<string> list = new List<string>();
  5835. // try
  5836. // {
  5837. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5838. // foreach (var item in spilitArr)
  5839. // {
  5840. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5841. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5842. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5843. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5844. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5845. // list.Add(depName);
  5846. // list.Add(arrName);
  5847. // }
  5848. // list = list.Distinct().ToList();
  5849. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5850. // }
  5851. // catch (Exception)
  5852. // {
  5853. // dic.Add("ReturnCode", "行程录入不正确!");
  5854. // }
  5855. //}
  5856. //else
  5857. //{
  5858. // dic.Add("ReturnCode", "未录入行程!");
  5859. //}
  5860. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5861. dic.Add("ReturnCode", string.Join("、", countrys));
  5862. #endregion
  5863. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5864. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5865. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5866. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5867. //{
  5868. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5869. // dic.Add("Day", sp.Days.ToString());
  5870. //}
  5871. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5872. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5873. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5874. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5875. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5876. //培训人员名单
  5877. int cultivateRowIndex = 7;
  5878. foreach (var item in DeleClientList)
  5879. {
  5880. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5881. builder.Write(item.Name);
  5882. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5883. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5884. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5885. string birthDay = "";
  5886. if (item.Birthday != null)
  5887. {
  5888. DateTime dt = Convert.ToDateTime(item.Birthday);
  5889. birthDay = $"{dt.Year}.{dt.Month}";
  5890. }
  5891. builder.Write(birthDay);
  5892. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5893. builder.Write(item.Company);
  5894. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5895. builder.Write(item.Job);
  5896. cultivateRowIndex++;
  5897. }
  5898. //删除多余行
  5899. //cultivateRowIndex -= 2;
  5900. int delRows = 10 + 7 - cultivateRowIndex;
  5901. if (delRows > 0)
  5902. {
  5903. for (int i = 0; i < delRows; i++)
  5904. {
  5905. table1.Rows.RemoveAt(cultivateRowIndex);
  5906. //cultivateRowIndex++;
  5907. }
  5908. }
  5909. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5910. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5911. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5912. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5913. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5914. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5915. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5916. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5917. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5918. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5919. //其他费用
  5920. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5921. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5922. //其他费用合计
  5923. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5924. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5925. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5926. //公务舱合计
  5927. //国际旅费
  5928. string outsideJJ = "";
  5929. string allPriceJJ = "";
  5930. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5931. {
  5932. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5933. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5934. }
  5935. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5936. {
  5937. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5938. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5939. }
  5940. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5941. {
  5942. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5943. dic.Add("AirFeeTotal", airFeeTotalStr);
  5944. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5945. dic.Add("FeeTotal", feeTotalStr);
  5946. }
  5947. foreach (var key in dic.Keys)
  5948. {
  5949. builder.MoveToBookmark(key);
  5950. builder.Write(dic[key]);
  5951. }
  5952. //模板文件名
  5953. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5954. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5955. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5956. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5957. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5958. }
  5959. }
  5960. else if (dto.ExportType == 2) //表格
  5961. {
  5962. //利用键值对存放数据
  5963. Dictionary<string, string> dic = new Dictionary<string, string>();
  5964. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5965. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5966. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5967. dic.Add("Day", sp.Days.ToString());
  5968. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5969. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5970. {
  5971. //获取模板
  5972. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5973. //载入模板
  5974. Document doc = new Document(tempPath);
  5975. DocumentBuilder builder = new DocumentBuilder(doc);
  5976. dic.Add("TeamName", _DelegationInfo.TeamName);
  5977. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5978. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5979. string missionLeaderName = "",
  5980. missionLeaderJob = "";
  5981. if (DeleClientList.Count > 0)
  5982. {
  5983. missionLeaderName = DeleClientList[0].Name;
  5984. missionLeaderJob = DeleClientList[0].Job;
  5985. }
  5986. dic.Add("MissionLeaderName", missionLeaderName);
  5987. dic.Add("MissionLeaderJob", missionLeaderJob);
  5988. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5989. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5990. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5991. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5992. int rowCount = 10;//总人数行
  5993. int startRowIndex = 7; //起始行
  5994. for (int i = 0; i < DeleClientList.Count; i++)
  5995. {
  5996. builder.MoveToCell(0, startRowIndex, 0, 0);
  5997. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5998. builder.MoveToCell(0, startRowIndex, 1, 0);
  5999. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6000. builder.Write(sex);//性别
  6001. builder.MoveToCell(0, startRowIndex, 2, 0);
  6002. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  6003. builder.MoveToCell(0, startRowIndex, 3, 0);
  6004. builder.Write(DeleClientList[i].Company);//工作单位
  6005. builder.MoveToCell(0, startRowIndex, 4, 0);
  6006. builder.Write(DeleClientList[i].Job);//职务及级别
  6007. builder.MoveToCell(0, startRowIndex, 5, 0);
  6008. builder.Write("");//人员属性
  6009. builder.MoveToCell(0, startRowIndex, 6, 0);
  6010. builder.Write("");//上次出国时间
  6011. startRowIndex++;
  6012. }
  6013. int nullRow = rowCount - DeleClientList.Count;//空行
  6014. for (int i = 0; i < nullRow; i++)
  6015. {
  6016. table1.Rows.Remove(table1.Rows[startRowIndex]);
  6017. }
  6018. foreach (var key in dic.Keys)
  6019. {
  6020. builder.MoveToBookmark(key);
  6021. builder.Write(dic[key]);
  6022. }
  6023. //模板文件名
  6024. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  6025. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6026. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6027. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6028. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6029. }
  6030. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6031. {
  6032. //获取模板
  6033. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6034. //载入模板
  6035. Document doc = new Document(tempPath);
  6036. DocumentBuilder builder = new DocumentBuilder(doc);
  6037. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6038. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6039. dic.Add("Names", Names);
  6040. int accommodationRows = 12, foodandotherRows = 12;
  6041. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6042. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6043. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6044. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6045. int accommodationStartIndex = 6;
  6046. decimal dac1totalPrice = 0.00M;
  6047. foreach (var dac in dac1)
  6048. {
  6049. if (dac.SubTotal == 0)
  6050. {
  6051. continue;
  6052. }
  6053. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6054. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6055. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6056. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6057. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6058. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6059. builder.Write(currency);//币种
  6060. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6061. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6062. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6063. builder.Write("");//人数
  6064. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6065. builder.Write("");//天数
  6066. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6067. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6068. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6069. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6070. builder.Write(rate.ToString("#0.0000"));//汇率
  6071. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6072. decimal rbmPrice = rate * dac.SubTotal;
  6073. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6074. accommodationStartIndex++;
  6075. dac1totalPrice += rbmPrice;
  6076. }
  6077. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6078. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6079. builder.Write("小计");
  6080. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6081. builder.Write(dac1totalPrice.ToString("#0.00"));
  6082. accommodationStartIndex++;
  6083. int nullRow = accommodationRows - dac1.Count;
  6084. //删除空行
  6085. //if (nullRow > 0)
  6086. //{
  6087. // int rowIndex = accommodationStartIndex;
  6088. // for (int i = 0; i < nullRow; i++)
  6089. // {
  6090. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6091. // row.Remove();
  6092. // rowIndex++;
  6093. // }
  6094. //}
  6095. if (dac2.Count == dac3.Count)//国家 币种 金额
  6096. {
  6097. for (int i = 0; i < dac2.Count; i++)
  6098. {
  6099. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6100. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6101. }
  6102. }
  6103. int foodandotherStartIndex = 19;//
  6104. decimal dac2totalPrice = 0.00M;
  6105. foreach (var dac in dac2)
  6106. {
  6107. if (dac.SubTotal == 0)
  6108. {
  6109. continue;
  6110. }
  6111. //foodandotherStartIndex = 12;
  6112. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6113. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6114. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6115. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6116. builder.Write(currency);//币种
  6117. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6118. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6119. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6120. builder.Write("");//人数
  6121. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6122. builder.Write("");//天数
  6123. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6124. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6125. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6126. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6127. builder.Write(rate.ToString("#0.0000"));//汇率
  6128. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6129. decimal rbmPrice = rate * dac.SubTotal;
  6130. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6131. foodandotherStartIndex++;
  6132. dac2totalPrice += rbmPrice;
  6133. }
  6134. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6135. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6136. //删除空行
  6137. //if (dac2.Count < foodandotherRows)
  6138. //{
  6139. // while (table2.Rows.Count > dac2.Count)
  6140. // {
  6141. // table2.Rows.RemoveAt(dac2.Count);
  6142. // }
  6143. //}
  6144. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6145. string otherFeeStr = "";
  6146. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6147. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6148. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6149. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6150. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6151. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6152. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6153. foreach (var otherInfo in dac5)
  6154. {
  6155. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6156. }
  6157. #endregion
  6158. if (otherFeeStr.Length > 0)
  6159. {
  6160. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6161. otherFeeStr = $"({otherFeeStr})";
  6162. dic.Add("OtherFeeStr", otherFeeStr);
  6163. }
  6164. foreach (var key in dic.Keys)
  6165. {
  6166. builder.MoveToBookmark(key);
  6167. builder.Write(dic[key]);
  6168. }
  6169. //模板文件名
  6170. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6171. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6172. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6173. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6174. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6175. }
  6176. }
  6177. else if (dto.ExportType == 3)
  6178. {
  6179. if (dto.SubTypeId == 1) //团组成员名单
  6180. {
  6181. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6182. //获取模板
  6183. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6184. //载入模板
  6185. Document doc = new Document(tempPath);
  6186. DocumentBuilder builder = new DocumentBuilder(doc);
  6187. //获取word里所有表格
  6188. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6189. //获取所填表格的序数
  6190. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6191. var rowStart = tableOne.Rows[0]; //获取第1行
  6192. //循环赋值
  6193. for (int i = 0; i < DeleClientList.Count; i++)
  6194. {
  6195. builder.MoveToCell(0, i + 1, 0, 0);
  6196. builder.Write(DeleClientList[i].Name);
  6197. builder.MoveToCell(0, i + 1, 1, 0);
  6198. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6199. builder.Write(sex);
  6200. builder.MoveToCell(0, i + 1, 2, 0);
  6201. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6202. builder.MoveToCell(0, i + 1, 3, 0);
  6203. builder.Write(DeleClientList[i].Company);
  6204. builder.MoveToCell(0, i + 1, 4, 0);
  6205. builder.Write(DeleClientList[i].Job);
  6206. }
  6207. //删除多余行
  6208. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6209. {
  6210. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6211. }
  6212. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6213. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6214. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6215. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6216. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6217. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6218. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6219. }
  6220. }
  6221. return Ok(JsonView(400, "操作失败!", ""));
  6222. }
  6223. catch (Exception ex)
  6224. {
  6225. return Ok(JsonView(400, ex.Message, ""));
  6226. }
  6227. }
  6228. /// <summary>
  6229. /// 获取三公费用标准city
  6230. /// </summary>
  6231. /// <param name="placeData"></param>
  6232. /// <param name="nationalTravelFeeId"></param>
  6233. /// <returns></returns>
  6234. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6235. {
  6236. string _city = string.Empty;
  6237. if (placeData.Count < 1) return _city;
  6238. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6239. if (data == null) return _city;
  6240. string country = data.Country;
  6241. string city = data.City;
  6242. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6243. else _city = city;
  6244. return _city;
  6245. }
  6246. /// <summary>
  6247. /// 团组模块 - 出入境费用 - 明细表导出
  6248. /// </summary>
  6249. /// <returns></returns>
  6250. [HttpPost]
  6251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6252. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6253. {
  6254. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6255. if (data.Code != 0)
  6256. {
  6257. return Ok(JsonView(false, data.Msg));
  6258. }
  6259. return Ok(JsonView(true, data.Msg, data.Data));
  6260. }
  6261. /// <summary>
  6262. /// 团组模块 - 出入境费用 - 一键清空
  6263. /// </summary>
  6264. /// <returns></returns>
  6265. [HttpPost]
  6266. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6267. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6268. {
  6269. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6270. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6271. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6272. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6273. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6274. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6275. .SetColumns(x => new Grp_DayOtherPrice
  6276. {
  6277. IsDel = 1,
  6278. DeleteUserId = dto.UserId,
  6279. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6280. })
  6281. .ExecuteCommandAsync();
  6282. if (_view.Code == 0)
  6283. {
  6284. return Ok(JsonView(true, "操作成功"));
  6285. }
  6286. return Ok(JsonView(false, "操作失败"));
  6287. }
  6288. /// <summary>
  6289. /// 团组模块 - 出入境费用 - 子项删除
  6290. /// </summary>
  6291. /// <returns></returns>
  6292. [HttpPost]
  6293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6294. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6295. {
  6296. try
  6297. {
  6298. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6299. if (data.Code != 0)
  6300. {
  6301. return Ok(JsonView(false, data.Msg));
  6302. }
  6303. return Ok(JsonView(true, "操作成功!", data.Data));
  6304. }
  6305. catch (Exception ex)
  6306. {
  6307. return Ok(JsonView(false, ex.Message));
  6308. }
  6309. }
  6310. /// <summary>
  6311. /// 删除三公其他费用
  6312. /// </summary>
  6313. /// <param name="dto"></param>
  6314. /// <returns></returns>
  6315. [HttpPost]
  6316. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6317. {
  6318. var jw = JsonView(false,"删除失败!");
  6319. var data = new Grp_DayOtherPrice()
  6320. {
  6321. Id = dto.Id,
  6322. IsDel = 1,
  6323. DeleteUserId = dto.DeleteUserId,
  6324. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6325. };
  6326. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6327. if (del > 0)
  6328. {
  6329. jw.Code = 200;
  6330. jw.Msg = "删除成功!";
  6331. }
  6332. return Ok(jw);
  6333. }
  6334. /// <summary>
  6335. /// 团组模块 - 出入境国家费用标准 List
  6336. /// </summary>
  6337. /// <returns></returns>
  6338. [HttpPost]
  6339. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6340. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6341. {
  6342. try
  6343. {
  6344. Stopwatch sw = new Stopwatch();
  6345. sw.Start();
  6346. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6347. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6348. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6349. Where gntf.Isdel = 0");
  6350. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6351. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6352. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6353. //foreach (var item in nationalTravel)
  6354. //{
  6355. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6356. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6357. // if (otherData != null)
  6358. // {
  6359. // cityData.Remove(otherData);
  6360. // cityData.Add(otherData);
  6361. // }
  6362. // nationalTravelFeeData1.Add(new
  6363. // {
  6364. // Country = item.Country,
  6365. // CityData = cityData
  6366. // });
  6367. //}
  6368. sw.Stop();
  6369. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6370. }
  6371. catch (Exception ex)
  6372. {
  6373. return Ok(JsonView(false, ex.Message));
  6374. throw;
  6375. }
  6376. }
  6377. /// <summary>
  6378. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6379. /// </summary>
  6380. /// <returns></returns>
  6381. [HttpPost]
  6382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6383. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6384. {
  6385. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6386. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6387. List<string> countryData = new List<string>();
  6388. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6389. countryData = countryData.Distinct().ToList();
  6390. List<dynamic> dataSource = new List<dynamic>();
  6391. foreach (var item in countryData)
  6392. {
  6393. List<string> cityData1 = new List<string>();
  6394. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6395. var countryData2 = new
  6396. {
  6397. CountryName = item,
  6398. CityData = cityData1
  6399. };
  6400. dataSource.Add(countryData2);
  6401. }
  6402. return Ok(JsonView(true, "查询成功!", dataSource));
  6403. }
  6404. /// <summary>
  6405. /// 团组模块 - 出入境国家费用标准 Page List
  6406. /// </summary>
  6407. /// <returns></returns>
  6408. [HttpPost]
  6409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6410. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6411. {
  6412. int portId = dto.PortType;
  6413. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6414. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6415. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6416. string whereSql = string.Empty;
  6417. if (!string.IsNullOrEmpty(dto.Country))
  6418. {
  6419. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6420. }
  6421. if (!string.IsNullOrEmpty(dto.City))
  6422. {
  6423. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6424. }
  6425. string pageSql = string.Format(@"Select * From (
  6426. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6427. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6428. From Grp_NationalTravelFee gntf
  6429. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6430. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6431. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6432. RefAsync<int> total = 0;
  6433. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6434. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6435. }
  6436. /// <summary>
  6437. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6438. /// </summary>
  6439. /// <returns></returns>
  6440. [HttpPost]
  6441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6442. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6443. {
  6444. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6445. int portId = dto.PortType;
  6446. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6447. string whereSql = string.Empty;
  6448. if (!string.IsNullOrEmpty(dto.Country))
  6449. {
  6450. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6451. }
  6452. if (!string.IsNullOrEmpty(dto.City))
  6453. {
  6454. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6455. }
  6456. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6457. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6458. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6459. From Grp_NationalTravelFee gntf
  6460. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6461. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6462. Where gntf.Isdel = 0 {0} ", whereSql);
  6463. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6464. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6465. }
  6466. /// <summary>
  6467. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6468. /// </summary>
  6469. /// <returns></returns>
  6470. [HttpPost]
  6471. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6472. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6473. {
  6474. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6475. if (data.Code != 0)
  6476. {
  6477. return Ok(JsonView(false, data.Msg));
  6478. }
  6479. return Ok(JsonView(true, "操作成功!", data.Data));
  6480. }
  6481. /// <summary>
  6482. /// 团组模块 - 出入境国家费用标准 - Del
  6483. /// </summary>
  6484. /// <returns></returns>
  6485. [HttpPost]
  6486. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6487. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6488. {
  6489. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6490. {
  6491. Id = dto.Id,
  6492. DeleteUserId = dto.DeleteUserId,
  6493. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6494. IsDel = 1
  6495. };
  6496. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6497. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6498. .WhereColumns(it => new { it.Id })
  6499. .ExecuteCommandAsync();
  6500. if (delStatus <= 0)
  6501. {
  6502. return Ok(JsonView(false, "删除失败!"));
  6503. }
  6504. return Ok(JsonView(true, "操作成功!"));
  6505. }
  6506. /// <summary>
  6507. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6508. /// 注:Get 请求Headers 加 Token
  6509. /// </summary>
  6510. /// <param name="groupId"></param>
  6511. /// <returns></returns>
  6512. [HttpGet("{groupId}")]
  6513. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6514. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6515. {
  6516. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6517. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6518. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6519. data.ForEach(x =>
  6520. {
  6521. x.CreateUserId = _currUserInfo.UserId;
  6522. });
  6523. if (data.Any())
  6524. {
  6525. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6526. if (add > 0)
  6527. {
  6528. return Ok(JsonView(true, "操作成功!"));
  6529. }
  6530. }
  6531. return Ok(JsonView(false, "未操作!"));
  6532. }
  6533. #endregion
  6534. #region 团组经理模块 出入境费用-草稿
  6535. /// <summary>
  6536. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6537. /// </summary>
  6538. /// <returns></returns>
  6539. [HttpPost]
  6540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6541. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6542. {
  6543. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6544. .Where(x => x.IsDel == 0)
  6545. .OrderByDescending(x => x.CreateTime)
  6546. .Select(x => new { x.Id, x.DraftName })
  6547. .ToListAsync();
  6548. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6549. //SetDataInfoView
  6550. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6551. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6552. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6553. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6554. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6555. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6556. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6557. //默认币种显示
  6558. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6559. {
  6560. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6561. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6562. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6563. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6564. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6565. };
  6566. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6567. if (_currencyRate.Count > 0)
  6568. {
  6569. foreach (var item in _currencyInfos)
  6570. {
  6571. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6572. if (rateInfo != null)
  6573. {
  6574. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6575. rate1 *= 1.035M;
  6576. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6577. }
  6578. }
  6579. }
  6580. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6581. return Ok(JsonView(true, "查询成功!", new
  6582. {
  6583. DraftNameDatas = draftNameDatas,
  6584. CurrencyData = _CurrencyData,
  6585. WordTypeData = _WordTypeData,
  6586. ExcelTypeData = _ExcelTypeData,
  6587. CurrencyInit = _currencyInfos,
  6588. ViewPermissionData = viewPermissionData
  6589. }));
  6590. }
  6591. /// <summary>
  6592. /// 团组模块 - 出入境费用-草稿
  6593. /// 实时汇率 tips
  6594. /// 签证费用 tips
  6595. /// 机票费用 tips
  6596. /// </summary>
  6597. /// <returns></returns>
  6598. [HttpPost]
  6599. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6600. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6601. {
  6602. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6603. //默认币种显示
  6604. var _currencyInfos = _currencyInit;
  6605. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6606. List<dynamic> reteInfos = new List<dynamic>();
  6607. if (_currencyRate.Count > 0)
  6608. {
  6609. foreach (var item in _currencyInfos)
  6610. {
  6611. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6612. if (rateInfo != null)
  6613. {
  6614. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6615. decimal rate1 = item.Rate;
  6616. rate1 *= 1.03M;
  6617. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6618. reteInfos.Add(new
  6619. {
  6620. currCode = item.CurrencyCode,
  6621. currName = item.CurrencyName,
  6622. rate = rate2,
  6623. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6624. });
  6625. }
  6626. }
  6627. }
  6628. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6629. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6630. return Ok(JsonView(true, "查询成功!", new
  6631. {
  6632. //GroupNameData = groupNameData.Data,
  6633. //visaData = visaData.Data,
  6634. //airData = airData.Data,
  6635. reteInfos = reteInfos
  6636. }));
  6637. }
  6638. /// <summary>
  6639. /// 团组模块 - 出入境费用-草稿 - Info
  6640. /// </summary>
  6641. /// <returns></returns>
  6642. [HttpPost]
  6643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6644. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6645. {
  6646. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6647. }
  6648. /// <summary>
  6649. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6650. /// </summary>
  6651. /// <returns></returns>
  6652. [HttpPost]
  6653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6654. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6655. {
  6656. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6657. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6658. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6659. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6660. foreach (var userId in dto.UserIds)
  6661. {
  6662. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6663. }
  6664. if (permissions.Any())
  6665. {
  6666. _sqlSugar.BeginTran();
  6667. try
  6668. {
  6669. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6670. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6671. if (result < 1)
  6672. {
  6673. _sqlSugar.RollbackTran();
  6674. return Ok(JsonView(false));
  6675. }
  6676. }
  6677. catch (Exception ex)
  6678. {
  6679. _sqlSugar.RollbackTran();
  6680. return Ok(JsonView(false, ex.Message));
  6681. }
  6682. _sqlSugar.CommitTran();
  6683. return Ok(JsonView(true));
  6684. }
  6685. return Ok(JsonView(false));
  6686. }
  6687. /// <summary>
  6688. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6689. /// </summary>
  6690. /// <returns></returns>
  6691. [HttpPost]
  6692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6693. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6694. {
  6695. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6696. if (data.Code != 0)
  6697. {
  6698. return Ok(JsonView(false, data.Msg));
  6699. }
  6700. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6701. //汇率信息记录
  6702. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6703. return Ok(JsonView(true, data.Msg, data.Data));
  6704. }
  6705. /// <summary>
  6706. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6707. /// </summary>
  6708. /// <param name="dto"></param>
  6709. /// <returns></returns>
  6710. [HttpPost]
  6711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6712. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6713. {
  6714. try
  6715. {
  6716. var id = dto.Id;
  6717. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6718. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6719. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6720. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6721. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6722. 3 团组成员名单 1 团组成员名单", ""));
  6723. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6724. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6725. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6726. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6727. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6728. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  6729. //数据源
  6730. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6731. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6732. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6733. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6734. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6735. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6736. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6737. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6738. .Select((x, a, b) => new
  6739. {
  6740. x.Index,
  6741. itemName = a.Name,
  6742. CurrencyStr = b.Name,
  6743. x.Cost,
  6744. x.SubTotal,
  6745. x.Remark
  6746. })
  6747. .OrderBy((x) => x.Index)
  6748. .ToList(); //其他款项费用
  6749. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6750. var peiceItemCurrencys = new List<string>();
  6751. if (_DayAndCosts.Any())
  6752. {
  6753. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  6754. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  6755. }
  6756. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  6757. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  6758. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  6759. {
  6760. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  6761. }
  6762. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6763. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6764. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6765. if (dto.ExportType == 1) //明细表
  6766. {
  6767. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6768. {
  6769. //获取模板
  6770. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6771. //载入模板
  6772. Document doc = new Document(tempPath);
  6773. DocumentBuilder builder = new DocumentBuilder(doc);
  6774. //利用键值对存放数据
  6775. Dictionary<string, string> dic = new Dictionary<string, string>();
  6776. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6777. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6778. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6779. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6780. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6781. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6782. //境内费用(其他费用)
  6783. if (_EnterExitCosts.ChoiceOne == 1)
  6784. {
  6785. string row1_1 = "";
  6786. if (_EnterExitCosts.Visa > 0)
  6787. {
  6788. //insidePayTotal += _EnterExitCosts.Visa;
  6789. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6790. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6791. {
  6792. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6793. }
  6794. }
  6795. string row1_2 = "";
  6796. if (_EnterExitCosts.YiMiao > 0)
  6797. {
  6798. //insidePayTotal += _EnterExitCosts.YiMiao;
  6799. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6800. }
  6801. if (_EnterExitCosts.HeSuan > 0)
  6802. {
  6803. //insidePayTotal += _EnterExitCosts.HeSuan;
  6804. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6805. }
  6806. if (_EnterExitCosts.Service > 0)
  6807. {
  6808. //insidePayTotal += _EnterExitCosts.Service;
  6809. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6810. }
  6811. string row1_3 = "";
  6812. if (_EnterExitCosts.Safe > 0)
  6813. {
  6814. //insidePayTotal += _EnterExitCosts.Safe;
  6815. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6816. }
  6817. if (_EnterExitCosts.Ticket > 0)
  6818. {
  6819. //insidePayTotal += _EnterExitCosts.Ticket;
  6820. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6821. }
  6822. string row1 = "";
  6823. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6824. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6825. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6826. row1 += $"备注:{_EnterExitCosts.Remark}";
  6827. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6828. dic.Add("Row1Str", row1);
  6829. }
  6830. string airTotalStr = string.Empty,
  6831. airPriceStr = string.Empty;
  6832. //经济舱
  6833. if (_EnterExitCosts.SumJJC == 1)
  6834. {
  6835. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6836. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6837. }
  6838. //公务舱
  6839. if (_EnterExitCosts.SumGWC == 1)
  6840. {
  6841. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6842. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6843. }
  6844. //头等舱
  6845. if (_EnterExitCosts.SumTDC == 1)
  6846. {
  6847. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6848. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6849. }
  6850. //汇率描述
  6851. string rateStr = "";
  6852. if (peiceItemCurrencyInfos.Any())
  6853. {
  6854. rateStr = "\r\n汇率描述:";
  6855. foreach (var item in peiceItemCurrencyInfos)
  6856. {
  6857. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  6858. }
  6859. }
  6860. string twoItemRemark = "备注:";
  6861. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6862. {
  6863. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6864. }
  6865. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  6866. dic.Add("AirTotalStr", airTotalStr);
  6867. dic.Add("AirPriceStr", airPriceStr);
  6868. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6869. dic.Add("TwoItemRemark", twoItemRemark);
  6870. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6871. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6872. int table1Row = 0,
  6873. table2Row = 0,
  6874. table3Row = 0,
  6875. table4Row = 0,
  6876. table5Row = 0;
  6877. //住宿费
  6878. if (_EnterExitCosts.ChoiceThree == 1)
  6879. {
  6880. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6881. table1Row = dac1.Count;
  6882. #region 填充word表格内容
  6883. for (int i = 0; i < dac1.Count; i++)
  6884. {
  6885. var dac = dac1[i];
  6886. if (dac == null) continue;
  6887. builder.MoveToCell(0, i, 0, 0);
  6888. builder.Write("第" + dac.Days.ToString() + "晚:");
  6889. builder.MoveToCell(0, i, 1, 0);
  6890. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6891. //builder.Write(dac.Place == null ? "" : dac.Place);
  6892. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6893. builder.MoveToCell(0, i, 2, 0);
  6894. builder.Write("费用标准:");
  6895. string curr = "";
  6896. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6897. if (currData != null)
  6898. {
  6899. curr = currData.Name;
  6900. }
  6901. builder.MoveToCell(0, i, 3, 0);
  6902. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6903. builder.MoveToCell(0, i, 4, 0);
  6904. builder.Write("费用小计:");
  6905. builder.MoveToCell(0, i, 5, 0);
  6906. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6907. }
  6908. #endregion
  6909. }
  6910. else dic.Add("SubZS", "0.00");
  6911. //删除多余行
  6912. while (table1.Rows.Count > table1Row)
  6913. {
  6914. table1.Rows.RemoveAt(table1Row);
  6915. }
  6916. //伙食费
  6917. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6918. if (_EnterExitCosts.ChoiceFour == 1)
  6919. {
  6920. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6921. table2Row = dac2.Count;
  6922. #region 填充word表格内容
  6923. for (int i = 0; i < dac2.Count; i++)
  6924. {
  6925. var dac = dac2[i];
  6926. if (dac == null) continue;
  6927. builder.MoveToCell(1, i, 0, 0);
  6928. builder.Write("第" + dac.Days.ToString() + "天:");
  6929. builder.MoveToCell(1, i, 1, 0);
  6930. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6931. builder.MoveToCell(1, i, 2, 0);
  6932. builder.Write("费用标准:");
  6933. string curr = "";
  6934. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6935. if (currData != null)
  6936. {
  6937. curr = currData.Name;
  6938. }
  6939. builder.MoveToCell(1, i, 3, 0);
  6940. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6941. builder.MoveToCell(1, i, 4, 0);
  6942. builder.Write("费用小计:");
  6943. builder.MoveToCell(1, i, 5, 0);
  6944. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6945. }
  6946. #endregion
  6947. }
  6948. else dic.Add("SubHS", "0.00");
  6949. //删除多余行
  6950. while (table2.Rows.Count > table2Row)
  6951. {
  6952. table2.Rows.RemoveAt(table2Row);
  6953. }
  6954. //公杂费
  6955. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6956. if (_EnterExitCosts.ChoiceFive == 1)
  6957. {
  6958. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6959. table3Row = dac3.Count;
  6960. #region 填充word表格内容
  6961. for (int i = 0; i < dac3.Count; i++)
  6962. {
  6963. var dac = dac3[i];
  6964. if (dac == null) continue;
  6965. builder.MoveToCell(2, i, 0, 0);
  6966. builder.Write("第" + dac.Days.ToString() + "天:");
  6967. builder.MoveToCell(2, i, 1, 0);
  6968. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6969. builder.MoveToCell(2, i, 2, 0);
  6970. builder.Write("费用标准:");
  6971. string curr = "";
  6972. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6973. if (currData != null)
  6974. {
  6975. curr = currData.Name;
  6976. }
  6977. builder.MoveToCell(2, i, 3, 0);
  6978. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6979. builder.MoveToCell(2, i, 4, 0);
  6980. builder.Write("费用小计:");
  6981. builder.MoveToCell(2, i, 5, 0);
  6982. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6983. }
  6984. //删除多余行
  6985. while (table3.Rows.Count > table3Row)
  6986. {
  6987. table3.Rows.RemoveAt(table3Row);
  6988. }
  6989. #endregion
  6990. }
  6991. else dic.Add("SubGZF", "0.00");
  6992. //删除多余行
  6993. while (table3.Rows.Count > table3Row)
  6994. {
  6995. table3.Rows.RemoveAt(table3Row);
  6996. }
  6997. //培训费
  6998. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6999. if (_EnterExitCosts.ChoiceSix == 1)
  7000. {
  7001. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  7002. dic.Add("SubPX", pxStr);
  7003. table4Row = dac4.Count;
  7004. #region 填充word表格内容
  7005. for (int i = 0; i < dac4.Count; i++)
  7006. {
  7007. var dac = dac4[i];
  7008. if (dac == null) continue;
  7009. builder.MoveToCell(3, i, 0, 0);
  7010. builder.Write("第" + dac.Days.ToString() + "天:");
  7011. builder.MoveToCell(3, i, 1, 0);
  7012. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  7013. builder.MoveToCell(3, i, 2, 0);
  7014. builder.Write("费用标准:");
  7015. string curr = "";
  7016. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7017. if (currData != null)
  7018. {
  7019. curr = currData.Name;
  7020. }
  7021. builder.MoveToCell(3, i, 3, 0);
  7022. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7023. builder.MoveToCell(3, i, 4, 0);
  7024. builder.Write("费用小计:");
  7025. builder.MoveToCell(3, i, 5, 0);
  7026. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7027. }
  7028. #endregion
  7029. }
  7030. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  7031. //删除多余行
  7032. while (table4.Rows.Count > table4Row)
  7033. {
  7034. table4.Rows.RemoveAt(table4Row);
  7035. }
  7036. //其他费用
  7037. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  7038. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  7039. {
  7040. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  7041. dic.Add("titleQi", qtStr);
  7042. table5Row = dac5.Count;
  7043. #region 填充word表格内容
  7044. for (int i = 0; i < dac5.Count; i++)
  7045. {
  7046. var dac = dac5[i];
  7047. if (dac == null) continue;
  7048. builder.MoveToCell(4, i, 0, 0);
  7049. builder.Write("第" + dac.Index.ToString() + "项:");
  7050. builder.MoveToCell(4, i, 1, 0);
  7051. builder.Write(dac.itemName);
  7052. builder.MoveToCell(4, i, 2, 0);
  7053. builder.Write("费用标准:");
  7054. builder.MoveToCell(4, i, 3, 0);
  7055. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7056. builder.MoveToCell(4, i, 4, 0);
  7057. builder.Write("费用小计:");
  7058. builder.MoveToCell(4, i, 5, 0);
  7059. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7060. builder.MoveToCell(4, i, 6, 0);
  7061. builder.Write("备注:");
  7062. builder.MoveToCell(4, i, 7, 0);
  7063. builder.Write(dac.Remark);
  7064. }
  7065. #endregion
  7066. }
  7067. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7068. //删除多余行
  7069. while (table5.Rows.Count > table5Row)
  7070. {
  7071. table5.Rows.RemoveAt(table5Row);
  7072. }
  7073. //加上其他费用
  7074. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7075. decimal subJJC = 0.00M,
  7076. subGWC = 0.00M,
  7077. subTDC = 0.00M;
  7078. //经济舱
  7079. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7080. //公务舱
  7081. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7082. //头等舱
  7083. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7084. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7085. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7086. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7087. #region 填充word模板书签内容
  7088. foreach (var key in dic.Keys)
  7089. {
  7090. Bookmark bookmark = doc.Range.Bookmarks[key];
  7091. if (bookmark != null)
  7092. {
  7093. builder.MoveToBookmark(key);
  7094. builder.Write(dic[key]);
  7095. }
  7096. }
  7097. #endregion
  7098. //文件名
  7099. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7100. strFileName = CommonFun.ValidFileName(strFileName);
  7101. AsposeHelper.removewatermark_v2180();
  7102. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7103. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7104. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7105. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7106. }
  7107. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7108. {
  7109. //获取模板
  7110. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7111. //载入模板
  7112. Document doc = new Document(tempPath);
  7113. DocumentBuilder builder = new DocumentBuilder(doc);
  7114. Dictionary<string, string> dic = new Dictionary<string, string>();
  7115. string returnCodeLabel = string.Empty;
  7116. if (nationalTravelFeeData.Any())
  7117. {
  7118. List<string> list = new List<string>();
  7119. foreach (var item in nationalTravelFeeData)
  7120. {
  7121. list.Add($"{item.Country}({item.City})");
  7122. }
  7123. list = list.Distinct().ToList();
  7124. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7125. }
  7126. var countryLabel = string.Empty;
  7127. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7128. if (countryData.Any())
  7129. {
  7130. countryLabel = string.Join("、", countryData);
  7131. }
  7132. dic.Add("ReturnCodeAir", returnCodeLabel);
  7133. dic.Add("VisitStartDate", "-");
  7134. dic.Add("VisitEndDate", "-");
  7135. dic.Add("Day", "-");
  7136. dic.Add("VisitCountry", countryLabel);
  7137. dic.Add("ClientUnit", "-");
  7138. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7139. //dic.Add("Names", Names);
  7140. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7141. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7142. decimal dac1totalPrice = 0.00M;
  7143. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7144. foreach (var dac in dac1)
  7145. {
  7146. if (dac.SubTotal == 0.00M)
  7147. {
  7148. continue;
  7149. }
  7150. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7151. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7152. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7153. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7154. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7155. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7156. builder.Write(currency);//币种
  7157. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7158. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7159. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7160. builder.Write("");//人数
  7161. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7162. builder.Write("");//天数
  7163. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7164. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7165. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7166. decimal rate = 0.00M;
  7167. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7168. builder.Write(rate.ToString("#0.0000"));//汇率
  7169. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7170. decimal rbmPrice = dac.SubTotal;
  7171. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7172. accommodationStartIndex++;
  7173. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7174. }
  7175. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7176. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7177. {
  7178. table1.Rows.RemoveAt(i - 1);
  7179. foodandotherStartIndex--;
  7180. }
  7181. if (dac2.Count == dac3.Count)//国家 币种 金额
  7182. {
  7183. for (int i = 0; i < dac2.Count; i++)
  7184. {
  7185. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7186. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7187. }
  7188. }
  7189. decimal dac2totalPrice = 0.00M;
  7190. foreach (var dac in dac2)
  7191. {
  7192. if (dac.SubTotal == 0)
  7193. {
  7194. continue;
  7195. }
  7196. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7197. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7198. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7199. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7200. builder.Write(currency);//币种
  7201. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7202. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7203. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7204. builder.Write("");//人数
  7205. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7206. builder.Write("");//天数
  7207. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7208. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7209. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7210. decimal rate = 0.00M;
  7211. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7212. builder.Write(rate.ToString("#0.0000"));//汇率
  7213. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7214. decimal rbmPrice = dac.SubTotal;
  7215. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7216. foodandotherStartIndex++;
  7217. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7218. }
  7219. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7220. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7221. {
  7222. table1.Rows.RemoveAt(i - 1);
  7223. }
  7224. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7225. string otherFeeStr = "";
  7226. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7227. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7228. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7229. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7230. foreach (var otherInfo in dac5)
  7231. {
  7232. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7233. }
  7234. #endregion
  7235. if (otherFeeStr.Length > 0)
  7236. {
  7237. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7238. otherFeeStr = $"({otherFeeStr})";
  7239. dic.Add("OtherFeeStr", otherFeeStr);
  7240. }
  7241. //总计
  7242. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7243. //国际旅费
  7244. string outsideAir = string.Empty;
  7245. string allPriceAir = string.Empty;
  7246. if (_EnterExitCosts.SumJJC == 1)
  7247. {
  7248. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7249. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7250. }
  7251. if (_EnterExitCosts.SumGWC == 1)
  7252. {
  7253. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7254. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7255. }
  7256. if (_EnterExitCosts.SumTDC == 1)
  7257. {
  7258. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7259. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7260. }
  7261. dic.Add("InTravelPrice", $"({outsideAir})");
  7262. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7263. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7264. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7265. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7266. foreach (var key in dic.Keys)
  7267. {
  7268. builder.MoveToBookmark(key);
  7269. builder.Write(dic[key]);
  7270. }
  7271. //模板文件名
  7272. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7273. strFileName = CommonFun.ValidFileName(strFileName);
  7274. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7275. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7276. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7277. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7278. }
  7279. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7280. {
  7281. //获取模板
  7282. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7283. //载入模板
  7284. WorkbookDesigner designer = new WorkbookDesigner();
  7285. designer.Workbook = new Workbook(tempPath);
  7286. Dictionary<string, string> dic = new Dictionary<string, string>();
  7287. string returnCodeLabel = string.Empty;
  7288. if (nationalTravelFeeData.Any())
  7289. {
  7290. List<string> list = new List<string>();
  7291. foreach (var item in nationalTravelFeeData)
  7292. {
  7293. list.Add($"{item.Country}({item.City})");
  7294. }
  7295. list = list.Distinct().ToList();
  7296. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7297. }
  7298. var countryLabel = string.Empty;
  7299. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7300. if (countryData.Any())
  7301. {
  7302. countryLabel = string.Join("、", countryData);
  7303. }
  7304. dic.Add("ReturnCodeAir", returnCodeLabel);
  7305. dic.Add("VisitStartDate", "-");
  7306. dic.Add("VisitEndDate", "-");
  7307. dic.Add("Day", "0");
  7308. dic.Add("VisitCountry", countryLabel);
  7309. dic.Add("ClientUnit", "-");
  7310. designer.SetDataSource("ClientUnit", "-");
  7311. designer.SetDataSource("VisitCountry", countryLabel);
  7312. designer.SetDataSource("Group", "-");
  7313. designer.SetDataSource("ClientUnitTitle", "-");
  7314. designer.SetDataSource("Name", "-");
  7315. designer.SetDataSource("VisitStartDate", "-" );
  7316. designer.SetDataSource("Day", "0");
  7317. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7318. designer.SetDataSource("ReturnCodeAir", "-");
  7319. int startIndex = 10;
  7320. const int startIndexcopy = 10;
  7321. if (dac2.Count == dac3.Count)//国家 币种 金额
  7322. {
  7323. for (int i = 0; i < dac2.Count; i++)
  7324. {
  7325. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7326. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7327. }
  7328. }
  7329. DataTable dtdac1 = new DataTable();
  7330. List<string> place = new List<string>();
  7331. dtdac1.Columns.AddRange(new DataColumn[] {
  7332. new DataColumn(){ ColumnName = "city"},
  7333. new DataColumn(){ ColumnName = "curr"},
  7334. new DataColumn(){ ColumnName = "criterion"},
  7335. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7336. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7337. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7338. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7339. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7340. });
  7341. DataTable dtdac2 = new DataTable();
  7342. dtdac2.Columns.AddRange(new DataColumn[] {
  7343. new DataColumn(){ ColumnName = "city"},
  7344. new DataColumn(){ ColumnName = "curr"},
  7345. new DataColumn(){ ColumnName = "criterion"},
  7346. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7347. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7348. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7349. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7350. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7351. });
  7352. dtdac1.TableName = "tb1";
  7353. dtdac2.TableName = "tb2";
  7354. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7355. foreach (var item in dac1)
  7356. {
  7357. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7358. if (place.Contains(item.Place))
  7359. {
  7360. continue;
  7361. }
  7362. DataRow row = dtdac1.NewRow();
  7363. row["city"] = item.Place;
  7364. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7365. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7366. row["curr"] = currency;
  7367. row["rate"] = rate.ToString("#0.0000");
  7368. row["criterion"] = item.Cost.ToString("#0.00");
  7369. row["number"] = 1;
  7370. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7371. //row["costRMB"] = rbmPrice;
  7372. dtdac1.Rows.Add(row);
  7373. place.Add(item.Place);
  7374. }
  7375. place = new List<string>();
  7376. foreach (var item in dac2)
  7377. {
  7378. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7379. if (place.Contains(item.Place))
  7380. {
  7381. continue;
  7382. }
  7383. DataRow row = dtdac2.NewRow();
  7384. row["city"] = item.Place;
  7385. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7386. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7387. row["curr"] = currency;
  7388. row["rate"] = rate.ToString("#0.0000");
  7389. row["criterion"] = item.Cost.ToString("#0.00");
  7390. row["number"] = 1;
  7391. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7392. //row["cost"] = item.SubTotal;
  7393. //row["costRMB"] = rbmPrice;
  7394. dtdac2.Rows.Add(row);
  7395. place.Add(item.Place);
  7396. //dac2totalPrice += rbmPrice;
  7397. }
  7398. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7399. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7400. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7401. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7402. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7403. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7404. string cell4Str1 = string.Empty;
  7405. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7406. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7407. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7408. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7409. string cellStr = $" 5.其他费用(";
  7410. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7411. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7412. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7413. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7414. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7415. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7416. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7417. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7418. foreach (var otherInfo in dac5)
  7419. {
  7420. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7421. }
  7422. #endregion
  7423. if (cellStr.Length > 8)
  7424. {
  7425. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7426. }
  7427. cellStr += ")";
  7428. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7429. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7430. decimal pxFee = dac4.Sum(it => it.Cost);
  7431. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7432. string celllastStr1 = "";
  7433. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7434. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7435. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7436. celllastStr1 += $",国际旅费 元";
  7437. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7438. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7439. designer.SetDataSource("cell4Str", cell4Str);
  7440. designer.SetDataSource("cellStr", cellStr);
  7441. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7442. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7443. designer.SetDataSource("celllastStr", celllastStr);
  7444. Workbook wb = designer.Workbook;
  7445. var sheet = wb.Worksheets[0];
  7446. //绑定datatable数据集
  7447. designer.SetDataSource(dtdac1);
  7448. designer.SetDataSource(dtdac2);
  7449. designer.Process();
  7450. var rowStart = dtdac1.Rows.Count;
  7451. while (rowStart > 0)
  7452. {
  7453. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7454. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7455. startIndex++;
  7456. rowStart--;
  7457. }
  7458. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7459. startIndex += 1; //总计行
  7460. rowStart = dtdac2.Rows.Count;
  7461. while (rowStart > 0)
  7462. {
  7463. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7464. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7465. startIndex++;
  7466. rowStart--;
  7467. }
  7468. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7469. wb.CalculateFormula(true);
  7470. //模板文件名
  7471. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7472. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7473. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7474. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7475. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7476. }
  7477. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7478. {
  7479. //获取模板
  7480. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7481. //载入模板
  7482. Document doc = new Document(tempPath);
  7483. DocumentBuilder builder = new DocumentBuilder(doc);
  7484. Dictionary<string, string> dic = new Dictionary<string, string>();
  7485. dic.Add("GroupName", "-");
  7486. dic.Add("ClientUnit", "-");
  7487. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7488. string missionLeaderJob = "";//负责人job
  7489. int groupNumber = 0; //团人数
  7490. dic.Add("MissionLeader", "-"); //团负责人
  7491. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7492. dic.Add("GroupNumber", "0"); //团人数
  7493. dic.Add("Day", "0");
  7494. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7495. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7496. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7497. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7498. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7499. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7500. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7501. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7502. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7503. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7504. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7505. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7506. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7507. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7508. //其他费用
  7509. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7510. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7511. //其他费用合计
  7512. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7513. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7514. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7515. //公务舱合计
  7516. //国际旅费
  7517. string outsideJJ = "";
  7518. string allPriceJJ = "";
  7519. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7520. {
  7521. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7522. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7523. }
  7524. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7525. {
  7526. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7527. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7528. }
  7529. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7530. {
  7531. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7532. dic.Add("AirFeeTotal", airFeeTotalStr);
  7533. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7534. dic.Add("FeeTotal", feeTotalStr);
  7535. }
  7536. foreach (var key in dic.Keys)
  7537. {
  7538. builder.MoveToBookmark(key);
  7539. builder.Write(dic[key]);
  7540. }
  7541. //模板文件名
  7542. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7543. strFileName = CommonFun.ValidFileName(strFileName);
  7544. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7545. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7546. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7547. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7548. }
  7549. }
  7550. else if (dto.ExportType == 2) //表格
  7551. {
  7552. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7553. }
  7554. else if (dto.ExportType == 3)
  7555. {
  7556. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7557. }
  7558. return Ok(JsonView(400, "只可导出明细表!", ""));
  7559. }
  7560. catch (Exception ex)
  7561. {
  7562. return Ok(JsonView(400, ex.Message, ""));
  7563. }
  7564. }
  7565. /// <summary>
  7566. /// 获取三公费用标准city
  7567. /// </summary>
  7568. /// <param name="placeData"></param>
  7569. /// <param name="nationalTravelFeeId"></param>
  7570. /// <returns></returns>
  7571. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7572. {
  7573. string _city = string.Empty;
  7574. if (!placeData.Any()) return _city;
  7575. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7576. if (data == null) return _city;
  7577. string country = data.Country;
  7578. string city = data.City;
  7579. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7580. else _city = city;
  7581. return _city;
  7582. }
  7583. /// <summary>
  7584. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7585. /// </summary>
  7586. /// <returns></returns>
  7587. [HttpPost]
  7588. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7589. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7590. {
  7591. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7592. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7593. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7594. if (_view.Code == 0)
  7595. {
  7596. return Ok(JsonView(true, "操作成功"));
  7597. }
  7598. return Ok(JsonView(false, "操作失败"));
  7599. }
  7600. /// <summary>
  7601. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7602. /// </summary>
  7603. /// <returns></returns>
  7604. [HttpPost]
  7605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7606. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7607. {
  7608. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7609. if (data.Code != 0)
  7610. {
  7611. return Ok(JsonView(false, data.Msg));
  7612. }
  7613. return Ok(JsonView(true, "操作成功!", data.Data));
  7614. }
  7615. /// <summary>
  7616. /// 三公其他费用草稿 删除
  7617. /// </summary>
  7618. /// <param name="dto"></param>
  7619. /// <returns></returns>
  7620. [HttpPost]
  7621. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7622. {
  7623. var jw = JsonView(false, "删除失败!");
  7624. var data = new Grp_DayOtherPriceDraft()
  7625. {
  7626. Id = dto.Id,
  7627. IsDel = 1,
  7628. DeleteUserId = dto.DeleteUserId,
  7629. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7630. };
  7631. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7632. if (del > 0)
  7633. {
  7634. jw.Code = 200;
  7635. jw.Msg = "删除成功!";
  7636. }
  7637. return Ok(jw);
  7638. }
  7639. /// <summary>
  7640. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7641. /// </summary>
  7642. /// <param name="dto"></param>
  7643. /// <returns></returns>
  7644. [HttpPost]
  7645. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7646. {
  7647. var jw = JsonView(false);
  7648. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7649. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7650. jw.Code = StatusCodes.Status200OK;
  7651. jw.Msg = "操作成功!";
  7652. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7653. return Ok(jw);
  7654. }
  7655. /// <summary>
  7656. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7657. /// </summary>
  7658. /// <param name="dto"></param>
  7659. /// <returns></returns>
  7660. [HttpPost]
  7661. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7662. {
  7663. int userId = dto.UserId,
  7664. portId = dto.PortType,
  7665. groupId = dto.GroupId,
  7666. draftId = dto.DraftId;
  7667. _portTypeData.Add(1);
  7668. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7669. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7670. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7671. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7672. _sqlSugar.BeginTran();
  7673. try
  7674. {
  7675. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7676. if (draftDatas == null)
  7677. {
  7678. _sqlSugar.RollbackTran();
  7679. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7680. }
  7681. //验证可覆盖已有数据 两边创建人需为同一人;
  7682. int draftCreateUserId = draftDatas.CreateUserId,
  7683. formalCreateUserId = 0;
  7684. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7685. if (formalData != null)
  7686. {
  7687. formalCreateUserId = formalData.CreateUserId;
  7688. if (draftCreateUserId != formalCreateUserId)
  7689. {
  7690. _sqlSugar.RollbackTran();
  7691. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7692. }
  7693. }
  7694. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7695. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7696. var permissions = new List<Grp_EnterExitCostPermission>();
  7697. if (userIds.Any())
  7698. {
  7699. foreach (var userId1 in userIds)
  7700. {
  7701. permissions.Add(new Grp_EnterExitCostPermission() {
  7702. GroupId = groupId,
  7703. UserId = userId1,
  7704. CreateUserId = dto.UserId
  7705. });
  7706. }
  7707. }
  7708. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7709. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7710. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7711. newExterData.DiId = groupId;
  7712. newExterData.CreateUserId = userId;
  7713. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7714. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7715. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7716. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7717. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7718. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7719. //数据如果存在执行删除
  7720. if (enterExitCostInfo != null)
  7721. {
  7722. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7723. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7724. .Where(x => x.Id == enterExitCostInfo.Id)
  7725. .ExecuteCommand();
  7726. _sqlSugar.Updateable<Grp_DayAndCost>()
  7727. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7728. .Where(x => x.DiId == groupId)
  7729. .ExecuteCommand();
  7730. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7731. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7732. .Where(x => x.Diid == groupId)
  7733. .ExecuteCommand();
  7734. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7735. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7736. .Where(x => x.GroupId == groupId)
  7737. .ExecuteCommand();
  7738. }
  7739. //执行insert
  7740. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7741. if (insertId < 1)
  7742. {
  7743. _sqlSugar.RollbackTran();
  7744. return Ok(JsonView(false, "草稿数据导入失败!"));
  7745. }
  7746. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7747. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7748. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7749. _sqlSugar.CommitTran();
  7750. //执行操作之后
  7751. //生成默认文件pdf并且通知人员
  7752. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7753. {
  7754. DiId = groupId,
  7755. ExportType = 1,
  7756. SubTypeId = 1005
  7757. }, "pdf");
  7758. //发送通知
  7759. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7760. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7761. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7762. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7763. //汇率信息记录
  7764. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7765. return Ok(JsonView(true));
  7766. }
  7767. catch (Exception ex)
  7768. {
  7769. _sqlSugar.RollbackTran();
  7770. return Ok(JsonView(false,ex.Message));
  7771. }
  7772. }
  7773. #endregion
  7774. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7775. /// <summary>
  7776. /// 获取币种基础数据(含逻辑处理)
  7777. /// </summary>
  7778. /// <returns></returns>
  7779. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7780. {
  7781. //默认币种显示
  7782. var _currencyInfos = _currencyInit;
  7783. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7784. if (_currencyRate.Count > 0)
  7785. {
  7786. foreach (var item in _currencyInfos)
  7787. {
  7788. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7789. if (rateInfo != null)
  7790. {
  7791. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7792. rate1 *= 1.035M;
  7793. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7794. }
  7795. }
  7796. }
  7797. return _currencyInfos;
  7798. }
  7799. /// <summary>
  7800. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7801. /// </summary>
  7802. /// <returns></returns>
  7803. [HttpPost]
  7804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7805. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7806. {
  7807. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7808. //SetDataInfoView
  7809. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7810. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7811. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7812. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7813. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7814. //默认币种显示
  7815. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7816. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7817. return Ok(JsonView(true, "查询成功!", new
  7818. {
  7819. WordTypeData = _WordTypeData,
  7820. ExcelTypeData = _ExcelTypeData,
  7821. CurrencyInit = _currencyInfos,
  7822. viewPermissionData = viewPermissionData
  7823. }));
  7824. }
  7825. /// <summary>
  7826. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7827. /// </summary>
  7828. /// <returns></returns>
  7829. [HttpPost]
  7830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7831. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7832. {
  7833. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7834. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7835. RefAsync<int> total = 0;
  7836. int diId = 0;
  7837. var status = int.TryParse(dto.GroupName, out diId);
  7838. string sql = string.Format(@"SELECT
  7839. Id,
  7840. TeamName GroupName,
  7841. CASE WHEN EXISTS (
  7842. SELECT
  7843. 1
  7844. FROM
  7845. Grp_EnterExitCost
  7846. WHERE
  7847. IsDel = 0
  7848. AND DiId = di.Id
  7849. ) THEN 1 ELSE 0 END AS [IsNull],
  7850. CASE WHEN EXISTS(
  7851. SELECT
  7852. TOP 1 *
  7853. FROM
  7854. Grp_EnterExitCost
  7855. WHERE
  7856. IsDel = 0
  7857. AND DiId = di.Id
  7858. AND CreateUserId = {0}
  7859. ORDER BY
  7860. CreateTime DESC
  7861. ) THEN 1 ELSE 0 END AS [IsEdit],
  7862. CASE WHEN EXISTS(
  7863. SELECT
  7864. TOP 1 *
  7865. FROM
  7866. Grp_EnterExitCost
  7867. WHERE
  7868. IsDel = 0
  7869. AND DiId = di.Id
  7870. AND CreateUserId = {0}
  7871. ORDER BY
  7872. CreateTime DESC
  7873. ) THEN 1 WHEN EXISTS(
  7874. SELECT
  7875. TOP 1 *
  7876. FROM
  7877. Grp_EnterExitCostPermission
  7878. WHERE
  7879. IsDel = 0
  7880. AND GroupId = di.Id
  7881. AND Permission = 1
  7882. AND UserId = {0}
  7883. ORDER BY
  7884. CreateTime DESC
  7885. ) THEN 1 ELSE 0 END AS [IsView]
  7886. FROM
  7887. Grp_DelegationInfo di
  7888. WHERE
  7889. di.Isdel = 0 ",dto.CurrUserId);
  7890. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7891. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7892. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7893. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7894. .OrderByDescending(x => x.Id)
  7895. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7896. return Ok(JsonView(true, "查询成功!", data, total));
  7897. }
  7898. /// <summary>
  7899. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7900. /// </summary>
  7901. /// <returns></returns>
  7902. [HttpPost]
  7903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7904. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7905. {
  7906. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7907. RefAsync<int> total = 0;
  7908. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7909. .Where(x => x.IsDel == 0 && x.STid == 66)
  7910. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7911. .Select(x => new
  7912. {
  7913. id = x.Id,
  7914. name = x.Name,
  7915. remark = x.Remark,
  7916. })
  7917. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7918. return Ok(JsonView(true, "查询成功!", data, total));
  7919. }
  7920. /// <summary>
  7921. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7922. /// </summary>
  7923. /// <returns></returns>
  7924. [HttpPost]
  7925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7926. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7927. {
  7928. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7929. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7930. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7931. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7932. var groupOtherRateData = groupRateData.TeamRates;
  7933. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7934. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7935. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7936. groupOtherRateData = groupOtherRateData
  7937. .Select(x => new TeamRateDescAddCurrencyIdView {
  7938. CurrencyId = x.CurrencyId,
  7939. CurrencyName = x.CurrencyName,
  7940. CurrencyCode = x.CurrencyCode,
  7941. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7942. }).ToList();
  7943. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7944. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7945. }
  7946. /// <summary>
  7947. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7948. /// </summary>
  7949. /// <returns></returns>
  7950. [HttpPost]
  7951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7952. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7953. {
  7954. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7955. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7956. var tipsData = new List<int>() {1,2,3 };
  7957. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7958. if (dto.TipsType == 1)
  7959. {
  7960. //默认币种显示
  7961. var _currencyInfos = _currencyInit;
  7962. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7963. List<dynamic> reteInfos = new List<dynamic>();
  7964. if (_currencyRate.Count > 0)
  7965. {
  7966. foreach (var item in _currencyInfos)
  7967. {
  7968. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7969. if (rateInfo != null)
  7970. {
  7971. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7972. decimal rate1 = item.Rate;
  7973. rate1 *= 1.03M;
  7974. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7975. reteInfos.Add(new
  7976. {
  7977. currCode = item.CurrencyCode,
  7978. currName = item.CurrencyName,
  7979. rate = rate2,
  7980. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7981. });
  7982. }
  7983. }
  7984. }
  7985. return Ok(JsonView(true, "查询成功!", reteInfos));
  7986. }
  7987. else if (dto.TipsType == 2)
  7988. {
  7989. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7990. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7991. }
  7992. else if (dto.TipsType == 3)
  7993. {
  7994. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7995. return Ok(JsonView(true, "查询成功!", airData.Data));
  7996. }
  7997. return Ok(JsonView(false));
  7998. }
  7999. /// <summary>
  8000. /// 团组模块 - 出入境国家费用标准-移动端 List
  8001. /// </summary>
  8002. /// <returns></returns>
  8003. [HttpPost]
  8004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8005. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  8006. {
  8007. Stopwatch sw = new Stopwatch();
  8008. sw.Start();
  8009. RefAsync<int> total = 0;
  8010. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  8011. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  8012. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  8013. .Where((ntf, sd, u) => ntf.IsDel == 0)
  8014. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  8015. .Select((ntf, sd, u) => new
  8016. {
  8017. Id = ntf.Id,
  8018. Area = $"{ntf.Country}-{ntf.City}",
  8019. Currency = ntf.Currency,
  8020. CurrencyCode = sd.Name,
  8021. CurrencyName = sd.Remark,
  8022. RoomCost = ntf.RoomCost,
  8023. FoodCost = ntf.FoodCost,
  8024. PublicCost = ntf.PublicCost,
  8025. LastUpdateUserId = ntf.LastUpdateUserId,
  8026. LastUpdateUserName = u.CnName,
  8027. LastUpdateTime = ntf.LastUpdateTime,
  8028. })
  8029. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  8030. sw.Stop();
  8031. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  8032. }
  8033. /// <summary>
  8034. /// 团组模块 - 出入境费用-移动端 - Info
  8035. /// </summary>
  8036. /// <returns></returns>
  8037. [HttpPost]
  8038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8039. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  8040. {
  8041. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8042. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8043. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  8044. return Ok(data);
  8045. }
  8046. /// <summary>
  8047. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  8048. /// </summary>
  8049. /// <returns></returns>
  8050. [HttpPost]
  8051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8052. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8053. {
  8054. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8055. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8056. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8057. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8058. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8059. mobileInfo.DiId = dto.DiId;
  8060. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8061. if (eecInfo == null) return Ok(mobileInfo);
  8062. //验证查看权限
  8063. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8064. if (!isView) return Ok(JsonView(false, msg));
  8065. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8066. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8067. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8068. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8069. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8070. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8071. {
  8072. SubId = dac.Id,
  8073. DiId = dac.DiId,
  8074. Type = dac.Type,
  8075. Days = dac.Days,
  8076. NationalTravelFeeId = dac.NationalTravelFeeId,
  8077. Arae = $"{ntf.Country}-{ntf.City}",
  8078. Cost = dac.Cost,
  8079. Currency = dac.Currency,
  8080. CurrencyName = sd.Name,
  8081. SubTotal = dac.SubTotal,
  8082. })
  8083. .ToList();
  8084. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8085. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8086. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8087. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8088. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8089. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8090. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8091. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8092. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8093. //其他款项
  8094. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8095. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8096. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8097. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8098. .OrderBy((dop, sd1, sd2) => dop.Index)
  8099. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8100. {
  8101. SubId = dop.Id,
  8102. DiId = dop.Diid,
  8103. Index = dop.Index,
  8104. SetDataId = dop.SetDataId,
  8105. SetDataName = sd1.Name,
  8106. Cost = dop.Cost,
  8107. Currency = dop.Currency,
  8108. CurrencyName = sd2.Remark,
  8109. SubTotal = dop.SubTotal,
  8110. Remark = dop.Remark,
  8111. })
  8112. .ToArray();
  8113. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8114. return Ok(mobileInfo);
  8115. }
  8116. /// <summary>
  8117. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8118. /// </summary>
  8119. /// <returns></returns>
  8120. [HttpPost]
  8121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8122. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8123. {
  8124. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8125. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8126. //验证查看权限
  8127. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8128. if (!isView) return Ok(JsonView(false, msg));
  8129. var userIds = Array.Empty<int>();
  8130. userIds = await _sqlSugar
  8131. .Queryable<Grp_EnterExitCostPermission>()
  8132. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8133. .Select(x => x.UserId)
  8134. .ToArrayAsync();
  8135. return Ok(userIds);
  8136. }
  8137. /// <summary>
  8138. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8139. /// </summary>
  8140. /// <returns></returns>
  8141. [HttpPost]
  8142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8143. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8144. {
  8145. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8146. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8147. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8148. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8149. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8150. //验证查看权限
  8151. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8152. if (!isView) return Ok(JsonView(false, msg));
  8153. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8154. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8155. var subType = dto.SubType;
  8156. if (subType == 1) //1:境内费用
  8157. {
  8158. var oneData = new ChoiceOneMobileSubInfoView()
  8159. {
  8160. Id = eecInfo.Id,
  8161. ChoiceOne = eecInfo.ChoiceOne,
  8162. ChoiceOneTotalCost = eecInfo.InsidePay,
  8163. Visa = eecInfo.Visa,
  8164. VisaRemark = eecInfo.VisaRemark,
  8165. YiMiao = eecInfo.YiMiao,
  8166. HeSuan = eecInfo.HeSuan,
  8167. Service = eecInfo.Service,
  8168. Ticket = eecInfo.Ticket,
  8169. Safe = eecInfo.Safe,
  8170. FirstItemRemark = eecInfo.FirstItemRemark
  8171. };
  8172. return Ok(JsonView(oneData));
  8173. }
  8174. else if (subType == 2) //2:国际旅费
  8175. {
  8176. var twoData = new ChoiceTwoMobileSubInfoView() {
  8177. Id = eecInfo.Id,
  8178. ChoiceTwoJJ = eecInfo.SumJJC,
  8179. OutsideJJPay = eecInfo.OutsideJJPay,
  8180. ChoiceTwoGW = eecInfo.SumGWC,
  8181. OutsideGWPay = eecInfo.OutsideGWPay,
  8182. ChoiceTwoTD = eecInfo.SumTDC,
  8183. OutsideTDPay = eecInfo.OutsideTDPay,
  8184. AirJJ = eecInfo.AirJJ,
  8185. AirGW = eecInfo.AirGW,
  8186. AirTD = eecInfo.AirTD,
  8187. CityTranffic = eecInfo.CityTranffic,
  8188. TwoItemRemark = eecInfo.TwoItemRemark
  8189. };
  8190. return Ok(JsonView(twoData));
  8191. }
  8192. else if (subType == 3) //3:住宿费
  8193. {
  8194. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8195. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8196. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8197. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8198. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8199. {
  8200. SubId = dac.Id,
  8201. DiId = dac.DiId,
  8202. Type = dac.Type,
  8203. Days = dac.Days,
  8204. NationalTravelFeeId = dac.NationalTravelFeeId,
  8205. Arae = $"{ntf.Country}-{ntf.City}",
  8206. Cost = dac.Cost,
  8207. Currency = dac.Currency,
  8208. CurrencyName = sd.Name,
  8209. SubTotal = dac.SubTotal,
  8210. })
  8211. .ToArray();
  8212. var data = new ChoiceMobileSubInfo3To6View() {
  8213. ParentId = eecInfo.Id,
  8214. Choice = eecInfo.ChoiceThree,
  8215. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8216. Details = dayAndCostDatas
  8217. };
  8218. return Ok(JsonView(data));
  8219. }
  8220. else if (subType == 4) //4:伙食费
  8221. {
  8222. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8223. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8224. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8225. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8226. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8227. {
  8228. SubId = dac.Id,
  8229. DiId = dac.DiId,
  8230. Type = dac.Type,
  8231. Days = dac.Days,
  8232. NationalTravelFeeId = dac.NationalTravelFeeId,
  8233. Arae = $"{ntf.Country}-{ntf.City}",
  8234. Cost = dac.Cost,
  8235. Currency = dac.Currency,
  8236. CurrencyName = sd.Name,
  8237. SubTotal = dac.SubTotal,
  8238. })
  8239. .ToArray();
  8240. var data = new ChoiceMobileSubInfo3To6View()
  8241. {
  8242. ParentId = eecInfo.Id,
  8243. Choice = eecInfo.ChoiceFour,
  8244. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8245. Details = dayAndCostDatas
  8246. };
  8247. return Ok(JsonView(data));
  8248. }
  8249. else if (subType == 5) //5:公杂费
  8250. {
  8251. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8252. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8253. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8254. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8255. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8256. {
  8257. SubId = dac.Id,
  8258. DiId = dac.DiId,
  8259. Type = dac.Type,
  8260. Days = dac.Days,
  8261. NationalTravelFeeId = dac.NationalTravelFeeId,
  8262. Arae = $"{ntf.Country}-{ntf.City}",
  8263. Cost = dac.Cost,
  8264. Currency = dac.Currency,
  8265. CurrencyName = sd.Name,
  8266. SubTotal = dac.SubTotal,
  8267. })
  8268. .ToArray();
  8269. var data = new ChoiceMobileSubInfo3To6View()
  8270. {
  8271. ParentId = eecInfo.Id,
  8272. Choice = eecInfo.ChoiceFive,
  8273. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8274. Details = dayAndCostDatas
  8275. };
  8276. return Ok(JsonView(data));
  8277. }
  8278. else if (subType == 6) //6:培训费
  8279. {
  8280. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8281. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8282. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8283. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8284. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8285. {
  8286. SubId = dac.Id,
  8287. DiId = dac.DiId,
  8288. Type = dac.Type,
  8289. Days = dac.Days,
  8290. NationalTravelFeeId = dac.NationalTravelFeeId,
  8291. Arae = $"{ntf.Country}-{ntf.City}",
  8292. Cost = dac.Cost,
  8293. Currency = dac.Currency,
  8294. CurrencyName = sd.Name,
  8295. SubTotal = dac.SubTotal,
  8296. })
  8297. .ToArray();
  8298. var data = new ChoiceMobileSubInfo3To6View()
  8299. {
  8300. ParentId = eecInfo.Id,
  8301. Choice = eecInfo.ChoiceSix,
  8302. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8303. Details = dayAndCostDatas
  8304. };
  8305. return Ok(JsonView(data));
  8306. }
  8307. else if (subType == 7) //7:其他
  8308. {
  8309. //其他款项
  8310. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8311. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8312. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8313. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8314. .OrderBy((dop, sd1, sd2) => dop.Index)
  8315. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8316. {
  8317. SubId = dop.Id,
  8318. DiId = dop.Diid,
  8319. Index = dop.Index,
  8320. SetDataId = dop.SetDataId,
  8321. SetDataName = sd1.Name,
  8322. Cost = dop.Cost,
  8323. Currency = dop.Currency,
  8324. CurrencyName = sd2.Name,
  8325. SubTotal = dop.SubTotal,
  8326. Remark = dop.Remark,
  8327. })
  8328. .ToArray();
  8329. var data = new ChoiceSevenMobileSubInfoView()
  8330. {
  8331. ParentId = eecInfo.Id,
  8332. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8333. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8334. Details = otherData
  8335. };
  8336. return Ok(JsonView(data));
  8337. }
  8338. return Ok(JsonView(false));
  8339. }
  8340. #region op
  8341. /// <summary>
  8342. /// 移动端更新费用消息通知
  8343. /// </summary>
  8344. /// <param name="diid"></param>
  8345. /// <param name="id"></param>
  8346. /// <param name="currUserId"></param>
  8347. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8348. {
  8349. try
  8350. {
  8351. ////生成默认文件pdf并且通知人员
  8352. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8353. //{
  8354. // DiId = diid,
  8355. // ExportType = 1,
  8356. // SubTypeId = 1005
  8357. //}, "pdf");
  8358. ////发送通知
  8359. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8360. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8361. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8362. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8363. ////汇率信息记录
  8364. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8365. }
  8366. catch (Exception ex)
  8367. {
  8368. //记录日志
  8369. throw;
  8370. }
  8371. }
  8372. /// <summary>
  8373. /// 验证出入境费用数据是否存在
  8374. /// 不存在添加
  8375. /// </summary>
  8376. /// <param name="diId"></param>
  8377. /// <param name="currUserId"></param>
  8378. /// <returns></returns>
  8379. /// <exception cref="CustomException"></exception>
  8380. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8381. {
  8382. var parentId = 0;
  8383. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8384. if (info != null) {
  8385. parentId = info.Id;
  8386. }
  8387. else
  8388. {
  8389. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8390. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8391. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8392. parentId = addId;
  8393. }
  8394. return parentId;
  8395. }
  8396. /// <summary>
  8397. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8398. /// </summary>
  8399. /// <returns></returns>
  8400. [HttpPost]
  8401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8402. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8403. {
  8404. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8405. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8406. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8407. //验证编辑权限
  8408. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8409. if (!isEdit) return Ok(JsonView(false, msg));
  8410. var permissions = new List<Grp_EnterExitCostPermission>();
  8411. foreach (var userId in dto.UserIds)
  8412. {
  8413. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8414. }
  8415. if (permissions.Any())
  8416. {
  8417. _sqlSugar.BeginTran();
  8418. try
  8419. {
  8420. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8421. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8422. if (result < 1)
  8423. {
  8424. _sqlSugar.RollbackTran();
  8425. return Ok(JsonView(false));
  8426. }
  8427. }
  8428. catch (Exception ex)
  8429. {
  8430. _sqlSugar.RollbackTran();
  8431. return Ok(JsonView(false, ex.Message));
  8432. }
  8433. _sqlSugar.CommitTran();
  8434. return Ok(JsonView(true));
  8435. }
  8436. return Ok(JsonView(false));
  8437. }
  8438. /// <summary>
  8439. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8440. /// </summary>
  8441. /// <returns></returns>
  8442. [HttpPost]
  8443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8444. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8445. {
  8446. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8447. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8448. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8449. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8450. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8451. int id = dto.Id;
  8452. if (id <= 0) //add
  8453. {
  8454. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8455. if (add < 1) return Ok(JsonView(false));
  8456. id = add;
  8457. }
  8458. else //update
  8459. {
  8460. //验证编辑权限
  8461. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8462. if (!isEdit) return Ok(JsonView(false, msg));
  8463. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8464. if (upd < 1) return Ok(JsonView(false));
  8465. }
  8466. #region 汇率变更时更改币种相关费用
  8467. var opDayCosts = new List<Grp_DayAndCost>();
  8468. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8469. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8470. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8471. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8472. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8473. .Select((dac, sd) => new {
  8474. dac.Id,
  8475. dac.DiId,
  8476. CurrencyCode = sd.Name,
  8477. dac.Cost
  8478. })
  8479. .ToList();
  8480. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8481. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8482. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8483. .Select((dop, sd) => new {
  8484. dop.Id,
  8485. dop.Diid,
  8486. CurrencyCode = sd.Name,
  8487. dop.Cost
  8488. })
  8489. .ToList();
  8490. if (dayCosts.Count > 0)
  8491. {
  8492. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8493. foreach (var dc in new_dayCosts)
  8494. {
  8495. var thisCurrency = dc.Key.ToUpper();
  8496. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8497. if (thisRate == 0.00M) continue;
  8498. foreach (var dcSub in dc)
  8499. {
  8500. opDayCosts.Add(new Grp_DayAndCost() {
  8501. Id = dcSub.Id,
  8502. DiId = dcSub.DiId,
  8503. Cost = dcSub.Cost,
  8504. SubTotal = dcSub.Cost * thisRate,
  8505. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8506. });
  8507. }
  8508. }
  8509. if (opDayCosts.Count > 0)
  8510. {
  8511. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8512. }
  8513. }
  8514. if (dayOtherCosts.Count > 0)
  8515. {
  8516. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8517. foreach (var dc in new_dayOtherCosts)
  8518. {
  8519. var thisCurrency = dc.Key.ToUpper();
  8520. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8521. if (thisRate == 0.00M) continue;
  8522. foreach (var dcSub in dc)
  8523. {
  8524. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8525. {
  8526. Id = dcSub.Id,
  8527. Diid = dcSub.Diid,
  8528. Cost = dcSub.Cost,
  8529. SubTotal = dcSub.Cost * thisRate,
  8530. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8531. });
  8532. }
  8533. }
  8534. if (opDayOtherCosts.Count > 0)
  8535. {
  8536. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8537. }
  8538. }
  8539. #endregion
  8540. //消息通知
  8541. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8542. //汇率信息记录
  8543. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8544. return Ok(JsonView(new { parentId = id }));
  8545. }
  8546. /// <summary>
  8547. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8548. /// </summary>
  8549. /// <returns></returns>
  8550. [HttpPost]
  8551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8552. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8553. {
  8554. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8555. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8556. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8557. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8558. int id = dto.Id;
  8559. if (id <= 0) //add
  8560. {
  8561. checkboxInfo.CreateUserId = dto.CurrUserId;
  8562. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8563. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8564. if (add < 1) return Ok(JsonView(false));
  8565. }
  8566. else //update
  8567. {
  8568. //验证编辑权限
  8569. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8570. if (!isEdit) return Ok(JsonView(false, msg));
  8571. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8572. .UpdateColumns(x => new {
  8573. x.ChoiceOne,
  8574. x.ChoiceTwo,
  8575. x.SumJJC,
  8576. x.SumGWC,
  8577. x.SumTDC,
  8578. x.ChoiceThree,
  8579. x.ChoiceFour,
  8580. x.ChoiceFive,
  8581. x.ChoiceSix,
  8582. x.OtherExpenses_Checked
  8583. })
  8584. .Where(x => x.Id == id)
  8585. .ExecuteCommandAsync();
  8586. if (upd < 1) return Ok(JsonView(false));
  8587. }
  8588. return Ok(JsonView(new { parentId = id }));
  8589. }
  8590. /// <summary>
  8591. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8592. /// </summary>
  8593. /// <returns></returns>
  8594. [HttpPost]
  8595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8596. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8597. {
  8598. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8599. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8600. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8601. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8602. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8603. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8604. var checkboxInfo = new Grp_EnterExitCost() {
  8605. Id = id,
  8606. DiId = diId,
  8607. CreateUserId = currUserId
  8608. };
  8609. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8610. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8611. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8612. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8613. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8614. if (id <= 0) //add
  8615. {
  8616. checkboxInfo.CreateUserId = dto.CurrUserId;
  8617. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8618. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8619. if (add < 1) return Ok(JsonView(false));
  8620. }
  8621. else //update
  8622. {
  8623. //验证编辑权限
  8624. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8625. if (!isEdit) return Ok(JsonView(false, msg));
  8626. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8627. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8628. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8629. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8630. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8631. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8632. .Where(x => x.Id == id)
  8633. .ExecuteCommandAsync();
  8634. if (upd < 1) return Ok(JsonView(false));
  8635. }
  8636. return Ok(JsonView(new { parentId = id }));
  8637. }
  8638. /// <summary>
  8639. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8640. /// </summary>
  8641. /// <returns></returns>
  8642. [HttpPost]
  8643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8644. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8645. {
  8646. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8647. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8648. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8649. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8650. info.FirstItemRemark = dto.FirstItemRemark;
  8651. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8652. int id = dto.Id;
  8653. if (id <= 0) //add
  8654. {
  8655. info.CreateUserId = dto.CurrUserId;
  8656. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8657. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8658. if (add < 1) return Ok(JsonView(false));
  8659. id = add;
  8660. }
  8661. else //update
  8662. {
  8663. //验证编辑权限
  8664. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8665. if (!isEdit) return Ok(JsonView(false, msg));
  8666. var upd = await _sqlSugar.Updateable(info)
  8667. .UpdateColumns(x => new {
  8668. x.ChoiceOne,
  8669. x.InsidePay,
  8670. x.VisaRemark,
  8671. x.Visa,
  8672. x.Service,
  8673. x.Safe,
  8674. x.Ticket,
  8675. x.HeSuan,
  8676. x.YiMiao,
  8677. x.FirstItemRemark
  8678. })
  8679. .Where(x => x.Id == id)
  8680. .ExecuteCommandAsync();
  8681. if (upd < 1) return Ok(JsonView(false));
  8682. }
  8683. //消息通知
  8684. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8685. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8686. }
  8687. /// <summary>
  8688. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8689. /// </summary>
  8690. /// <returns></returns>
  8691. [HttpPost]
  8692. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8693. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8694. {
  8695. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8696. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8697. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8698. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8699. info.OutsideJJPay = dto.OutsideJJPay;
  8700. info.OutsideGWPay = dto.OutsideGWPay;
  8701. info.OutsideTDPay = dto.OutsideTDPay;
  8702. info.AirJJ = dto.AirJJ;
  8703. info.AirGW = dto.AirGW;
  8704. info.AirTD = dto.AirTD;
  8705. info.CityTranffic = dto.CityTranffic;
  8706. info.TwoItemRemark = dto.TwoItemRemark;
  8707. info.SumJJC = dto.ChoiceTwoJJ;
  8708. info.SumGWC = dto.ChoiceTwoGW;
  8709. info.SumTDC = dto.ChoiceTwoTD;
  8710. int id = dto.Id;
  8711. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8712. if (id <= 0) //add
  8713. {
  8714. info.CreateUserId = dto.CurrUserId;
  8715. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8716. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8717. if (addId <= 0) return Ok(JsonView(false));
  8718. id = addId;
  8719. }
  8720. else //update
  8721. {
  8722. //验证编辑权限
  8723. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8724. if (!isEdit) return Ok(JsonView(false, msg));
  8725. var upd = await _sqlSugar.Updateable(info)
  8726. .UpdateColumns(x => new {
  8727. x.SumJJC,
  8728. x.OutsideJJPay,
  8729. x.SumGWC,
  8730. x.OutsideGWPay,
  8731. x.SumTDC,
  8732. x.OutsideTDPay,
  8733. x.AirJJ,
  8734. x.AirGW,
  8735. x.AirTD,
  8736. x.CityTranffic,
  8737. x.TwoItemRemark
  8738. })
  8739. .Where(x => x.Id == id)
  8740. .ExecuteCommandAsync();
  8741. if (upd <1) return Ok(JsonView(false));
  8742. }
  8743. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8744. gwcItemTotal = info.AirGW + info.CityTranffic;
  8745. tdcItemTotal = info.AirTD + info.CityTranffic;
  8746. //消息通知
  8747. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8748. return Ok(JsonView(new
  8749. {
  8750. parentId = id,
  8751. choiceTwoJJ = dto.ChoiceTwoJJ,
  8752. jjcItemTotal = jjcItemTotal,
  8753. choiceTwoGW = dto.ChoiceTwoGW,
  8754. gwcItemTotal = gwcItemTotal,
  8755. choiceTwoTD = dto.ChoiceTwoTD,
  8756. tdcItemTotal = tdcItemTotal
  8757. }));
  8758. }
  8759. /// <summary>
  8760. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8761. /// </summary>
  8762. /// <returns></returns>
  8763. [HttpPost]
  8764. [ApiExplorerSettings(IgnoreApi = true)]
  8765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8766. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8767. {
  8768. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8769. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8770. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8771. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8772. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8773. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8774. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8775. var infos = infos1.Select(x => new Grp_DayAndCost
  8776. {
  8777. Id = x.Id,
  8778. DiId = dto.DiId,
  8779. Type = dto.FeeType,
  8780. Days = x.Days,
  8781. NationalTravelFeeId = x.NationalTravelFeeId,
  8782. Cost = x.Cost,
  8783. Currency = x.Currency,
  8784. SubTotal = x.SubTotal,
  8785. CreateUserId = dto.CurrUserId
  8786. })
  8787. .ToList();
  8788. var adds = infos.Where(x => x.Id <= 0).ToList();
  8789. var upds = infos.Where(x => x.Id > 0).ToList();
  8790. if (adds.Count > 0)
  8791. {
  8792. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8793. if (add < 1) return Ok(JsonView(false));
  8794. }
  8795. if (upds.Count > 0)
  8796. {
  8797. var upd = await _sqlSugar.Updateable(adds)
  8798. .UpdateColumns(x => new
  8799. {
  8800. x.Days,
  8801. x.NationalTravelFeeId,
  8802. x.Cost,
  8803. x.Currency,
  8804. x.SubTotal
  8805. })
  8806. .WhereColumns(x => new { x.Id })
  8807. .ExecuteCommandAsync();
  8808. if (upd < 1) return Ok(JsonView(false));
  8809. }
  8810. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8811. //消息通知
  8812. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8813. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8814. return Ok(JsonView(new { itemTotal = itemTotal }));
  8815. }
  8816. /// <summary>
  8817. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8818. /// </summary>
  8819. /// <returns></returns>
  8820. [HttpPost]
  8821. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8822. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8823. {
  8824. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8825. int subId = dto.SubId, feeType = dto.FeeType;
  8826. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8827. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8828. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8829. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8830. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8831. subInfo.Id = subId;
  8832. subInfo.DiId = dto.DiId;
  8833. if (feeType == 3) subInfo.Type = 1;
  8834. else if (feeType == 4) subInfo.Type = 2;
  8835. else if (feeType == 5) subInfo.Type = 3;
  8836. else if (feeType == 6) subInfo.Type = 4;
  8837. subInfo.CreateUserId = dto.CurrUserId;
  8838. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8839. if (parentId < 1) return Ok(JsonView(false));
  8840. //子表op
  8841. if (subId < 1)
  8842. {
  8843. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8844. if (subAdd < 1) return Ok(JsonView(false));
  8845. }
  8846. else
  8847. {
  8848. //验证编辑权限
  8849. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8850. if (!isEdit) return Ok(JsonView(false, msg));
  8851. var subUpd = await _sqlSugar.Updateable(subInfo)
  8852. .UpdateColumns(x => new
  8853. {
  8854. x.Days,
  8855. x.NationalTravelFeeId,
  8856. x.Cost,
  8857. x.Currency,
  8858. x.SubTotal
  8859. })
  8860. .WhereColumns(x => new { x.Id })
  8861. .ExecuteCommandAsync();
  8862. if (subUpd < 1) return Ok(JsonView(false));
  8863. }
  8864. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8865. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8866. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8867. }
  8868. /// <summary>
  8869. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8870. /// </summary>
  8871. /// <returns></returns>
  8872. [HttpPost]
  8873. [ApiExplorerSettings(IgnoreApi = true)]
  8874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8875. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8876. {
  8877. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8878. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8879. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8880. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8881. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8882. {
  8883. Id = x.Id,
  8884. Diid = dto.DiId,
  8885. SetDataId = x.SetDataId,
  8886. Index = x.Index,
  8887. Cost = x.Cost,
  8888. Currency = x.Currency,
  8889. SubTotal = x.SubTotal,
  8890. CreateUserId = dto.CurrUserId,
  8891. Remark = x.Remark
  8892. }).ToList();
  8893. var adds = infos.Where(x => x.Id <= 0).ToList();
  8894. var upds = infos.Where(x => x.Id > 0).ToList();
  8895. if (adds.Count > 0)
  8896. {
  8897. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8898. if (add < 1) return Ok(JsonView(false));
  8899. }
  8900. if (upds.Count > 0)
  8901. {
  8902. var upd = await _sqlSugar.Updateable(adds)
  8903. .UpdateColumns(x => new
  8904. {
  8905. x.Index,
  8906. x.SetDataId,
  8907. x.Cost,
  8908. x.Currency,
  8909. x.SubTotal,
  8910. x.Remark
  8911. })
  8912. .WhereColumns(x => new { x.Id })
  8913. .ExecuteCommandAsync();
  8914. if (upd < 1) return Ok(JsonView(false));
  8915. }
  8916. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8917. //消息通知
  8918. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8919. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8920. return Ok(JsonView(new { itemTotal = itemTotal }));
  8921. }
  8922. /// <summary>
  8923. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8924. /// </summary>
  8925. /// <returns></returns>
  8926. [HttpPost]
  8927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8928. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8929. {
  8930. int subId = dto.SubId;
  8931. int diId = dto.Diid;
  8932. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8933. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8934. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8935. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8936. subInfo.Id = subId;
  8937. subInfo.Diid = dto.Diid;
  8938. subInfo.CreateUserId = dto.CurrUserId;
  8939. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8940. if (parentId < 1) return Ok(JsonView(false));
  8941. #region 子表op
  8942. if (subId < 1)//add
  8943. {
  8944. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8945. if (subAdd < 1) return Ok(JsonView(false));
  8946. }
  8947. else //upd
  8948. {
  8949. //验证编辑权限
  8950. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8951. if (!isEdit) return Ok(JsonView(false, msg));
  8952. var subUpd = await _sqlSugar.Updateable(subInfo)
  8953. .UpdateColumns(x => new
  8954. {
  8955. x.Index,
  8956. x.SetDataId,
  8957. x.Cost,
  8958. x.Currency,
  8959. x.SubTotal,
  8960. x.Remark
  8961. })
  8962. .WhereColumns(x => new { x.Id })
  8963. .ExecuteCommandAsync();
  8964. if (subUpd < 1) return Ok(JsonView(false));
  8965. }
  8966. #endregion
  8967. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8968. //消息通知
  8969. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8970. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8971. }
  8972. /// <summary>
  8973. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8974. /// </summary>
  8975. /// <returns></returns>
  8976. [HttpPost]
  8977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8978. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8979. {
  8980. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8981. if (data.Code != 0)
  8982. {
  8983. return Ok(JsonView(false, data.Msg));
  8984. }
  8985. return Ok(JsonView(true, "操作成功!", data.Data));
  8986. }
  8987. /// <summary>
  8988. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8989. /// </summary>
  8990. /// <param name="dto"></param>
  8991. /// <returns></returns>
  8992. [HttpPost]
  8993. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8994. {
  8995. var data = new Grp_DayOtherPrice()
  8996. {
  8997. Id = dto.Id,
  8998. IsDel = 1,
  8999. DeleteUserId = dto.DeleteUserId,
  9000. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9001. };
  9002. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9003. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  9004. return Ok(JsonView(false,"删除失败!"));
  9005. }
  9006. #endregion
  9007. #endregion
  9008. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  9009. /// <summary>
  9010. /// 出入境费用-草稿 移动端
  9011. /// 获取币种基础数据(含逻辑处理)
  9012. /// </summary>
  9013. /// <returns></returns>
  9014. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  9015. {
  9016. //默认币种显示
  9017. var _currencyInfos = _currencyInit;
  9018. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  9019. if (_currencyRate.Count > 0)
  9020. {
  9021. foreach (var item in _currencyInfos)
  9022. {
  9023. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9024. if (rateInfo != null)
  9025. {
  9026. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  9027. rate1 *= 1.035M;
  9028. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9029. }
  9030. }
  9031. }
  9032. return _currencyInfos;
  9033. }
  9034. /// <summary>
  9035. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  9036. /// </summary>
  9037. /// <returns></returns>
  9038. [HttpPost]
  9039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9040. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  9041. {
  9042. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9043. //SetDataInfoView
  9044. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  9045. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  9046. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  9047. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  9048. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  9049. //默认币种显示
  9050. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  9051. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9052. return Ok(JsonView(true, "查询成功!", new
  9053. {
  9054. WordTypeData = _WordTypeData,
  9055. ExcelTypeData = _ExcelTypeData,
  9056. CurrencyInit = _currencyInfos,
  9057. viewPermissionData= viewPermissionData
  9058. }));
  9059. }
  9060. /// <summary>
  9061. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9062. /// </summary>
  9063. /// <returns></returns>
  9064. [HttpPost]
  9065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9066. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9067. {
  9068. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9069. RefAsync<int> total = 0;
  9070. int diId = 0;
  9071. var status = int.TryParse(dto.GroupName, out diId);
  9072. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9073. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9074. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9075. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9076. .Select(x => new
  9077. {
  9078. Id = x.Id,
  9079. GroupName = x.TeamName
  9080. })
  9081. .OrderByDescending(x => x.Id)
  9082. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9083. return Ok(JsonView(true, "查询成功!", data, total));
  9084. }
  9085. /// <summary>
  9086. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9087. /// </summary>
  9088. /// <returns></returns>
  9089. [HttpPost]
  9090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9091. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9092. {
  9093. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9094. RefAsync<int> total = 0;
  9095. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9096. .Where(x => x.IsDel == 0 && x.STid == 66)
  9097. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9098. .Select(x => new
  9099. {
  9100. id = x.Id,
  9101. name = x.Name,
  9102. remark = x.Remark,
  9103. })
  9104. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9105. return Ok(JsonView(true, "查询成功!", data, total));
  9106. }
  9107. /// <summary>
  9108. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9109. /// </summary>
  9110. /// <returns></returns>
  9111. [HttpPost]
  9112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9113. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9114. {
  9115. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9116. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9117. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9118. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9119. var groupOtherRateData = groupRateData.TeamRates;
  9120. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9121. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9122. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9123. groupOtherRateData = groupOtherRateData
  9124. .Select(x => new TeamRateDescAddCurrencyIdView
  9125. {
  9126. CurrencyId = x.CurrencyId,
  9127. CurrencyName = x.CurrencyName,
  9128. CurrencyCode = x.CurrencyCode,
  9129. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9130. }).ToList();
  9131. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9132. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9133. }
  9134. /// <summary>
  9135. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9136. /// </summary>
  9137. /// <returns></returns>
  9138. [HttpPost]
  9139. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9140. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9141. {
  9142. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9143. var tipsData = new List<int>() { 1, 2, 3 };
  9144. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9145. if (dto.TipsType == 1)
  9146. {
  9147. //默认币种显示
  9148. var _currencyInfos = _currencyInit;
  9149. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  9150. List<dynamic> reteInfos = new List<dynamic>();
  9151. if (_currencyRate.Count > 0)
  9152. {
  9153. foreach (var item in _currencyInfos)
  9154. {
  9155. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9156. if (rateInfo != null)
  9157. {
  9158. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9159. decimal rate1 = item.Rate;
  9160. rate1 *= 1.03M;
  9161. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9162. reteInfos.Add(new
  9163. {
  9164. currCode = item.CurrencyCode,
  9165. currName = item.CurrencyName,
  9166. rate = rate2,
  9167. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9168. });
  9169. }
  9170. }
  9171. }
  9172. return Ok(JsonView(true, "查询成功!", reteInfos));
  9173. }
  9174. else if (dto.TipsType == 2)
  9175. {
  9176. }
  9177. else if (dto.TipsType == 3)
  9178. {
  9179. }
  9180. return Ok(JsonView(false));
  9181. }
  9182. /// <summary>
  9183. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9184. /// </summary>
  9185. /// <returns></returns>
  9186. [HttpPost]
  9187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9188. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9189. {
  9190. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9191. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9192. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9193. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9194. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9195. if (eecInfo == null) return Ok(mobileInfo);
  9196. //验证查看权限
  9197. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9198. if (!isView) return Ok(JsonView(false, msg));
  9199. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9200. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9201. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9202. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9203. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9204. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9205. {
  9206. ParentId = dac.ParentId,
  9207. SubId = dac.Id,
  9208. Type = dac.Type,
  9209. Days = dac.Days,
  9210. NationalTravelFeeId = dac.NationalTravelFeeId,
  9211. Arae = $"{ntf.Country}-{ntf.City}",
  9212. Cost = dac.Cost,
  9213. Currency = dac.Currency,
  9214. CurrencyName = sd.Name,
  9215. SubTotal = dac.SubTotal,
  9216. })
  9217. .ToList();
  9218. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9219. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9220. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9221. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9222. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9223. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9224. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9225. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9226. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9227. //其他款项
  9228. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9229. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9230. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9231. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9232. .OrderBy((dop, sd1, sd2) => dop.Index)
  9233. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9234. {
  9235. ParentId = dop.ParentId,
  9236. SubId = dop.Id,
  9237. Index = dop.Index,
  9238. SetDataId = dop.SetDataId,
  9239. SetDataName = sd1.Name,
  9240. Cost = dop.Cost,
  9241. Currency = dop.Currency,
  9242. CurrencyName = sd2.Remark,
  9243. SubTotal = dop.SubTotal,
  9244. Remark = dop.Remark,
  9245. })
  9246. .ToArray();
  9247. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9248. return Ok(mobileInfo);
  9249. }
  9250. /// <summary>
  9251. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9252. /// </summary>
  9253. /// <returns></returns>
  9254. [HttpPost]
  9255. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9256. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9257. {
  9258. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9259. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9260. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9261. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9262. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9263. //验证查看权限
  9264. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9265. if (!isView) return Ok(JsonView(false, msg));
  9266. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9267. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9268. var subType = dto.SubType;
  9269. if (subType == 1) //1:境内费用
  9270. {
  9271. var oneData = new ChoiceOneMobileSubInfoView()
  9272. {
  9273. Id = eecInfo.Id,
  9274. ChoiceOne = eecInfo.ChoiceOne,
  9275. ChoiceOneTotalCost = eecInfo.InsidePay,
  9276. Visa = eecInfo.Visa,
  9277. VisaRemark = eecInfo.VisaRemark,
  9278. YiMiao = eecInfo.YiMiao,
  9279. HeSuan = eecInfo.HeSuan,
  9280. Service = eecInfo.Service,
  9281. Ticket = eecInfo.Ticket,
  9282. Safe = eecInfo.Safe,
  9283. FirstItemRemark = eecInfo.FirstItemRemark
  9284. };
  9285. return Ok(JsonView(oneData));
  9286. }
  9287. else if (subType == 2) //2:国际旅费
  9288. {
  9289. var twoData = new ChoiceTwoMobileSubInfoView()
  9290. {
  9291. Id = eecInfo.Id,
  9292. ChoiceTwoJJ = eecInfo.SumJJC,
  9293. OutsideJJPay = eecInfo.OutsideJJPay,
  9294. ChoiceTwoGW = eecInfo.SumGWC,
  9295. OutsideGWPay = eecInfo.OutsideGWPay,
  9296. ChoiceTwoTD = eecInfo.SumTDC,
  9297. OutsideTDPay = eecInfo.OutsideTDPay,
  9298. AirJJ = eecInfo.AirJJ,
  9299. AirGW = eecInfo.AirGW,
  9300. AirTD = eecInfo.AirTD,
  9301. CityTranffic = eecInfo.CityTranffic,
  9302. TwoItemRemark = eecInfo.TwoItemRemark
  9303. };
  9304. return Ok(JsonView(twoData));
  9305. }
  9306. else if (subType == 3) //3:住宿费
  9307. {
  9308. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9309. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9310. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9311. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9312. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9313. {
  9314. ParentId = dac.ParentId,
  9315. SubId = dac.Id,
  9316. Type = dac.Type,
  9317. Days = dac.Days,
  9318. NationalTravelFeeId = dac.NationalTravelFeeId,
  9319. Arae = $"{ntf.Country}-{ntf.City}",
  9320. Cost = dac.Cost,
  9321. Currency = dac.Currency,
  9322. CurrencyName = sd.Name,
  9323. SubTotal = dac.SubTotal,
  9324. })
  9325. .ToArray();
  9326. var data = new ChoiceDraftMobileSubInfo3To6View()
  9327. {
  9328. ParentId = eecInfo.Id,
  9329. Choice = eecInfo.ChoiceThree,
  9330. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9331. Details = dayAndCostDatas
  9332. };
  9333. return Ok(JsonView(data));
  9334. }
  9335. else if (subType == 4) //4:伙食费
  9336. {
  9337. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9338. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9339. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9340. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9341. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9342. {
  9343. ParentId = dac.ParentId,
  9344. SubId = dac.Id,
  9345. Type = dac.Type,
  9346. Days = dac.Days,
  9347. NationalTravelFeeId = dac.NationalTravelFeeId,
  9348. Arae = $"{ntf.Country}-{ntf.City}",
  9349. Cost = dac.Cost,
  9350. Currency = dac.Currency,
  9351. CurrencyName = sd.Name,
  9352. SubTotal = dac.SubTotal,
  9353. })
  9354. .ToArray();
  9355. var data = new ChoiceDraftMobileSubInfo3To6View()
  9356. {
  9357. ParentId = eecInfo.Id,
  9358. Choice = eecInfo.ChoiceFour,
  9359. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9360. Details = dayAndCostDatas
  9361. };
  9362. return Ok(JsonView(data));
  9363. }
  9364. else if (subType == 5) //5:公杂费
  9365. {
  9366. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9367. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9368. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9369. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9370. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9371. {
  9372. ParentId = dac.ParentId,
  9373. SubId = dac.Id,
  9374. Type = dac.Type,
  9375. Days = dac.Days,
  9376. NationalTravelFeeId = dac.NationalTravelFeeId,
  9377. Arae = $"{ntf.Country}-{ntf.City}",
  9378. Cost = dac.Cost,
  9379. Currency = dac.Currency,
  9380. CurrencyName = sd.Name,
  9381. SubTotal = dac.SubTotal,
  9382. })
  9383. .ToArray();
  9384. var data = new ChoiceDraftMobileSubInfo3To6View()
  9385. {
  9386. ParentId = eecInfo.Id,
  9387. Choice = eecInfo.ChoiceFive,
  9388. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9389. Details = dayAndCostDatas
  9390. };
  9391. return Ok(JsonView(data));
  9392. }
  9393. else if (subType == 6) //6:培训费
  9394. {
  9395. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9396. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9397. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9398. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9399. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9400. {
  9401. ParentId = dac.ParentId,
  9402. SubId = dac.Id,
  9403. Type = dac.Type,
  9404. Days = dac.Days,
  9405. NationalTravelFeeId = dac.NationalTravelFeeId,
  9406. Arae = $"{ntf.Country}-{ntf.City}",
  9407. Cost = dac.Cost,
  9408. Currency = dac.Currency,
  9409. CurrencyName = sd.Name,
  9410. SubTotal = dac.SubTotal,
  9411. })
  9412. .ToArray();
  9413. var data = new ChoiceDraftMobileSubInfo3To6View()
  9414. {
  9415. ParentId = eecInfo.Id,
  9416. Choice = eecInfo.ChoiceSix,
  9417. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9418. Details = dayAndCostDatas
  9419. };
  9420. return Ok(JsonView(data));
  9421. }
  9422. else if (subType == 7) //7:其他
  9423. {
  9424. //其他款项
  9425. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9426. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9427. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9428. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9429. .OrderBy((dop, sd1, sd2) => dop.Index)
  9430. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9431. {
  9432. ParentId = dop.ParentId,
  9433. SubId = dop.Id,
  9434. Index = dop.Index,
  9435. SetDataId = dop.SetDataId,
  9436. SetDataName = sd1.Name,
  9437. Cost = dop.Cost,
  9438. Currency = dop.Currency,
  9439. CurrencyName = sd2.Name,
  9440. SubTotal = dop.SubTotal,
  9441. Remark = dop.Remark,
  9442. })
  9443. .ToArray();
  9444. var data = new ChoiceSevenDraftMobileSubInfoView()
  9445. {
  9446. ParentId = eecInfo.Id,
  9447. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9448. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9449. Details = otherData
  9450. };
  9451. return Ok(JsonView(data));
  9452. }
  9453. return Ok(JsonView(false));
  9454. }
  9455. #region op
  9456. /// <summary>
  9457. /// 移动端更新费用消息通知
  9458. /// </summary>
  9459. /// <param name="diid"></param>
  9460. /// <param name="id"></param>
  9461. /// <param name="currUserId"></param>
  9462. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9463. {
  9464. try
  9465. {
  9466. ////生成默认文件pdf并且通知人员
  9467. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9468. //{
  9469. // DiId = draftId,
  9470. // ExportType = 1,
  9471. // SubTypeId = 1005
  9472. //}, "pdf");
  9473. ////发送通知
  9474. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9475. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9476. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9477. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9478. ////汇率信息记录
  9479. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9480. }
  9481. catch (Exception ex)
  9482. {
  9483. //记录日志
  9484. throw;
  9485. }
  9486. }
  9487. /// <summary>
  9488. /// 验证出入境费用数据是否存在
  9489. /// 不存在添加
  9490. /// </summary>
  9491. /// <param name="draftId"></param>
  9492. /// <param name="currUserId"></param>
  9493. /// <returns></returns>
  9494. /// <exception cref="CustomException"></exception>
  9495. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9496. {
  9497. var parentId = 0;
  9498. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9499. if (info != null) parentId = info.Id;
  9500. else
  9501. {
  9502. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9503. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9504. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9505. parentId = addId;
  9506. }
  9507. return parentId;
  9508. }
  9509. /// <summary>
  9510. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9511. /// </summary>
  9512. /// <returns></returns>
  9513. [HttpPost]
  9514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9515. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9516. {
  9517. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9518. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9519. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9520. //验证编辑权限
  9521. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9522. if (!isEdit) return Ok(JsonView(false, msg));
  9523. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9524. foreach (var userId in dto.UserIds)
  9525. {
  9526. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9527. }
  9528. if (permissions.Any())
  9529. {
  9530. _sqlSugar.BeginTran();
  9531. try
  9532. {
  9533. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9534. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9535. if (result < 1)
  9536. {
  9537. _sqlSugar.RollbackTran();
  9538. return Ok(JsonView(false));
  9539. }
  9540. }
  9541. catch (Exception ex)
  9542. {
  9543. _sqlSugar.RollbackTran();
  9544. return Ok(JsonView(false, ex.Message));
  9545. }
  9546. _sqlSugar.CommitTran();
  9547. return Ok(JsonView(true));
  9548. }
  9549. return Ok(JsonView(false));
  9550. }
  9551. /// <summary>
  9552. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9553. /// </summary>
  9554. /// <returns></returns>
  9555. [HttpPost]
  9556. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9557. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9558. {
  9559. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9560. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9561. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9562. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9563. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9564. int id = dto.DraftId;
  9565. if (id <= 0) //add
  9566. {
  9567. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9568. if (add < 1) return Ok(JsonView(false));
  9569. id = add;
  9570. }
  9571. else //update
  9572. {
  9573. //验证编辑权限
  9574. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9575. if (!isEdit) return Ok(JsonView(false, msg));
  9576. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9577. if (upd < 1) return Ok(JsonView(false));
  9578. }
  9579. #region 汇率变更时更改币种相关费用
  9580. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9581. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9582. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9583. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9584. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9585. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9586. .Select((dac, sd) => new
  9587. {
  9588. dac.Id,
  9589. dac.ParentId,
  9590. CurrencyCode = sd.Name,
  9591. dac.Cost
  9592. })
  9593. .ToList();
  9594. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9595. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9596. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9597. .Select((dop, sd) => new
  9598. {
  9599. dop.Id,
  9600. dop.ParentId,
  9601. CurrencyCode = sd.Name,
  9602. dop.Cost
  9603. })
  9604. .ToList();
  9605. if (dayCosts.Count > 0)
  9606. {
  9607. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9608. foreach (var dc in new_dayCosts)
  9609. {
  9610. var thisCurrency = dc.Key.ToUpper();
  9611. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9612. if (thisRate == 0.00M) continue;
  9613. foreach (var dcSub in dc)
  9614. {
  9615. opDayCosts.Add(new Grp_DayAndCostDraft()
  9616. {
  9617. Id = dcSub.Id,
  9618. ParentId = dcSub.ParentId,
  9619. Cost = dcSub.Cost,
  9620. SubTotal = dcSub.Cost * thisRate,
  9621. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9622. });
  9623. }
  9624. }
  9625. if (opDayCosts.Count > 0)
  9626. {
  9627. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9628. }
  9629. }
  9630. if (dayOtherCosts.Count > 0)
  9631. {
  9632. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9633. foreach (var dc in new_dayOtherCosts)
  9634. {
  9635. var thisCurrency = dc.Key.ToUpper();
  9636. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9637. if (thisRate == 0.00M) continue;
  9638. foreach (var dcSub in dc)
  9639. {
  9640. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9641. {
  9642. Id = dcSub.Id,
  9643. ParentId = dcSub.ParentId,
  9644. Cost = dcSub.Cost,
  9645. SubTotal = dcSub.Cost * thisRate,
  9646. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9647. });
  9648. }
  9649. }
  9650. if (opDayOtherCosts.Count > 0)
  9651. {
  9652. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9653. }
  9654. }
  9655. #endregion
  9656. ////消息通知
  9657. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9658. ////汇率信息记录
  9659. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9660. return Ok(JsonView(new { parentId = id }));
  9661. }
  9662. /// <summary>
  9663. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9664. /// </summary>
  9665. /// <returns></returns>
  9666. [HttpPost]
  9667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9668. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9669. {
  9670. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9671. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9672. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9673. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9674. int id = dto.DraftId;
  9675. if (id <= 0) //add
  9676. {
  9677. checkboxInfo.CreateUserId = dto.CurrUserId;
  9678. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9679. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9680. if (add < 1) return Ok(JsonView(false));
  9681. }
  9682. else //update
  9683. {
  9684. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9685. .UpdateColumns(x => new
  9686. {
  9687. x.ChoiceOne,
  9688. x.ChoiceTwo,
  9689. x.SumJJC,
  9690. x.SumGWC,
  9691. x.SumTDC,
  9692. x.ChoiceThree,
  9693. x.ChoiceFour,
  9694. x.ChoiceFive,
  9695. x.ChoiceSix,
  9696. x.OtherExpenses_Checked
  9697. })
  9698. .Where(x => x.Id == id)
  9699. .ExecuteCommandAsync();
  9700. if (upd < 1) return Ok(JsonView(false));
  9701. }
  9702. return Ok(JsonView(new { parentId = id }));
  9703. }
  9704. /// <summary>
  9705. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9706. /// </summary>
  9707. /// <returns></returns>
  9708. [HttpPost]
  9709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9710. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9711. {
  9712. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9713. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9714. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9715. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9716. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9717. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9718. var checkboxInfo = new Grp_EnterExitCostDraft()
  9719. {
  9720. Id = draftId,
  9721. CreateUserId = currUserId
  9722. };
  9723. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9724. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9725. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9726. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9727. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9728. if (draftId <= 0) //add
  9729. {
  9730. checkboxInfo.CreateUserId = dto.CurrUserId;
  9731. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9732. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9733. if (add < 1) return Ok(JsonView(false));
  9734. }
  9735. else //update
  9736. {
  9737. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9738. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9739. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9740. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9741. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9742. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9743. .Where(x => x.Id == draftId)
  9744. .ExecuteCommandAsync();
  9745. if (upd < 1) return Ok(JsonView(false));
  9746. }
  9747. return Ok(JsonView(new { parentId = draftId }));
  9748. }
  9749. /// <summary>
  9750. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9751. /// </summary>
  9752. /// <returns></returns>
  9753. [HttpPost]
  9754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9755. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9756. {
  9757. int id = dto.DraftId,currUserId = dto.CurrUserId;
  9758. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9759. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9760. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9761. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9762. info.FirstItemRemark = dto.FirstItemRemark;
  9763. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9764. if (id <= 0) //add
  9765. {
  9766. info.CreateUserId = dto.CurrUserId;
  9767. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9768. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9769. if (add < 1) return Ok(JsonView(false));
  9770. id = add;
  9771. }
  9772. else //update
  9773. {
  9774. var upd = await _sqlSugar.Updateable(info)
  9775. .UpdateColumns(x => new
  9776. {
  9777. x.ChoiceOne,
  9778. x.InsidePay,
  9779. x.VisaRemark,
  9780. x.Visa,
  9781. x.Service,
  9782. x.Safe,
  9783. x.Ticket,
  9784. x.HeSuan,
  9785. x.YiMiao,
  9786. x.FirstItemRemark
  9787. })
  9788. .Where(x => x.Id == id)
  9789. .ExecuteCommandAsync();
  9790. if (upd < 1) return Ok(JsonView(false));
  9791. }
  9792. ////消息通知
  9793. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9794. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9795. }
  9796. /// <summary>
  9797. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9798. /// </summary>
  9799. /// <returns></returns>
  9800. [HttpPost]
  9801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9802. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9803. {
  9804. int id = dto.DraftId;
  9805. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9806. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9807. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9808. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9809. info.OutsideJJPay = dto.OutsideJJPay;
  9810. info.OutsideGWPay = dto.OutsideGWPay;
  9811. info.OutsideTDPay = dto.OutsideTDPay;
  9812. info.AirJJ = dto.AirJJ;
  9813. info.AirGW = dto.AirGW;
  9814. info.AirTD = dto.AirTD;
  9815. info.CityTranffic = dto.CityTranffic;
  9816. info.TwoItemRemark = dto.TwoItemRemark;
  9817. info.SumJJC = dto.ChoiceTwoJJ;
  9818. info.SumGWC = dto.ChoiceTwoGW;
  9819. info.SumTDC = dto.ChoiceTwoTD;
  9820. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9821. if (id <= 0) //add
  9822. {
  9823. info.CreateUserId = dto.CurrUserId;
  9824. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9825. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9826. if (addId <= 0) return Ok(JsonView(false));
  9827. id = addId;
  9828. }
  9829. else //update
  9830. {
  9831. var upd = await _sqlSugar.Updateable(info)
  9832. .UpdateColumns(x => new
  9833. {
  9834. x.SumJJC,
  9835. x.OutsideJJPay,
  9836. x.SumGWC,
  9837. x.OutsideGWPay,
  9838. x.SumTDC,
  9839. x.OutsideTDPay,
  9840. x.AirJJ,
  9841. x.AirGW,
  9842. x.AirTD,
  9843. x.CityTranffic,
  9844. x.TwoItemRemark
  9845. })
  9846. .Where(x => x.Id == id)
  9847. .ExecuteCommandAsync();
  9848. if (upd < 1) return Ok(JsonView(false));
  9849. }
  9850. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9851. gwcItemTotal = info.AirGW + info.CityTranffic;
  9852. tdcItemTotal = info.AirTD + info.CityTranffic;
  9853. ////消息通知
  9854. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9855. return Ok(JsonView(new
  9856. {
  9857. parentId = id,
  9858. choiceTwoJJ = dto.ChoiceTwoJJ,
  9859. jjcItemTotal = jjcItemTotal,
  9860. choiceTwoGW = dto.ChoiceTwoGW,
  9861. gwcItemTotal = gwcItemTotal,
  9862. choiceTwoTD = dto.ChoiceTwoTD,
  9863. tdcItemTotal = tdcItemTotal
  9864. }));
  9865. }
  9866. /// <summary>
  9867. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9868. /// </summary>
  9869. /// <returns></returns>
  9870. [HttpPost]
  9871. [ApiExplorerSettings(IgnoreApi = true)]
  9872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9873. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9874. {
  9875. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9876. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9877. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9878. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9879. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9880. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9881. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9882. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9883. {
  9884. Id = x.Id,
  9885. ParentId = dto.DraftId,
  9886. Type = dto.FeeType,
  9887. Days = x.Days,
  9888. NationalTravelFeeId = x.NationalTravelFeeId,
  9889. Cost = x.Cost,
  9890. Currency = x.Currency,
  9891. SubTotal = x.SubTotal,
  9892. CreateUserId = dto.CurrUserId
  9893. })
  9894. .ToList();
  9895. var adds = infos.Where(x => x.Id <= 0).ToList();
  9896. var upds = infos.Where(x => x.Id > 0).ToList();
  9897. if (adds.Count > 0)
  9898. {
  9899. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9900. if (add < 1) return Ok(JsonView(false));
  9901. }
  9902. if (upds.Count > 0)
  9903. {
  9904. var upd = await _sqlSugar.Updateable(adds)
  9905. .UpdateColumns(x => new
  9906. {
  9907. x.Days,
  9908. x.NationalTravelFeeId,
  9909. x.Cost,
  9910. x.Currency,
  9911. x.SubTotal
  9912. })
  9913. .WhereColumns(x => new { x.Id })
  9914. .ExecuteCommandAsync();
  9915. if (upd < 1) return Ok(JsonView(false));
  9916. }
  9917. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9918. ////消息通知
  9919. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9920. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9921. return Ok(JsonView(new { itemTotal = itemTotal }));
  9922. }
  9923. /// <summary>
  9924. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9925. /// </summary>
  9926. /// <returns></returns>
  9927. [HttpPost]
  9928. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9929. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9930. {
  9931. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9932. int subId = dto.SubId, feeType = dto.FeeType;
  9933. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9934. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9935. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9936. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9937. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9938. subInfo.Id = subId;
  9939. subInfo.ParentId = dto.DraftId;
  9940. if (feeType == 3) subInfo.Type = 1;
  9941. else if (feeType == 4) subInfo.Type = 2;
  9942. else if (feeType == 5) subInfo.Type = 3;
  9943. else if (feeType == 6) subInfo.Type = 4;
  9944. subInfo.CreateUserId = dto.CurrUserId;
  9945. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9946. if (parentId < 1) return Ok(JsonView(false));
  9947. //子表op
  9948. if (subId < 1)
  9949. {
  9950. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9951. if (subAdd < 1) return Ok(JsonView(false));
  9952. }
  9953. else
  9954. {
  9955. var subUpd = await _sqlSugar.Updateable(subInfo)
  9956. .UpdateColumns(x => new
  9957. {
  9958. x.Days,
  9959. x.NationalTravelFeeId,
  9960. x.Cost,
  9961. x.Currency,
  9962. x.SubTotal
  9963. })
  9964. .WhereColumns(x => new { x.Id })
  9965. .ExecuteCommandAsync();
  9966. if (subUpd < 1) return Ok(JsonView(false));
  9967. }
  9968. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9969. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9970. }
  9971. /// <summary>
  9972. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9973. /// </summary>
  9974. /// <returns></returns>
  9975. [HttpPost]
  9976. [ApiExplorerSettings(IgnoreApi = true)]
  9977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9978. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9979. {
  9980. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9981. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9982. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9983. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9984. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9985. {
  9986. Id = x.Id,
  9987. ParentId = dto.DraftId,
  9988. SetDataId = x.SetDataId,
  9989. Index = x.Index,
  9990. Cost = x.Cost,
  9991. Currency = x.Currency,
  9992. SubTotal = x.SubTotal,
  9993. CreateUserId = dto.CurrUserId,
  9994. Remark = x.Remark
  9995. }).ToList();
  9996. var adds = infos.Where(x => x.Id <= 0).ToList();
  9997. var upds = infos.Where(x => x.Id > 0).ToList();
  9998. if (adds.Count > 0)
  9999. {
  10000. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  10001. if (add < 1) return Ok(JsonView(false));
  10002. }
  10003. if (upds.Count > 0)
  10004. {
  10005. var upd = await _sqlSugar.Updateable(adds)
  10006. .UpdateColumns(x => new
  10007. {
  10008. x.Index,
  10009. x.SetDataId,
  10010. x.Cost,
  10011. x.Currency,
  10012. x.SubTotal,
  10013. x.Remark
  10014. })
  10015. .WhereColumns(x => new { x.Id })
  10016. .ExecuteCommandAsync();
  10017. if (upd < 1) return Ok(JsonView(false));
  10018. }
  10019. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  10020. //消息通知
  10021. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  10022. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  10023. return Ok(JsonView(new { itemTotal = itemTotal }));
  10024. }
  10025. /// <summary>
  10026. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  10027. /// </summary>
  10028. /// <returns></returns>
  10029. [HttpPost]
  10030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10031. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  10032. {
  10033. int subId = dto.SubId,id = dto.DarftId;
  10034. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10035. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  10036. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10037. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  10038. subInfo.Id = subId;
  10039. subInfo.ParentId = dto.DarftId;
  10040. subInfo.CreateUserId = dto.CurrUserId;
  10041. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  10042. if (parentId < 1) return Ok(JsonView(false));
  10043. #region 子表op
  10044. if (subId < 1)//add
  10045. {
  10046. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  10047. if (subAdd < 1) return Ok(JsonView(false));
  10048. }
  10049. else //upd
  10050. {
  10051. var subUpd = await _sqlSugar.Updateable(subInfo)
  10052. .UpdateColumns(x => new
  10053. {
  10054. x.Index,
  10055. x.SetDataId,
  10056. x.Cost,
  10057. x.Currency,
  10058. x.SubTotal,
  10059. x.Remark
  10060. })
  10061. .WhereColumns(x => new { x.Id })
  10062. .ExecuteCommandAsync();
  10063. if (subUpd < 1) return Ok(JsonView(false));
  10064. }
  10065. #endregion
  10066. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10067. ////消息通知
  10068. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10069. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10070. }
  10071. /// <summary>
  10072. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10073. /// </summary>
  10074. /// <returns></returns>
  10075. [HttpPost]
  10076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10077. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10078. {
  10079. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10080. if (data.Code != 0)
  10081. {
  10082. return Ok(JsonView(false, data.Msg));
  10083. }
  10084. return Ok(JsonView(true, "操作成功!", data.Data));
  10085. }
  10086. /// <summary>
  10087. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10088. /// </summary>
  10089. /// <param name="dto"></param>
  10090. /// <returns></returns>
  10091. [HttpPost]
  10092. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10093. {
  10094. var data = new Grp_DayOtherPriceDraft()
  10095. {
  10096. Id = dto.Id,
  10097. IsDel = 1,
  10098. DeleteUserId = dto.DeleteUserId,
  10099. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10100. };
  10101. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10102. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10103. return Ok(JsonView(false, "删除失败!"));
  10104. }
  10105. #endregion
  10106. #endregion
  10107. #region 签证费用录入
  10108. /// <summary>
  10109. /// 根据diid查询签证费用列表
  10110. /// </summary>
  10111. /// <param name="dto"></param>
  10112. /// <returns></returns>
  10113. [HttpPost]
  10114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10115. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10116. {
  10117. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10118. if (groupData.Code != 0)
  10119. {
  10120. return Ok(JsonView(false, groupData.Msg));
  10121. }
  10122. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10123. }
  10124. /// <summary>
  10125. /// 根据签证费用Id查询单条数据及c表数据
  10126. /// </summary>
  10127. /// <param name="dto"></param>
  10128. /// <returns></returns>
  10129. [HttpPost]
  10130. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10131. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10132. {
  10133. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10134. if (groupData.Code != 0)
  10135. {
  10136. return Ok(JsonView(false, groupData.Msg));
  10137. }
  10138. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10139. }
  10140. /// <summary>
  10141. /// 签证费用删除
  10142. /// </summary>
  10143. /// <param name="dto"></param>
  10144. /// <returns></returns>
  10145. [HttpPost]
  10146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10147. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10148. {
  10149. _sqlSugar.BeginTran();
  10150. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10151. if (!res)
  10152. {
  10153. _sqlSugar.RollbackTran();
  10154. return Ok(JsonView(false, "删除失败"));
  10155. }
  10156. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10157. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10158. .SetColumns(a => new Grp_CreditCardPayment()
  10159. {
  10160. IsDel = 1,
  10161. DeleteUserId = dto.DeleteUserId,
  10162. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10163. })
  10164. .ExecuteCommand();
  10165. if (resSub < 1)
  10166. {
  10167. _sqlSugar.RollbackTran();
  10168. return Ok(JsonView(false, "删除失败"));
  10169. }
  10170. _sqlSugar.CommitTran();
  10171. return Ok(JsonView(true, "删除成功!"));
  10172. }
  10173. /// <summary>
  10174. /// 签证费用录入下拉框初始化
  10175. /// </summary>
  10176. /// <returns></returns>
  10177. [HttpPost]
  10178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10179. public async Task<IActionResult> VisaPriceAddSelect()
  10180. {
  10181. //支付方式
  10182. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10183. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10184. //币种
  10185. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10186. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10187. //乘客类型
  10188. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10189. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10190. //卡类型
  10191. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10192. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10193. //代办费类型
  10194. var agencyFeeTypeData = new List<dynamic>() {
  10195. new { id = 0 , Text = "未选择" },
  10196. new { id = 1 , Text = "小公务" },
  10197. new { id = 2 , Text = "大公务" },
  10198. };
  10199. //签证费用标准国家Data
  10200. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10201. var data = new
  10202. {
  10203. Payment = _Payment,
  10204. CurrencyList = _CurrencyList,
  10205. PassengerType = _PassengerType,
  10206. BankCard = _BankCard,
  10207. AgencyFeeType = agencyFeeTypeData,
  10208. CountryFeeData = visaCountryFeeData
  10209. };
  10210. return Ok(JsonView(true, "查询成功!", data));
  10211. }
  10212. /// <summary>
  10213. /// 签证费用录入操作(Status:1.新增,2.修改)
  10214. /// </summary>
  10215. /// <param name="dto"></param>
  10216. /// <returns></returns>
  10217. [HttpPost]
  10218. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10219. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10220. {
  10221. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10222. if (groupData.Code != 0)
  10223. {
  10224. return Ok(JsonView(false, groupData.Msg));
  10225. }
  10226. #region 应用推送
  10227. try
  10228. {
  10229. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10230. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10231. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10232. //2024-10-21 新增LZ UID
  10233. var userIds = new List<int>() { 21 };
  10234. string title = $"系统通知";
  10235. string content = "";
  10236. var diId = dto.DiId;
  10237. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10238. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10239. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10240. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10241. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10242. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10243. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10244. }
  10245. catch (Exception ex)
  10246. {
  10247. }
  10248. #endregion
  10249. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10250. }
  10251. #endregion
  10252. #region 签证提成录入
  10253. /// <summary>
  10254. /// 签证提成录入
  10255. /// 基础数据
  10256. /// </summary>
  10257. /// <param name="_dto"></param>
  10258. /// <returns></returns>
  10259. [HttpGet]
  10260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10261. public async Task<IActionResult> VisaCommissionInit()
  10262. {
  10263. return Ok(await _visaCommissionRep.Init());
  10264. }
  10265. /// <summary>
  10266. /// 签证提成录入
  10267. /// Item
  10268. /// </summary>
  10269. /// <param name="_dto"></param>
  10270. /// <returns></returns>
  10271. [HttpPost]
  10272. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10273. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10274. {
  10275. var validator = new VisaCommissionItemDtoValidator();
  10276. var validatorRes = await validator.ValidateAsync(_dto);
  10277. if (!validatorRes.IsValid)
  10278. {
  10279. StringBuilder sb = new StringBuilder();
  10280. foreach (var item in validatorRes.Errors)
  10281. {
  10282. sb.AppendLine(item.ErrorMessage);
  10283. }
  10284. return Ok(JsonView(false, sb.ToString()));
  10285. }
  10286. return Ok(await _visaCommissionRep.Item(_dto));
  10287. }
  10288. /// <summary>
  10289. /// 签证提成录入
  10290. /// Save
  10291. /// </summary>
  10292. /// <param name="_dto"></param>
  10293. /// <returns></returns>
  10294. [HttpPost]
  10295. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10296. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10297. {
  10298. //参数验证
  10299. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10300. foreach (var item in _dto.Items)
  10301. {
  10302. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10303. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10304. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10305. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10306. }
  10307. return Ok(await _visaCommissionRep.Save(_dto));
  10308. }
  10309. /// <summary>
  10310. /// 签证提成录入
  10311. /// Create
  10312. /// </summary>
  10313. /// <param name="_dto"></param>
  10314. /// <returns></returns>
  10315. [HttpPost]
  10316. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10317. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10318. {
  10319. var validator = new VisaCommissionCreateDtoValidator();
  10320. var validatorRes = await validator.ValidateAsync(_dto);
  10321. if (!validatorRes.IsValid)
  10322. {
  10323. StringBuilder sb = new StringBuilder();
  10324. foreach (var item in validatorRes.Errors)
  10325. {
  10326. sb.AppendLine(item.ErrorMessage);
  10327. }
  10328. return Ok(JsonView(false, sb.ToString()));
  10329. }
  10330. return Ok(await _visaCommissionRep.Create(_dto));
  10331. }
  10332. /// <summary>
  10333. /// 签证提成录入
  10334. /// Put(编辑)
  10335. /// </summary>
  10336. /// <param name="id"></param>
  10337. /// <param name="_dto"></param>
  10338. /// <returns></returns>
  10339. [HttpPut]
  10340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10341. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10342. {
  10343. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10344. var validator = new VisaCommissionCreateDtoValidator();
  10345. var validatorRes = await validator.ValidateAsync(_dto);
  10346. if (!validatorRes.IsValid)
  10347. {
  10348. StringBuilder sb = new StringBuilder();
  10349. foreach (var item in validatorRes.Errors)
  10350. {
  10351. sb.AppendLine(item.ErrorMessage);
  10352. }
  10353. return Ok(JsonView(false, sb.ToString()));
  10354. }
  10355. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10356. }
  10357. /// <summary>
  10358. /// 签证提成录入
  10359. /// Del
  10360. /// </summary>
  10361. /// <param name="id"></param>
  10362. /// <param name="currUserId"></param>
  10363. /// <returns></returns>
  10364. [HttpPost]
  10365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10366. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10367. {
  10368. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10369. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10370. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10371. }
  10372. #endregion
  10373. #region op费用录入
  10374. /// <summary>
  10375. /// 根据diid查询op费用列表
  10376. /// </summary>
  10377. /// <param name="dto"></param>
  10378. /// <returns></returns>
  10379. [HttpPost]
  10380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10381. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10382. {
  10383. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10384. if (groupData.Code != 0)
  10385. {
  10386. return Ok(JsonView(false, groupData.Msg));
  10387. }
  10388. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10389. }
  10390. /// <summary>
  10391. /// 根据op费用Id查询单条数据及c表数据
  10392. /// </summary>
  10393. /// <param name="dto"></param>
  10394. /// <returns></returns>
  10395. [HttpPost]
  10396. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10397. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10398. {
  10399. try
  10400. {
  10401. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10402. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10403. var data = new
  10404. {
  10405. CarTouristGuideGround = _groupData,
  10406. CreditCardPayment = _creditCardPayment
  10407. };
  10408. return Ok(JsonView(true, "查询成功!", data));
  10409. }
  10410. catch (Exception ex)
  10411. {
  10412. return Ok(JsonView(false, "程序错误!"));
  10413. }
  10414. }
  10415. /// <summary>
  10416. /// op费用删除
  10417. /// </summary>
  10418. /// <param name="dto"></param>
  10419. /// <returns></returns>
  10420. [HttpPost]
  10421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10422. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10423. {
  10424. try
  10425. {
  10426. _sqlSugar.BeginTran();
  10427. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10428. if (!res)
  10429. {
  10430. return Ok(JsonView(false, "删除失败"));
  10431. }
  10432. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10433. {
  10434. IsDel = 1,
  10435. DeleteUserId = dto.DeleteUserId,
  10436. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10437. }).ExecuteCommandAsync();
  10438. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10439. {
  10440. IsDel = 1,
  10441. DeleteUserId = dto.DeleteUserId,
  10442. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10443. }).ExecuteCommandAsync();
  10444. #region 删除超支相关数据
  10445. //删除导入的超支数据
  10446. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10447. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10448. {
  10449. IsDel = 1,
  10450. DeleteUserId = dto.DeleteUserId,
  10451. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10452. }).ExecuteCommand();
  10453. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10454. {
  10455. IsDel = 1,
  10456. DeleteUserId = dto.DeleteUserId,
  10457. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10458. }).ExecuteCommand();
  10459. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10460. {
  10461. IsDel = 1,
  10462. DeleteUserId = dto.DeleteUserId,
  10463. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10464. }).ExecuteCommand();
  10465. #endregion
  10466. _sqlSugar.CommitTran();
  10467. return Ok(JsonView(true, "删除成功!"));
  10468. }
  10469. catch (Exception ex)
  10470. {
  10471. _sqlSugar.RollbackTran();
  10472. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10473. }
  10474. }
  10475. /// <summary>
  10476. /// op费用录入操作(Status:1.新增,2.修改)
  10477. /// </summary>
  10478. /// <param name="dto"></param>
  10479. /// <returns></returns>
  10480. [HttpPost]
  10481. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10482. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10483. {
  10484. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10485. if (groupData.Code != 0)
  10486. {
  10487. return Ok(JsonView(false, groupData.Msg));
  10488. }
  10489. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10490. }
  10491. /// <summary>
  10492. /// 填写费用详细页面初始化绑定
  10493. /// </summary>
  10494. /// <param name="dto"></param>
  10495. /// <returns></returns>
  10496. [HttpPost]
  10497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10498. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10499. {
  10500. try
  10501. {
  10502. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10503. if (groupData.Code != 0)
  10504. {
  10505. return Ok(JsonView(false, groupData.Msg));
  10506. }
  10507. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10508. }
  10509. catch (Exception ex)
  10510. {
  10511. return Ok(JsonView(false, ex.Message));
  10512. }
  10513. }
  10514. /// <summary>
  10515. /// 根据op费用Id查询详细数据
  10516. /// </summary>
  10517. /// <param name="dto"></param>
  10518. /// <returns></returns>
  10519. [HttpPost]
  10520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10521. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10522. {
  10523. try
  10524. {
  10525. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10526. if (groupData.Code != 0)
  10527. {
  10528. return Ok(JsonView(false, groupData.Msg));
  10529. }
  10530. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10531. }
  10532. catch (Exception ex)
  10533. {
  10534. return Ok(JsonView(false, ex.Message));
  10535. }
  10536. }
  10537. /// <summary>
  10538. /// OP费用录入填写详情
  10539. /// </summary>
  10540. /// <param name="dto"></param>
  10541. /// <returns></returns>
  10542. [HttpPost]
  10543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10544. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10545. {
  10546. try
  10547. {
  10548. #region 参数校验
  10549. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10550. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10551. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10552. #endregion
  10553. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10554. if (groupData.Code != 0)
  10555. {
  10556. return Ok(JsonView(false, groupData.Msg));
  10557. }
  10558. //自动审核
  10559. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10560. #region 应用推送
  10561. try
  10562. {
  10563. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10564. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10565. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10566. //2024-10-21 新增LZ UID
  10567. var userIds = new List<int>() { 21 };
  10568. string title = $"系统通知";
  10569. var diId = dto.DiId;
  10570. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10571. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10572. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  10573. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10574. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10575. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10576. }
  10577. catch (Exception ex)
  10578. {
  10579. }
  10580. #endregion
  10581. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10582. }
  10583. catch (Exception ex)
  10584. {
  10585. return Ok(JsonView(false, ex.Message));
  10586. }
  10587. }
  10588. /// <summary>
  10589. /// 获取三公详细所有城市
  10590. /// </summary>
  10591. /// <returns></returns>
  10592. [HttpGet]
  10593. public IActionResult OpCarCityResult()
  10594. {
  10595. var jw = JsonView(false);
  10596. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10597. {
  10598. x.Id,
  10599. x.Country,
  10600. x.City,
  10601. }).ToList();
  10602. if (data.Count > 0)
  10603. {
  10604. jw = JsonView(true, "获取成功!", data);
  10605. }
  10606. else
  10607. {
  10608. jw.Msg = "城市数据为空!";
  10609. jw.Data = new string[0];
  10610. }
  10611. return Ok(jw);
  10612. }
  10613. /// <summary>
  10614. /// 导出地接费用明细
  10615. /// </summary>
  10616. /// <param name="dto"></param>
  10617. /// <returns></returns>
  10618. [HttpPost]
  10619. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10620. {
  10621. var jw = JsonView(false);
  10622. if (dto.Diid < 1)
  10623. {
  10624. jw.Msg = "请输入正确的diid!";
  10625. return Ok(jw);
  10626. }
  10627. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10628. if (group == null)
  10629. {
  10630. jw.Msg = "未找到团组信息!";
  10631. return Ok(jw);
  10632. }
  10633. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10634. if (localGuideArr.Count == 0)
  10635. {
  10636. jw.Msg = "该团组暂无地接信息!";
  10637. return Ok(jw);
  10638. }
  10639. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10640. var overspendSoure = new Dictionary<int, int>
  10641. {
  10642. { 91, 982 }, //车
  10643. { 92 , 1059} ,//导游
  10644. { 994 , 1073}, //翻译
  10645. { 988 , 1074 }, //早餐
  10646. { 93 , 1075 }, //午餐
  10647. { 989 , 1076 }, //晚餐
  10648. };
  10649. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10650. foreach (var groupArr in localGroup)
  10651. {
  10652. var keyValue = groupArr.Key;
  10653. if (int.TryParse(keyValue, out int cityid))
  10654. {
  10655. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10656. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10657. }
  10658. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10659. foreach (var item in groupArr)
  10660. {
  10661. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10662. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10663. new Grp_CarTouristGuideGroundReservationsContentExtend
  10664. {
  10665. Count = a.Count,
  10666. CreateTime = a.CreateTime,
  10667. CreateUserId = a.CreateUserId,
  10668. CTGGRId = a.CTGGRId,
  10669. Currency = a.Currency,
  10670. DatePrice = a.DatePrice,
  10671. DeleteTime = a.DeleteTime,
  10672. DeleteUserId = a.DeleteUserId,
  10673. DiId = a.DiId,
  10674. Id = a.Id,
  10675. IsDel = a.IsDel,
  10676. Price = a.Price,
  10677. PriceContent = a.PriceContent,
  10678. Remark = a.Remark,
  10679. SId = a.SId,
  10680. SidName = b.Name,
  10681. Units = a.Units,
  10682. }
  10683. ).ToList();
  10684. if (content.Count > 0)
  10685. {
  10686. contentArr.Add(content);
  10687. }
  10688. }
  10689. //open excel
  10690. //set excel
  10691. //save excel
  10692. try
  10693. {
  10694. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10695. IWorkbook workbook;
  10696. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10697. {
  10698. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10699. }
  10700. else
  10701. {
  10702. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10703. }
  10704. ISheet sheet = workbook.GetSheetAt(0);
  10705. var rowStartIndex = 2;
  10706. var clounmCount = 10;
  10707. var initStyleRow = sheet.GetRow(2);
  10708. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10709. //var overspendArrDetail =
  10710. var existsId = new List<CarCompare>();
  10711. var lastElem = arr.Last();
  10712. var thisSid = -1;
  10713. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10714. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10715. {
  10716. Name = "未知币种!",
  10717. Remark = "未知币种!",
  10718. };
  10719. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10720. Action cloneRowFn = () =>
  10721. {
  10722. rowStartIndex++;
  10723. var cloneRow = sheet.CreateRow(rowStartIndex);
  10724. // 复制样式
  10725. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10726. {
  10727. ICell sourceCell = initStyleRow.GetCell(i);
  10728. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10729. // 确保单元格存在样式
  10730. if (sourceCell.CellStyle != null)
  10731. {
  10732. targetCell.CellStyle = sourceCell.CellStyle;
  10733. }
  10734. }
  10735. };
  10736. var mergeRow = () =>
  10737. {
  10738. for (int i = 2; i < sheet.LastRowNum; i++)
  10739. {
  10740. var row = sheet.GetRow(i);
  10741. var cellFirst = row.GetCell(0);
  10742. var thisIndex = i + 1;
  10743. while (thisIndex < sheet.LastRowNum)
  10744. {
  10745. var nextRow = sheet.GetRow(thisIndex);
  10746. var nextCellFirst = nextRow.GetCell(0);
  10747. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10748. {
  10749. thisIndex++;
  10750. }
  10751. else
  10752. {
  10753. break;
  10754. }
  10755. }
  10756. thisIndex--;
  10757. if (thisIndex != i)
  10758. {
  10759. //合并row
  10760. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10761. i, // 起始行索引(0-based)
  10762. thisIndex, // 结束行索引(0-based)
  10763. 0, // 起始列索引(0-based)
  10764. 0 // 结束列索引(0-based)
  10765. );
  10766. sheet.AddMergedRegion(cellRangeAddress);
  10767. i = thisIndex;
  10768. }
  10769. }
  10770. };
  10771. var chaoshiNumber = 0;
  10772. var totalNumber = 0.00M;
  10773. string lastStr = "";
  10774. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10775. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10776. {
  10777. b.IsAuditGM,
  10778. x.Id,
  10779. x.Area,
  10780. b.PayPercentage,
  10781. b.PayMoney,
  10782. }).ToList();
  10783. string yesPayment = "", noPayment = "";
  10784. foreach (var item in queryCarArrByCityAndDiid)
  10785. {
  10786. if (item.IsAuditGM == 1)
  10787. {
  10788. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10789. }
  10790. else
  10791. {
  10792. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10793. }
  10794. }
  10795. lastStr = yesPayment + noPayment;
  10796. foreach (var item in arr)
  10797. {
  10798. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10799. {
  10800. if (thisSid != item.SId)
  10801. {
  10802. if (thisSid == -1)
  10803. {
  10804. thisSid = item.SId;
  10805. }
  10806. else
  10807. {
  10808. //合并小计行
  10809. //创建合并区域的实例
  10810. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10811. rowStartIndex, // 起始行索引(0-based)
  10812. rowStartIndex, // 结束行索引(0-based)
  10813. 0, // 起始列索引(0-based)
  10814. 3 // 结束列索引(0-based)
  10815. );
  10816. sheet.AddMergedRegion(cellRangeAddress);
  10817. var CellStyle = workbook.CreateCellStyle();
  10818. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10819. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10820. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10821. for (int i = 0; i <= clounmCount; i++)
  10822. {
  10823. if (i > 6)
  10824. {
  10825. var CellStyle1 = workbook.CreateCellStyle();
  10826. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10827. IFont Font = workbook.CreateFont(); // 创建字体
  10828. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10829. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10830. CellStyle1.SetFont(Font);
  10831. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10832. }
  10833. else
  10834. {
  10835. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10836. }
  10837. }
  10838. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10839. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10840. //超时合计
  10841. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10842. //超时数
  10843. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10844. //超时合计费用
  10845. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10846. thisSid = item.SId;
  10847. cloneRowFn();
  10848. chaoshiNumber = 0;
  10849. totalNumber = 0;
  10850. }
  10851. }
  10852. IRow row = sheet.GetRow(rowStartIndex);
  10853. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10854. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10855. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10856. if (isOpenOverspendSoure)
  10857. {
  10858. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10859. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10860. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10861. }
  10862. for (int i = 0; i <= clounmCount; i++)
  10863. {
  10864. var cell = row.GetCell(i);
  10865. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10866. if (cell == null)
  10867. {
  10868. cell = row.CreateCell(i);
  10869. }
  10870. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10871. fontRed.CloneStyleFrom(cell.CellStyle);
  10872. IFont Font = workbook.CreateFont(); // 创建字体
  10873. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10874. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10875. fontRed.SetFont(Font);
  10876. byte[] rgb = new byte[3] { 255, 242, 204 };
  10877. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10878. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10879. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10880. if (workbook is XSSFWorkbook)
  10881. {
  10882. BackgroundColor255_242_204.FillForegroundColor = 0;
  10883. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10884. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10885. }
  10886. else
  10887. {
  10888. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10889. }
  10890. if (i == 1 || i > 6)
  10891. {
  10892. if (i > 6)
  10893. {
  10894. fontRed.FillForegroundColor = 0;
  10895. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10896. fontRed.FillPattern = FillPattern.SolidForeground;
  10897. }
  10898. cell.CellStyle = fontRed;
  10899. }
  10900. if (i > 2 && i < 7)
  10901. {
  10902. cell.CellStyle = BackgroundColor255_242_204;
  10903. }
  10904. cell.SetCellValue(setCellValue); //写入单元格
  10905. }
  10906. if (overspendSoure.ContainsKey(thisSid))
  10907. {
  10908. var overspendId = overspendSoure[thisSid];
  10909. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10910. }
  10911. cloneRowFn();
  10912. existsId.Add(new CarCompare
  10913. {
  10914. DataPrice = item.DatePrice.ObjToDate(),
  10915. Sid = item.SId
  10916. });
  10917. }
  10918. if (item.Equals(lastElem))
  10919. {
  10920. //合并小计行
  10921. //创建合并区域的实例
  10922. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10923. rowStartIndex, // 起始行索引(0-based)
  10924. rowStartIndex, // 结束行索引(0-based)
  10925. 0, // 起始列索引(0-based)
  10926. 3 // 结束列索引(0-based)
  10927. );
  10928. sheet.AddMergedRegion(cellRangeAddress);
  10929. var CellStyle = workbook.CreateCellStyle();
  10930. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10931. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10932. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10933. for (int i = 0; i <= clounmCount; i++)
  10934. {
  10935. if (i > 6)
  10936. {
  10937. var CellStyle1 = workbook.CreateCellStyle();
  10938. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10939. IFont Font = workbook.CreateFont(); // 创建字体
  10940. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10941. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10942. CellStyle1.SetFont(Font);
  10943. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10944. }
  10945. else
  10946. {
  10947. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10948. }
  10949. }
  10950. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10951. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10952. //超时合计
  10953. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10954. //超时数
  10955. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10956. //超时合计费用
  10957. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10958. cloneRowFn();
  10959. // 创建合并区域的实例
  10960. cellRangeAddress = new CellRangeAddress(
  10961. rowStartIndex, // 起始行索引(0-based)
  10962. rowStartIndex, // 结束行索引(0-based)
  10963. 0, // 起始列索引(0-based)
  10964. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10965. );
  10966. // 添加合并区域
  10967. sheet.AddMergedRegion(cellRangeAddress);
  10968. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10969. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10970. }
  10971. }
  10972. mergeRow();
  10973. // 保存修改后的Excel文件到新文件
  10974. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10975. // new FileStream(newFilePath, FileMode.CreateNew)
  10976. using (var stream = new MemoryStream())
  10977. {
  10978. workbook.Write(stream, true);
  10979. stream.Flush();
  10980. stream.Seek(0, SeekOrigin.Begin);
  10981. MemoryStream memoryStream = new MemoryStream();
  10982. stream.CopyTo(memoryStream);
  10983. memoryStream.Seek(0, SeekOrigin.Begin);
  10984. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  10985. }
  10986. workbook.Close();
  10987. workbook.Dispose();
  10988. }
  10989. catch (Exception ex)
  10990. {
  10991. jw.Msg = "出现异常!" + ex.Message;
  10992. return Ok(jw);
  10993. }
  10994. }
  10995. if (Zips.Count > 0)
  10996. {
  10997. IOOperatorHelper io = new IOOperatorHelper();
  10998. var byts = io.ConvertZipStream(Zips);
  10999. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  11000. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  11001. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  11002. }
  11003. else
  11004. {
  11005. jw.Msg = "暂无生成文件!";
  11006. }
  11007. return Ok(jw);
  11008. }
  11009. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  11010. {
  11011. string outStr = string.Empty;
  11012. switch (i)
  11013. {
  11014. case 0:
  11015. outStr = arr[0].SidName;
  11016. break;
  11017. case 1:
  11018. outStr = arr[0].DataPriceStr;
  11019. break;
  11020. case 2:
  11021. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  11022. break;
  11023. case 4:
  11024. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  11025. break;
  11026. case 7:
  11027. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11028. {
  11029. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  11030. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  11031. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  11032. }
  11033. break;
  11034. case 8:
  11035. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11036. {
  11037. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  11038. }
  11039. break;
  11040. case 9:
  11041. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11042. {
  11043. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  11044. }
  11045. break;
  11046. case 10:
  11047. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  11048. {
  11049. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  11050. }
  11051. break;
  11052. }
  11053. return outStr;
  11054. }
  11055. #region OP行程单
  11056. /// <summary>
  11057. /// OP行程单初始化
  11058. /// </summary>
  11059. /// <param name="dto"></param>
  11060. /// <returns></returns>
  11061. [HttpPost]
  11062. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11063. {
  11064. var jw = JsonView(false);
  11065. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11066. var group = groupList.First();
  11067. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11068. if (group == null)
  11069. {
  11070. jw.Msg = "暂无团组!";
  11071. return Ok(jw);
  11072. }
  11073. group = groupList.Find(x => x.Id == diid);
  11074. if (group == null)
  11075. {
  11076. jw.Msg = "请输入正确的团组ID!";
  11077. return Ok(jw);
  11078. }
  11079. string city = string.Empty;
  11080. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11081. if (blackCode.Count > 0)
  11082. {
  11083. var black = blackCode.First();
  11084. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11085. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11086. if (blackSp.Length > 0)
  11087. {
  11088. try
  11089. {
  11090. var cityArrCode = new List<string>(20);
  11091. foreach (var item in blackSp)
  11092. {
  11093. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11094. var IndexSelect = itemSp[2];
  11095. var cityArrCodeLength = cityArrCode.Count - 1;
  11096. var startCity = IndexSelect.Substring(0, 3);
  11097. if (cityArrCodeLength > 0)
  11098. {
  11099. var arrEndCity = cityArrCode[cityArrCodeLength];
  11100. if (arrEndCity != startCity)
  11101. {
  11102. cityArrCode.Add(startCity.ToUpper());
  11103. }
  11104. }
  11105. else
  11106. {
  11107. cityArrCode.Add(startCity.ToUpper());
  11108. }
  11109. var endCity = IndexSelect.Substring(3, 3);
  11110. cityArrCode.Add(endCity.ToUpper());
  11111. }
  11112. var cityThree = string.Empty;
  11113. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11114. cityThree = cityThree.TrimEnd(',');
  11115. if (string.IsNullOrWhiteSpace(cityThree))
  11116. {
  11117. throw new
  11118. Exception("error");
  11119. }
  11120. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11121. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11122. foreach (var item in cityArrCode)
  11123. {
  11124. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11125. if (find != null)
  11126. {
  11127. city += find.City + "/";
  11128. }
  11129. else
  11130. {
  11131. city += item + "三字码未收入/";
  11132. }
  11133. }
  11134. city = city.TrimEnd('/');
  11135. }
  11136. catch (Exception e)
  11137. {
  11138. city = "黑屏代码格式不正确!";
  11139. }
  11140. }
  11141. }
  11142. else
  11143. {
  11144. city = "未录入黑屏代码";
  11145. }
  11146. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11147. {
  11148. Date = x.Date,
  11149. Days = x.Days,
  11150. Diffgroup = x.Diffgroup,
  11151. Diid = x.Diid,
  11152. Traffic_First = x.Traffic_First,
  11153. Traffic_Second = x.Traffic_Second,
  11154. Trip = x.Trip,
  11155. WeekDay = x.WeekDay,
  11156. Id = x.Id
  11157. }).ToList();
  11158. jw.Data = new
  11159. {
  11160. groupList = groupList.Select(x => new
  11161. {
  11162. x.Id,
  11163. x.TeamName,
  11164. x.TourCode
  11165. }).ToList(),
  11166. groupInfo = new
  11167. {
  11168. group.VisitDays,
  11169. group.TourCode,
  11170. group.VisitPNumber,
  11171. group.TeamName,
  11172. city
  11173. },
  11174. OpTravelList
  11175. };
  11176. jw.Code = 200;
  11177. jw.Msg = "操作成功!";
  11178. return Ok(jw);
  11179. }
  11180. /// <summary>
  11181. /// 删除团组行程单
  11182. /// </summary>
  11183. /// <returns></returns>
  11184. [HttpPost]
  11185. public IActionResult DelTravel(DelOpTravelDto dto)
  11186. {
  11187. var jw = JsonView(false);
  11188. if (dto.UserId <= 0 || dto.Diid <= 0)
  11189. {
  11190. jw.Msg = "请输入正确的参数!";
  11191. return Ok(jw);
  11192. }
  11193. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11194. .SetColumns(x => new Grp_TravelList
  11195. {
  11196. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11197. DeleteUserId = dto.UserId,
  11198. IsDel = 1,
  11199. }).ExecuteCommand();
  11200. jw = JsonView(true);
  11201. return Ok(jw);
  11202. }
  11203. /// <summary>
  11204. /// 行程单保存
  11205. /// </summary>
  11206. /// <returns></returns>
  11207. [HttpPost]
  11208. public IActionResult TravelSave(TravelSaveDto dto)
  11209. {
  11210. var jw = JsonView(false);
  11211. if (dto.Arr.Count > 0)
  11212. {
  11213. try
  11214. {
  11215. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11216. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  11217. .ToList();
  11218. _sqlSugar.BeginTran();
  11219. foreach (var item in dto.Arr)
  11220. {
  11221. if (item.Id == 0)
  11222. {
  11223. throw new Exception("请传入正确的Id");
  11224. }
  11225. //比较上一次的差异
  11226. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11227. if (findTravel != null)
  11228. {
  11229. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11230. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11231. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  11232. }
  11233. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11234. .SetColumns(x => new Grp_TravelList
  11235. {
  11236. Trip = item.Trip
  11237. }).ExecuteCommand();
  11238. }
  11239. _sqlSugar.CommitTran();
  11240. jw = JsonView(true);
  11241. }
  11242. catch (Exception ex)
  11243. {
  11244. _sqlSugar.RollbackTran();
  11245. jw.Msg = "程序异常!" + ex.Message;
  11246. }
  11247. }
  11248. else
  11249. {
  11250. jw.Msg = "请传入正确的参数!";
  11251. }
  11252. return Ok(jw);
  11253. }
  11254. private string CheckStr(string original, string changed)
  11255. {
  11256. // 创建diff_match_patch对象
  11257. var dmp = new diff_match_patch();
  11258. // 计算差异
  11259. List<Diff> diffs = dmp.diff_main(original, changed);
  11260. // 清理和合并差异
  11261. dmp.diff_cleanupSemantic(diffs);
  11262. // 使用StringBuilder构建最终的字符串
  11263. StringBuilder finalString = new StringBuilder();
  11264. // 输出差异结果,并构建变动后的字符串
  11265. foreach (Diff diff in diffs)
  11266. {
  11267. switch (diff.operation)
  11268. {
  11269. case Operation.EQUAL:
  11270. // 相等的部分,直接添加到最终字符串
  11271. finalString.Append(diff.text);
  11272. break;
  11273. case Operation.INSERT:
  11274. // 插入的部分,添加标记并添加到最终字符串
  11275. finalString.Append("[++]" + diff.text + "[++]");
  11276. break;
  11277. case Operation.DELETE:
  11278. // 删除的部分,不添加到最终字符串
  11279. //finalString.Append("[++]" + diff.text + "[++]");
  11280. break;
  11281. }
  11282. }
  11283. // 输出变动后的字符串
  11284. return finalString.ToString();
  11285. }
  11286. private class tagContent
  11287. {
  11288. public DateTime Date { get; set; }
  11289. public string StartTag { get; set; }
  11290. public string EndTag { get; set; }
  11291. public string Content { get; set; }
  11292. public static int tagLength { get { return 3; } }
  11293. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11294. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11295. public bool IsFinally { get; set; }
  11296. }
  11297. private List<string> ExtractContentBetweenTags(string input, string tag)
  11298. {
  11299. List<string> results = new List<string>();
  11300. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11301. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11302. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11303. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11304. string[] strValueArr = new string[1];
  11305. foreach (System.Text.RegularExpressions.Match match in matches)
  11306. {
  11307. var strValue = match.Groups[1].Value;
  11308. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11309. }
  11310. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11311. return results;
  11312. }
  11313. /// <summary>
  11314. /// 导出行程单
  11315. /// </summary>
  11316. /// <param name="dto"></param>
  11317. /// <returns></returns>
  11318. [HttpPost]
  11319. public IActionResult ExportTravel(ExportTravelDto dto)
  11320. {
  11321. var jw = JsonView(false);
  11322. jw.Data = "";
  11323. int diid = 0;
  11324. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11325. if (Find == null)
  11326. {
  11327. jw.Msg = "请选择正确的团组!";
  11328. return Ok(jw);
  11329. }
  11330. else
  11331. {
  11332. diid = Find.Id;
  11333. }
  11334. //数据源
  11335. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11336. DataTable dtBlack = null;
  11337. try
  11338. {
  11339. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11340. }
  11341. catch (Exception)
  11342. {
  11343. jw.Msg = "机票黑屏代码有误!";
  11344. return Ok(jw);
  11345. }
  11346. string CityStr = string.Empty;
  11347. if (dtBlack.Rows.Count == 0)
  11348. {
  11349. jw.Msg = "机票黑屏代码有误!";
  11350. return Ok(jw);
  11351. }
  11352. else
  11353. {
  11354. foreach (DataRow row in dtBlack.Rows)
  11355. {
  11356. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11357. {
  11358. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11359. return Ok(jw);
  11360. }
  11361. }
  11362. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11363. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11364. }
  11365. // 指定的文字
  11366. var targetTextDic = new Dictionary<string, List<string>>();
  11367. //创建数据源Table
  11368. DataTable dtSource = new DataTable();
  11369. dtSource.Columns.Add("Days", typeof(string));
  11370. dtSource.Columns.Add("Date", typeof(string));
  11371. dtSource.Columns.Add("Week", typeof(string));
  11372. dtSource.Columns.Add("Traffic", typeof(string));
  11373. dtSource.Columns.Add("Trip", typeof(string));
  11374. //获取数据,放到datatable
  11375. foreach (var item in _travelList)
  11376. {
  11377. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11378. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11379. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11380. .Replace("[++]", string.Empty);
  11381. DataRow dr = dtSource.NewRow();
  11382. dr["Days"] = item.Days;
  11383. dr["Date"] = item.Date;
  11384. dr["Week"] = item.WeekDay;
  11385. dr["Traffic"] = item.Traffic_First
  11386. + "\r\n"
  11387. + item.Traffic_Second;
  11388. dr["Trip"] = item.Trip;
  11389. dtSource.Rows.Add(dr);
  11390. }
  11391. Dictionary<string, string> dic = new Dictionary<string, string>();
  11392. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11393. dic.Add("City", CityStr);
  11394. dic.Add("Days", Find.VisitDays.ToString());
  11395. dic.Add("DeleCode", Find.TourCode);
  11396. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11397. //模板路径
  11398. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11399. //载入模板
  11400. Document doc = null;
  11401. DocumentBuilder builder = null;
  11402. try
  11403. {
  11404. //载入模板
  11405. doc = new Document(tempPath);
  11406. builder = new DocumentBuilder(doc);
  11407. }
  11408. catch (Exception)
  11409. {
  11410. jw.Msg = "模板位置不存在!";
  11411. return Ok(jw);
  11412. }
  11413. foreach (var key in dic.Keys)
  11414. {
  11415. Bookmark bookmark = doc.Range.Bookmarks[key];
  11416. if (bookmark != null)
  11417. {
  11418. builder.MoveToBookmark(key);
  11419. builder.Write(dic[key]);
  11420. }
  11421. }
  11422. //获取word里所有表格
  11423. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11424. //获取所填表格的序数
  11425. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11426. try
  11427. {
  11428. //循环赋值
  11429. for (int i = 0; i < dtSource.Rows.Count; i++)
  11430. {
  11431. builder.MoveToCell(0, i + 1, 0, 0);
  11432. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11433. builder.MoveToCell(0, i + 1, 1, 0);
  11434. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11435. builder.MoveToCell(0, i + 1, 2, 0);
  11436. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11437. var trip = dtSource.Rows[i]["Trip"].ToString();
  11438. builder.MoveToCell(0, i + 1, 3, 0);
  11439. builder.Write(trip);
  11440. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11441. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11442. // 获取特定索引的段落
  11443. Paragraph paragraph = (Paragraph)paragraphs[0];
  11444. Run run = paragraph.Runs[0];
  11445. Aspose.Words.Font font = run.Font;
  11446. font.Name = "黑体";
  11447. //设置双休红色
  11448. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11449. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11450. paragraph = (Paragraph)paragraphs[1];
  11451. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11452. {
  11453. run = paragraph.Runs[0];
  11454. font = run.Font;
  11455. font.Color = Color.Red;
  11456. }
  11457. }
  11458. }
  11459. catch (Exception ex)
  11460. {
  11461. }
  11462. //删除多余行
  11463. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11464. {
  11465. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11466. }
  11467. var targetTextList = new List<string>();
  11468. // 遍历文档中的表格
  11469. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11470. {
  11471. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11472. {
  11473. var cellIndex = 0;
  11474. foreach (Cell cell in row.Cells)
  11475. {
  11476. if (cellIndex == 1 && row.Cells.Count == 4)
  11477. {
  11478. foreach (var target in targetTextDic.Keys)
  11479. {
  11480. if (cell.GetText().Contains(target))
  11481. {
  11482. targetTextList = targetTextDic[target];
  11483. break;
  11484. }
  11485. }
  11486. }
  11487. // 遍历单元格中的所有段落
  11488. foreach (Paragraph paragraph in cell.Paragraphs)
  11489. {
  11490. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11491. List<Run> runs = new List<Run>();
  11492. foreach (Run run in paragraph.Runs)
  11493. {
  11494. runs.Add(run);
  11495. }
  11496. foreach (Run run in runs)
  11497. {
  11498. foreach (var targetText in targetTextList)
  11499. {
  11500. // 检查文字是否包含指定文字
  11501. if (run.Text.Contains(targetText))
  11502. {
  11503. // 将包含的部分设置为红色
  11504. HighlightText(run, targetText, Color.Red);
  11505. }
  11506. }
  11507. }
  11508. }
  11509. cellIndex++;
  11510. }
  11511. }
  11512. }
  11513. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11514. if (!Directory.Exists(savePath))
  11515. {
  11516. try
  11517. {
  11518. Directory.CreateDirectory(savePath);
  11519. }
  11520. catch
  11521. {
  11522. }
  11523. }
  11524. string path = savePath + Find.TeamName + "出访日程";
  11525. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11526. try
  11527. {
  11528. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11529. string postfix = ".docx";
  11530. if (dto.IsPDF == 1)
  11531. {
  11532. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11533. postfix = ".pdf";
  11534. }
  11535. doc.Save(path + postfix, saveFormat);
  11536. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11537. }
  11538. catch (Exception)
  11539. {
  11540. jw = JsonView(false);
  11541. }
  11542. return Ok(jw);
  11543. }
  11544. /// <summary>
  11545. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11546. /// </summary>
  11547. /// <param name="num"></param>
  11548. /// <returns></returns>
  11549. string GetNum(string num)
  11550. {
  11551. string str = "";
  11552. switch (num)
  11553. {
  11554. case "1":
  11555. str = "一";
  11556. break;
  11557. case "2":
  11558. str = "二";
  11559. break;
  11560. case "3":
  11561. str = "三";
  11562. break;
  11563. case "4":
  11564. str = "四";
  11565. break;
  11566. case "5":
  11567. str = "五";
  11568. break;
  11569. case "6":
  11570. str = "六";
  11571. break;
  11572. case "7":
  11573. str = "七";
  11574. break;
  11575. case "8":
  11576. str = "八";
  11577. break;
  11578. case "9":
  11579. str = "九";
  11580. break;
  11581. case "10":
  11582. str = "十";
  11583. break;
  11584. case "11":
  11585. str = "十一";
  11586. break;
  11587. case "12":
  11588. str = "十二";
  11589. break;
  11590. case "一":
  11591. str = "1";
  11592. break;
  11593. case "二":
  11594. str = "2";
  11595. break;
  11596. case "三":
  11597. str = "3";
  11598. break;
  11599. case "四":
  11600. str = "4";
  11601. break;
  11602. case "五":
  11603. str = "5";
  11604. break;
  11605. case "六":
  11606. str = "6";
  11607. break;
  11608. case "七":
  11609. str = "7";
  11610. break;
  11611. case "八":
  11612. str = "8";
  11613. break;
  11614. case "九":
  11615. str = "9";
  11616. break;
  11617. case "十":
  11618. str = "10";
  11619. break;
  11620. case "十一":
  11621. str = "11";
  11622. break;
  11623. case "十二":
  11624. str = "12";
  11625. break;
  11626. }
  11627. return str;
  11628. }
  11629. // 高亮包含指定文字的部分
  11630. void HighlightText(Run run, string targetText, Color color)
  11631. {
  11632. string text = run.Text;
  11633. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11634. if (startIndex >= 0)
  11635. {
  11636. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11637. // 前部分
  11638. if (startIndex > 0)
  11639. {
  11640. Run beforeRun = (Run)run.Clone(true);
  11641. beforeRun.Text = text.Substring(0, startIndex);
  11642. parentParagraph.InsertBefore(beforeRun, run);
  11643. }
  11644. // 匹配部分
  11645. Run matchRun = (Run)run.Clone(true);
  11646. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11647. matchRun.Font.Color = color;
  11648. parentParagraph.InsertBefore(matchRun, run);
  11649. // 后部分
  11650. if (startIndex + targetText.Length < text.Length)
  11651. {
  11652. Run afterRun = (Run)run.Clone(true);
  11653. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11654. parentParagraph.InsertBefore(afterRun, run);
  11655. }
  11656. // 删除原始Run
  11657. run.Remove();
  11658. }
  11659. }
  11660. #endregion
  11661. #endregion
  11662. #region 团组成本
  11663. /// <summary>
  11664. /// 团组成本数据初始化
  11665. /// </summary>
  11666. /// <param name="dto"></param>
  11667. /// <returns></returns>
  11668. [HttpPost]
  11669. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11670. {
  11671. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11672. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11673. WHEN COUNT(*) >= 0 THEN 'True'
  11674. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11675. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11676. ").ToList(); //团组列表
  11677. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11678. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11679. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11680. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11681. if (groupinfoValue != null)
  11682. {
  11683. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11684. var spArr = new string[1] { countryArr };
  11685. if (countryArr.Contains("|"))
  11686. {
  11687. spArr = countryArr.Split("|");
  11688. }
  11689. else if (countryArr.Contains("、"))
  11690. {
  11691. spArr = countryArr.Split("、");
  11692. }
  11693. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11694. {
  11695. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11696. if (dbQueryCountry != null)
  11697. {
  11698. visaCountryInfoArr.Add(dbQueryCountry);
  11699. }
  11700. }
  11701. }
  11702. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11703. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11704. var create = _GroupCostRepository.
  11705. CreateGroupCostByBlackCode(dto.Diid);
  11706. if (groupCost.Count == 0 && create.Code == 0)
  11707. {
  11708. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11709. }
  11710. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11711. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11712. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11713. groupCostMap = groupCostMap.Select(x =>
  11714. {
  11715. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11716. {
  11717. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11718. }
  11719. return x;
  11720. }).ToList();
  11721. //GroupCostParameter.Add(new
  11722. // Grp_GroupCostParameter());
  11723. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11724. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11725. return Ok(JsonView(new
  11726. {
  11727. groupList,
  11728. groupInfo,
  11729. groupChecks,
  11730. groupCost = groupCostMap,
  11731. hotelNumber,
  11732. GroupCostParameter = GroupCostParameterMap,
  11733. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11734. {
  11735. x.VisaCountry,
  11736. x.VisaPrice,
  11737. x.Id,
  11738. }).ToList(),
  11739. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11740. blackCodeIsTrue = create.Code == 0 ? true : false,
  11741. hotelIsTrue = hotelIsTrue,
  11742. }));
  11743. }
  11744. /// <summary>
  11745. /// 团组成本信息保存
  11746. /// </summary>
  11747. /// <param name="dto"></param>
  11748. /// <returns></returns>
  11749. [HttpPost]
  11750. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11751. {
  11752. if (dto.Diid <= 0 || dto.Userid <= 0)
  11753. {
  11754. return Ok(JsonView(false));
  11755. }
  11756. JsonView jw = null;
  11757. bool isTrue = false;
  11758. #region 复制团组成本
  11759. //if (dto.Diid == 2581)
  11760. //{
  11761. // dto.Diid = 2599;
  11762. // dto.CheckBoxs.ForEach(x =>
  11763. // {
  11764. // x.Diid = 2599;
  11765. // });
  11766. // dto.GroupCosts.ForEach(x =>
  11767. // {
  11768. // x.Diid = 2599;
  11769. // });
  11770. // dto.CostTypeHotelNumbers.ForEach(x =>
  11771. // {
  11772. // x.Diid = 2599;
  11773. // });
  11774. // dto.GroupCostParameters.ForEach(x =>
  11775. // {
  11776. // x.DiId = 2599;
  11777. // });
  11778. //}
  11779. #endregion
  11780. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11781. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11782. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11783. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11784. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11785. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11786. try
  11787. {
  11788. _sqlSugar.BeginTran();
  11789. isTrue = await _GroupCostRepository.
  11790. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11791. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11792. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11793. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11794. _sqlSugar.CommitTran();
  11795. jw = JsonView(true, "保存成功!", isTrue);
  11796. }
  11797. catch (Exception)
  11798. {
  11799. _sqlSugar.RollbackTran();
  11800. jw = JsonView(false);
  11801. }
  11802. return Ok(jw);
  11803. }
  11804. /// <summary>
  11805. /// 司兼导数据
  11806. /// </summary>
  11807. /// <param name="dto"></param>
  11808. /// <returns></returns>
  11809. [HttpPost]
  11810. public IActionResult GetCarGuides(CarGuidesDto dto)
  11811. {
  11812. JsonView jw = null;
  11813. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11814. jw = JsonView(true, "获取成功!", Data);
  11815. return Ok(jw);
  11816. }
  11817. /// <summary>
  11818. /// 导游数据
  11819. /// </summary>
  11820. /// <param name="dto"></param>
  11821. /// <returns></returns>
  11822. [HttpPost]
  11823. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11824. {
  11825. JsonView jw = null;
  11826. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11827. // 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
  11828. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11829. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11830. jw = JsonView(true, "获取成功!", Data);
  11831. return Ok(jw);
  11832. }
  11833. /// <summary>
  11834. /// 成本车数据
  11835. /// </summary>
  11836. /// <param name="dto"></param>
  11837. /// <returns></returns>
  11838. [HttpPost]
  11839. public IActionResult GetCarInfo(CarGuidesDto dto)
  11840. {
  11841. JsonView jw = null;
  11842. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11843. jw = JsonView(true, "获取成功!", Data);
  11844. return Ok(jw);
  11845. }
  11846. /// <summary>
  11847. /// 景点数据
  11848. /// </summary>
  11849. /// <param name="dto"></param>
  11850. /// <returns></returns>
  11851. [HttpPost]
  11852. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11853. {
  11854. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11855. return Ok(JsonView(true, "获取成功!", Data));
  11856. }
  11857. /// <summary>
  11858. /// 成本通知
  11859. /// </summary>
  11860. /// <param name="dto"></param>
  11861. /// <returns></returns>
  11862. [HttpPost]
  11863. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11864. {
  11865. if (dto.Diid < 0)
  11866. {
  11867. return Ok(JsonView(false));
  11868. }
  11869. JsonView jw = null;
  11870. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11871. if (GroupCostParameter != null)
  11872. {
  11873. int IsShare = 0;
  11874. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11875. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11876. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11877. string msg = string.Empty;
  11878. if (isTrue)
  11879. {
  11880. if (IsShare == 0)
  11881. {
  11882. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11883. }
  11884. else
  11885. {
  11886. #region 企微通知对应岗位用户
  11887. try
  11888. {
  11889. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11890. }
  11891. catch (Exception ex)
  11892. {
  11893. }
  11894. #endregion
  11895. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11896. }
  11897. jw = JsonView(isTrue, msg, new { IsShare });
  11898. }
  11899. else
  11900. {
  11901. msg = "修改失败!";
  11902. jw = JsonView(isTrue, msg);
  11903. }
  11904. }
  11905. else
  11906. {
  11907. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11908. }
  11909. return Ok(jw);
  11910. }
  11911. /// <summary>
  11912. /// 导出报价单
  11913. /// </summary>
  11914. /// <param name="dto"></param>
  11915. /// <returns></returns>
  11916. [HttpPost]
  11917. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11918. {
  11919. if (dto.Diid == 0)
  11920. {
  11921. return Ok(JsonView(false, "请传递团组id"));
  11922. }
  11923. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11924. if (deleInfo.Code != 0)
  11925. {
  11926. return Ok(JsonView(false, "团组信息查询失败!"));
  11927. }
  11928. var di = deleInfo.Data as DelegationInfoWebView;
  11929. if (di != null)
  11930. {
  11931. di.TeamName = di.TeamName.Replace("|", "、");
  11932. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11933. //文件名
  11934. string strFileName = di.TeamName + "-收款账单.doc";
  11935. //获取模板
  11936. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11937. //载入模板
  11938. Document doc = new Document(tmppath);
  11939. decimal TotalPrice = 0.00M;
  11940. string itemStr = string.Empty;
  11941. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11942. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11943. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11944. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11945. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11946. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11947. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11948. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11949. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11950. foreach (var cost in groupCostType)
  11951. {
  11952. var List = cost.ToList();
  11953. if (cost.Key == "A")
  11954. {
  11955. foreach (var ListItem in List)
  11956. {
  11957. if (ListItem.number > 0)
  11958. {
  11959. if (ListItem.code.Contains("TBR"))
  11960. {
  11961. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11962. }
  11963. else
  11964. {
  11965. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11966. }
  11967. TotalPrice += (ListItem.number * ListItem.price);
  11968. }
  11969. }
  11970. }
  11971. else
  11972. {
  11973. itemStr = itemStr.Insert(0, "A段\r\n");
  11974. itemStr += "B段\r\n";
  11975. foreach (var ListItem in List)
  11976. {
  11977. if (ListItem.number > 0)
  11978. {
  11979. if (ListItem.code.Contains("TBR"))
  11980. {
  11981. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11982. }
  11983. else
  11984. {
  11985. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11986. }
  11987. TotalPrice += (ListItem.number * ListItem.price);
  11988. }
  11989. }
  11990. }
  11991. }
  11992. #region 替换Word模板书签内容
  11993. Dictionary<string, string> marks = new Dictionary<string, string>();
  11994. marks.Add("To", di.ClientUnit);//付款方
  11995. marks.Add("ToTel", di.TellPhone);//付款方电话
  11996. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  11997. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  11998. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  11999. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  12000. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  12001. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  12002. marks.Add("PayItemContent", itemStr);//详细信息
  12003. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  12004. #endregion
  12005. ////注
  12006. //if (doc.Range.Bookmarks["Attention"] != null)
  12007. //{
  12008. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  12009. // mark.Text = frList[0].Attention;
  12010. //}
  12011. foreach (var item in marks.Keys)
  12012. {
  12013. if (doc.Range.Bookmarks[item] != null)
  12014. {
  12015. Bookmark mark = doc.Range.Bookmarks[item];
  12016. mark.Text = marks[item];
  12017. }
  12018. }
  12019. byte[] bytes = null;
  12020. using (MemoryStream stream = new MemoryStream())
  12021. {
  12022. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  12023. bytes = stream.ToArray();
  12024. }
  12025. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  12026. return Ok(JsonView(true, "", new
  12027. {
  12028. Data = bytes,
  12029. strFileName,
  12030. }));
  12031. }
  12032. else
  12033. {
  12034. return Ok(JsonView(false, "团组信息不存在!"));
  12035. }
  12036. }
  12037. /// <summary>
  12038. /// 导出团组成本
  12039. /// </summary>
  12040. /// <param name="dto"></param>
  12041. /// <returns></returns>
  12042. [HttpPost]
  12043. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  12044. {
  12045. var jw = JsonView(false);
  12046. if (dto.Diid == 0)
  12047. {
  12048. return Ok(JsonView(false, "请传递团组id"));
  12049. }
  12050. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12051. if (deleInfo.Code != 0)
  12052. {
  12053. return Ok(JsonView(false, "团组信息查询失败!"));
  12054. }
  12055. var di = deleInfo.Data as DelegationInfoWebView;
  12056. if (di == null)
  12057. {
  12058. return Ok(JsonView(false, "团组信息查询失败!"));
  12059. }
  12060. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12061. WorkbookDesigner designer = new WorkbookDesigner();
  12062. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12063. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12064. for (int i = 0; i < List_GC.Count; i++)
  12065. {
  12066. GroupCost_Excel gc = new GroupCost_Excel();
  12067. gc.Id = List_GC[i].Id;
  12068. gc.Diid = List_GC[i].Diid.ToString();
  12069. gc.DAY = List_GC[i].DAY;
  12070. string week = "";
  12071. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12072. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12073. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12074. gc.ITIN = List_GC[i].ITIN;
  12075. gc.CarType = List_GC[i].CarType;
  12076. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12077. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12078. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12079. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12080. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12081. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12082. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12083. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12084. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12085. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12086. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12087. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12088. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12089. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12090. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12091. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12092. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12093. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12094. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12095. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12096. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12097. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12098. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12099. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12100. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12101. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12102. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12103. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12104. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12105. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12106. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12107. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12108. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12109. List_GC1.Add(gc);
  12110. }
  12111. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12112. dt.TableName = "TB";
  12113. //报表标题等不用dt的值
  12114. designer.SetDataSource("TeamName", dto.title.TeamName);
  12115. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12116. designer.SetDataSource("Tax", dto.title.Tax);
  12117. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12118. designer.SetDataSource("Currency", dto.title.Currency);
  12119. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12120. designer.SetDataSource("Rate", dto.title.Rate);
  12121. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12122. var Aparams = hotels.Find(x => x.Type == "Default");
  12123. if (Aparams == null)
  12124. {
  12125. return Ok(jw);
  12126. }
  12127. //酒店数量
  12128. var txtSGRNumber = Aparams.SGR.ToString();
  12129. var txtTBRNumber = Aparams.TBR.ToString();
  12130. var txtJSESNumber = Aparams.JSES.ToString();
  12131. var txtSUITENumbe = Aparams.SUITE.ToString();
  12132. if (dto.costType == "B")
  12133. {
  12134. Aparams = hotels.Find(x => x.Type == "A");
  12135. var Bparams = hotels.Find(x => x.Type == "B");
  12136. if (Aparams == null || Bparams == null)
  12137. {
  12138. return Ok(jw);
  12139. }
  12140. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12141. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12142. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12143. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12144. }
  12145. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12146. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12147. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12148. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12149. var ws = designer.Workbook.Worksheets[0];
  12150. int Row = List_GC.Count;
  12151. int startIndex = 11;
  12152. int HideRows = 0;
  12153. List<int> hideRowsList = new List<int>();
  12154. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12155. #region A段left数据
  12156. var left = dto.leftInfo.Find(x => x.Type == "A");
  12157. if (left == null)
  12158. {
  12159. return Ok(jw);
  12160. }
  12161. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12162. if (leftBindData != null)
  12163. {
  12164. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12165. designer.SetDataSource("VisaRS", leftBindData.rs);
  12166. designer.SetDataSource("VisaXS", leftBindData.xs);
  12167. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12168. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12169. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12170. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12171. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12172. }
  12173. else
  12174. {
  12175. hideRowsList.Add(Row + startIndex + HideRows);
  12176. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12177. }
  12178. HideRows += 2;
  12179. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12180. if (leftBindData != null)
  12181. {
  12182. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12183. designer.SetDataSource("BXRS", leftBindData.rs);
  12184. designer.SetDataSource("BXXS", leftBindData.xs);
  12185. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12186. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12187. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12188. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12189. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12190. }
  12191. else
  12192. {
  12193. hideRowsList.Add(Row + startIndex + HideRows);
  12194. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12195. }
  12196. HideRows += 2;
  12197. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12198. if (leftBindData != null)
  12199. {
  12200. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12201. designer.SetDataSource("HSRS", leftBindData.rs);
  12202. designer.SetDataSource("HSXS", leftBindData.xs);
  12203. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12204. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12205. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12206. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12207. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12208. }
  12209. else
  12210. {
  12211. hideRowsList.Add(Row + startIndex + HideRows);
  12212. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12213. }
  12214. HideRows += 2;
  12215. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12216. if (leftBindData != null)
  12217. {
  12218. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12219. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12220. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12221. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12222. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12223. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12224. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12225. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12226. }
  12227. else
  12228. {
  12229. hideRowsList.Add(Row + startIndex + HideRows);
  12230. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12231. }
  12232. HideRows += 2;
  12233. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12234. if (leftBindData != null)
  12235. {
  12236. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12237. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12238. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12239. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12240. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12241. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12242. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12243. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12244. }
  12245. else
  12246. {
  12247. hideRowsList.Add(Row + startIndex + HideRows);
  12248. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12249. }
  12250. HideRows += 2;
  12251. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12252. if (leftBindData != null)
  12253. {
  12254. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12255. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12256. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12257. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12258. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12259. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12260. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12261. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12262. }
  12263. else
  12264. {
  12265. hideRowsList.Add(Row + startIndex + HideRows);
  12266. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12267. }
  12268. HideRows += 2;
  12269. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12270. if (leftBindData != null)
  12271. {
  12272. ////TBR
  12273. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12274. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12275. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12276. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12277. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12278. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12279. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12280. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12281. }
  12282. else
  12283. {
  12284. hideRowsList.Add(Row + startIndex + HideRows);
  12285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12286. }
  12287. HideRows += 2;
  12288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12289. if (leftBindData != null)
  12290. {
  12291. ////SGR
  12292. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12293. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12294. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12295. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12296. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12297. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12298. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12299. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12300. }
  12301. else
  12302. {
  12303. hideRowsList.Add(Row + startIndex + HideRows);
  12304. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12305. }
  12306. HideRows += 2;
  12307. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12308. if (leftBindData != null)
  12309. {
  12310. ////JS/ES
  12311. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12312. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12313. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12314. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12315. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12316. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12317. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12318. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12319. }
  12320. else
  12321. {
  12322. hideRowsList.Add(Row + startIndex + HideRows);
  12323. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12324. }
  12325. HideRows += 2;
  12326. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12327. if (leftBindData != null)
  12328. {
  12329. ////SUITE
  12330. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12331. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12332. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12333. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12334. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12335. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12336. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12337. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12338. }
  12339. else
  12340. {
  12341. hideRowsList.Add(Row + startIndex + HideRows);
  12342. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12343. }
  12344. HideRows += 2;
  12345. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12346. if (leftBindData != null)
  12347. {
  12348. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12349. designer.SetDataSource("DJRS", leftBindData.rs);
  12350. designer.SetDataSource("DJXS", leftBindData.xs);
  12351. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12352. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12353. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12354. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12355. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12356. }
  12357. else
  12358. {
  12359. hideRowsList.Add(Row + startIndex + HideRows);
  12360. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12361. }
  12362. HideRows += 2;
  12363. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12364. if (leftBindData != null)
  12365. {
  12366. designer.SetDataSource("HCPCB", leftBindData.cb);
  12367. designer.SetDataSource("HCPRS", leftBindData.rs);
  12368. designer.SetDataSource("HCPXS", leftBindData.xs);
  12369. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12370. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12371. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12372. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12373. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12374. }
  12375. else
  12376. {
  12377. hideRowsList.Add(Row + startIndex + HideRows);
  12378. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12379. }
  12380. HideRows += 2;
  12381. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12382. if (leftBindData != null)
  12383. {
  12384. designer.SetDataSource("CPCB", leftBindData.cb);
  12385. designer.SetDataSource("CPRS", leftBindData.rs);
  12386. designer.SetDataSource("CPXS", leftBindData.xs);
  12387. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12388. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12389. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12390. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12391. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12392. }
  12393. else
  12394. {
  12395. hideRowsList.Add(Row + startIndex + HideRows);
  12396. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12397. }
  12398. HideRows += 2;
  12399. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12400. if (leftBindData != null)
  12401. {
  12402. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12403. designer.SetDataSource("GWRS", leftBindData.rs);
  12404. designer.SetDataSource("GWXS", leftBindData.xs);
  12405. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12406. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12407. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12408. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12409. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12410. }
  12411. else
  12412. {
  12413. hideRowsList.Add(Row + startIndex + HideRows);
  12414. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12415. }
  12416. HideRows += 2;
  12417. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12418. if (leftBindData != null)
  12419. {
  12420. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12421. designer.SetDataSource("LYJRS", leftBindData.rs);
  12422. designer.SetDataSource("LYJXS", leftBindData.xs);
  12423. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12424. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12425. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12426. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12427. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12428. }
  12429. else
  12430. {
  12431. hideRowsList.Add(Row + startIndex + HideRows);
  12432. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12433. }
  12434. #endregion
  12435. #region A段Right信息
  12436. var right = dto.rightInfo.Find(x => x.Type == "A");
  12437. if (right == null)
  12438. {
  12439. return Ok(jw);
  12440. }
  12441. HideRows += 4;
  12442. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12443. if (rightBindData != null)
  12444. {
  12445. //经济舱 + 双人间 TBR
  12446. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12447. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12448. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12449. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12450. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12451. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12452. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12453. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12454. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12455. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12456. }
  12457. else
  12458. {
  12459. hideRowsList.Add(Row + startIndex + HideRows);
  12460. }
  12461. HideRows += 2;
  12462. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12463. if (rightBindData != null)
  12464. {
  12465. //经济舱 + 单人间 SGR
  12466. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12467. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12468. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12469. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12470. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12471. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12472. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12473. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12474. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12475. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12476. }
  12477. else
  12478. {
  12479. hideRowsList.Add(Row + startIndex + HideRows);
  12480. }
  12481. HideRows += 2;
  12482. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12483. if (rightBindData != null)
  12484. {
  12485. //公务舱 + 单人间 SGR
  12486. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12487. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12488. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12489. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12490. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12491. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12492. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12493. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12494. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12495. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12496. }
  12497. else
  12498. {
  12499. hideRowsList.Add(Row + startIndex + HideRows);
  12500. }
  12501. HideRows += 2;
  12502. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12503. if (rightBindData != null)
  12504. {
  12505. //公务舱 + 小套房 JSES
  12506. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12507. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12508. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12509. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12510. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12511. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12512. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12513. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12514. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12515. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12516. }
  12517. else
  12518. {
  12519. hideRowsList.Add(Row + startIndex + HideRows);
  12520. }
  12521. HideRows += 2;
  12522. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12523. if (rightBindData != null)
  12524. {
  12525. //公务舱 + 小套房 JSES
  12526. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12527. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12528. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12529. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12530. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12531. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12532. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12533. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12534. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12535. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12536. }
  12537. else
  12538. {
  12539. hideRowsList.Add(Row + startIndex + HideRows);
  12540. }
  12541. HideRows += 2;
  12542. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12543. if (rightBindData != null)
  12544. {
  12545. //经济舱 + 大套房
  12546. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12547. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12548. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12549. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12550. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12551. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12552. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12553. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12554. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12555. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12556. }
  12557. else
  12558. {
  12559. hideRowsList.Add(Row + startIndex + HideRows);
  12560. }
  12561. HideRows += 2;
  12562. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12563. if (rightBindData != null)
  12564. {
  12565. //头等舱 + 小套房 JSES
  12566. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12567. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12568. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12569. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12570. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12571. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12572. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12573. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12574. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12575. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12576. }
  12577. else
  12578. {
  12579. hideRowsList.Add(Row + startIndex + HideRows);
  12580. }
  12581. HideRows += 2;
  12582. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12583. if (rightBindData != null)
  12584. {
  12585. //头等舱 + 大套房
  12586. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12587. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12588. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12589. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12590. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12591. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12592. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12593. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12594. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12595. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12596. }
  12597. else
  12598. {
  12599. hideRowsList.Add(Row + startIndex + HideRows);
  12600. }
  12601. #endregion
  12602. #region B段标题清空
  12603. designer.SetDataSource("CostBDRCB", "");
  12604. designer.SetDataSource("CostBRS", "");
  12605. designer.SetDataSource("CostBXS", "");
  12606. designer.SetDataSource("CostBZCB", "");
  12607. designer.SetDataSource("CostBDRBJ", "");
  12608. designer.SetDataSource("CostBZBJ", "");
  12609. designer.SetDataSource("CostBDRLR", "");
  12610. designer.SetDataSource("CostBZLR", "");
  12611. designer.SetDataSource("CostBDRCBOM", "");
  12612. designer.SetDataSource("CostBRSOM", "");
  12613. designer.SetDataSource("CostBZCBOM", "");
  12614. designer.SetDataSource("CostBDRBJOM", "");
  12615. designer.SetDataSource("CostBZBJOM", "");
  12616. designer.SetDataSource("CostBDRLROM", "");
  12617. designer.SetDataSource("CostBZLROM", "");
  12618. #endregion
  12619. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12620. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12621. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12622. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12623. designer.SetDataSource("DJName", "地接(CNY)");
  12624. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12625. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12626. designer.SetDataSource("GWName", "公务(CNY)");
  12627. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12628. designer.SetDataSource("LYJName", "零用金(CNY)");
  12629. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12630. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12631. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12632. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12633. designer.SetDataSource("BXName", "保险(CNY)");
  12634. designer.SetDataSource("VisaName", "签证(CNY)");
  12635. #region B段基本数据
  12636. if (dto.costType == "B")
  12637. {
  12638. left = dto.leftInfo.Find(x => x.Type == "B");
  12639. if (left == null)
  12640. {
  12641. return Ok(jw);
  12642. }
  12643. #region B段left数据
  12644. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12645. if (leftBindData != null)
  12646. {
  12647. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12648. designer.SetDataSource("BHSRS", leftBindData.rs);
  12649. designer.SetDataSource("BHSXS", leftBindData.xs);
  12650. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12651. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12652. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12653. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12654. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12655. }
  12656. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12657. if (leftBindData != null)
  12658. {
  12659. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12660. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12661. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12662. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12663. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12664. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12665. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12666. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12667. }
  12668. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12669. if (leftBindData != null)
  12670. {
  12671. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12672. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12673. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12674. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12675. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12676. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12677. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12678. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12679. }
  12680. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12681. if (leftBindData != null)
  12682. {
  12683. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12684. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12685. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12686. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12687. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12688. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12689. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12690. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12691. }
  12692. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12693. if (leftBindData != null)
  12694. {
  12695. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12696. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12697. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12698. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12699. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12700. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12701. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12702. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12703. }
  12704. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12705. if (leftBindData != null)
  12706. {
  12707. designer.SetDataSource("BCPCB", leftBindData.cb);
  12708. designer.SetDataSource("BCPRS", leftBindData.rs);
  12709. designer.SetDataSource("BCPXS", leftBindData.xs);
  12710. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12711. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12712. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12713. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12714. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12715. }
  12716. //TBR
  12717. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12718. if (leftBindData != null)
  12719. {
  12720. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12721. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12722. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12723. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12724. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12725. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12726. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12727. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12728. }
  12729. //SGR
  12730. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12731. if (leftBindData != null)
  12732. {
  12733. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12734. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12735. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12736. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12737. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12738. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12739. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12740. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12741. }
  12742. //JS/ES
  12743. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12744. if (leftBindData != null)
  12745. {
  12746. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12747. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12748. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12749. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12750. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12751. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12752. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12753. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12754. }
  12755. //SUITE
  12756. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12757. if (leftBindData != null)
  12758. {
  12759. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12760. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12761. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12762. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12763. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12764. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12765. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12766. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12767. }
  12768. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12769. if (leftBindData != null)
  12770. {
  12771. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12772. designer.SetDataSource("BDJRS", leftBindData.rs);
  12773. designer.SetDataSource("BDJXS", leftBindData.xs);
  12774. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12775. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12776. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12777. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12778. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12779. }
  12780. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12781. if (leftBindData != null)
  12782. {
  12783. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12784. designer.SetDataSource("BGWRS", leftBindData.rs);
  12785. designer.SetDataSource("BGWXS", leftBindData.xs);
  12786. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12787. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12788. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12789. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12790. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12791. }
  12792. #region 优化方案
  12793. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12794. //excelBind.Add("零用金", new {
  12795. //cb="",
  12796. //rs="",
  12797. //xs ="",
  12798. //zcb = "",
  12799. //});
  12800. #endregion
  12801. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12802. if (leftBindData != null)
  12803. {
  12804. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12805. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12806. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12807. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12808. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12809. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12810. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12811. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12812. }
  12813. #endregion
  12814. #region B段Right信息
  12815. right = dto.rightInfo.Find(x => x.Type == "B");
  12816. if (right == null)
  12817. {
  12818. return Ok(jw);
  12819. }
  12820. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12821. if (rightBindData != null)
  12822. {
  12823. //经济舱 + 双人间 TBR
  12824. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12825. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12826. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12827. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12828. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12829. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12830. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12831. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12832. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12833. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12834. }
  12835. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12836. if (rightBindData != null)
  12837. {
  12838. //经济舱 + 单人间 SGR
  12839. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12840. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12841. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12842. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12843. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12844. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12845. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12846. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12847. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12848. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12849. }
  12850. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12851. if (rightBindData != null)
  12852. {
  12853. //公务舱 + 单人间 SGR
  12854. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12855. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12856. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12857. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12858. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12859. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12860. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12861. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12862. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12863. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12864. }
  12865. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12866. if (rightBindData != null)
  12867. {
  12868. //公务舱 + 小套房 JSES
  12869. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12870. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12871. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12872. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12873. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12874. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12875. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12876. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12877. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12878. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12879. }
  12880. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12881. if (rightBindData != null)
  12882. {
  12883. //公务舱 + 小套房 JSES
  12884. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12885. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12886. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12887. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12888. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12889. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12890. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12891. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12892. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12893. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12894. }
  12895. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12896. if (rightBindData != null)
  12897. {
  12898. //经济舱 + 大套房
  12899. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12900. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12901. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12902. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12903. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12904. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12905. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12906. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12907. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12908. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12909. }
  12910. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12911. if (rightBindData != null)
  12912. {
  12913. //头等舱 + 小套房 JSES
  12914. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12915. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12916. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12917. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12918. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12919. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12920. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12921. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12922. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12923. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12924. }
  12925. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12926. if (rightBindData != null)
  12927. {
  12928. //头等舱 + 大套房
  12929. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12930. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12931. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12932. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12933. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12934. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12935. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12936. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12937. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12938. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12939. }
  12940. #endregion
  12941. #region 标题
  12942. designer.SetDataSource("CostBDRCB", "单人成本");
  12943. designer.SetDataSource("CostBRS", "人数");
  12944. designer.SetDataSource("CostBXS", "系数");
  12945. designer.SetDataSource("CostBZCB", "总成本");
  12946. designer.SetDataSource("CostBDRBJ", "单人报价");
  12947. designer.SetDataSource("CostBZBJ", "总报价");
  12948. designer.SetDataSource("CostBDRLR", "单人利润");
  12949. designer.SetDataSource("CostBZLR", "总利润");
  12950. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12951. designer.SetDataSource("CostBRSOM", "人数");
  12952. designer.SetDataSource("CostBZCBOM", "总成本");
  12953. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12954. designer.SetDataSource("CostBZBJOM", "总报价");
  12955. designer.SetDataSource("CostBDRLROM", "单人利润");
  12956. designer.SetDataSource("CostBZLROM", "总利润");
  12957. #endregion
  12958. }
  12959. #endregion
  12960. designer.SetDataSource("TzZCB2", TzZCB2);
  12961. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12962. designer.SetDataSource("TzZLR2", TzZLR2);
  12963. string[] dataSourceKeys = new string[]
  12964. {
  12965. "VF",
  12966. "TGS",
  12967. "TGOF",
  12968. "TGM",
  12969. "TGA",
  12970. "TGTF",
  12971. "TGEF",
  12972. "CFM",
  12973. "CFOF",
  12974. "B",
  12975. "L",
  12976. "D",
  12977. "TBR",
  12978. "SGR",
  12979. "JSES",
  12980. "Suite",
  12981. "TV",
  12982. "1L",
  12983. "IF",
  12984. "EF",
  12985. "BRF",
  12986. "TE",
  12987. "TGT",
  12988. "DRVT",
  12989. "PC",
  12990. "TLF",
  12991. "ECT"
  12992. };
  12993. foreach (var item in dataSourceKeys)
  12994. {
  12995. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  12996. if (find != null)
  12997. {
  12998. designer.SetDataSource(item, find.text);
  12999. }
  13000. else
  13001. {
  13002. designer.SetDataSource(item, 0);
  13003. }
  13004. }
  13005. designer.SetDataSource(dt);
  13006. //根据数据源处理生成报表内容
  13007. designer.Process();
  13008. designer.Workbook.Worksheets[0].Name = "清单";
  13009. Worksheet sheet = designer.Workbook.Worksheets[0];
  13010. foreach (var Rowindex in hideRowsList)
  13011. {
  13012. ws.Cells.HideRows(Rowindex, 2);
  13013. }
  13014. byte[] bytes = null;
  13015. string strFileName = di.TeamName + "-团组-成本.xls";
  13016. using (MemoryStream stream = new MemoryStream())
  13017. {
  13018. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  13019. bytes = stream.ToArray();
  13020. }
  13021. return Ok(JsonView(true, "", new
  13022. {
  13023. Data = bytes,
  13024. strFileName,
  13025. }));
  13026. }
  13027. /// <summary>
  13028. /// 导出客户报表
  13029. /// </summary>
  13030. /// <returns></returns>
  13031. [HttpPost]
  13032. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  13033. {
  13034. var jw = JsonView(false);
  13035. if (dto.Diid == 0)
  13036. {
  13037. return Ok(JsonView(false, "请传递团组id"));
  13038. }
  13039. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  13040. if (deleInfo.Code != 0)
  13041. {
  13042. return Ok(JsonView(false, "团组信息查询失败!"));
  13043. }
  13044. var di = deleInfo.Data as DelegationInfoWebView;
  13045. if (di == null)
  13046. {
  13047. return Ok(JsonView(false, "团组信息查询失败!"));
  13048. }
  13049. //文件名
  13050. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  13051. //获取模板
  13052. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13053. //载入模板
  13054. Document doc = new Document(tmppath);
  13055. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13056. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13057. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13058. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13059. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13060. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13061. if (AParameter == null)
  13062. {
  13063. return Ok(JsonView(false, "系数不存在!"));
  13064. }
  13065. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13066. , TzAirDesc, TzZCost;
  13067. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13068. = TzAirDesc = TzZCost = string.Empty;
  13069. TzNumber = AParameter.CostTypenumber.ToString();
  13070. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13071. CarGuides1 = dto.CarGuides1;
  13072. Meal = dto.Meal;
  13073. SubsidizedMeals = dto.SubsidizedMeals;
  13074. NightRepair = dto.NightRepair;
  13075. AttractionsTickets = dto.AttractionsTickets;
  13076. MiscellaneousFees = dto.MiscellaneousFees;
  13077. ATip = dto.ATip;
  13078. TzHotelDesc = "";
  13079. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13080. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13081. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13082. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13083. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13084. TzAirDesc = "";
  13085. TzZCost = dto.TzZCost;
  13086. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13087. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13088. var index = 1;
  13089. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13090. foreach (var item in TzHotelDescArr)
  13091. {
  13092. if (AinfoArr != null)
  13093. {
  13094. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13095. if (Ainfo != null)
  13096. {
  13097. if (int.Parse(Ainfo.rs) <= 0)
  13098. {
  13099. continue;
  13100. }
  13101. var hotelText = string.Empty;
  13102. switch (item)
  13103. {
  13104. case "SGR":
  13105. hotelText = "单人间";
  13106. break;
  13107. case "JSES":
  13108. hotelText = "小套房";
  13109. break;
  13110. case "SUITE":
  13111. hotelText = "套房";
  13112. break;
  13113. case "TBR":
  13114. hotelText = "双人间";
  13115. break;
  13116. }
  13117. if (item != "TBR")
  13118. {
  13119. 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";
  13120. }
  13121. else
  13122. {
  13123. 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";
  13124. }
  13125. index++;
  13126. }
  13127. }
  13128. }
  13129. index = 1;
  13130. foreach (var item in TzAirDescArr)
  13131. {
  13132. if (AinfoArr != null)
  13133. {
  13134. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13135. if (Ainfo != null)
  13136. {
  13137. if (int.Parse(Ainfo.rs) <= 0)
  13138. {
  13139. continue;
  13140. }
  13141. 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";
  13142. index++;
  13143. }
  13144. }
  13145. }
  13146. if (dto.costType == "B")
  13147. {
  13148. if (BParameter == null)
  13149. {
  13150. return Ok(JsonView(false, "B段系数不存在!"));
  13151. }
  13152. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13153. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13154. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13155. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13156. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13157. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13158. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13159. foreach (var item in TzHotelDescArr)
  13160. {
  13161. if (AinfoArr != null)
  13162. {
  13163. TzHotelDesc += "B段信息 \r\n";
  13164. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13165. if (Ainfo != null)
  13166. {
  13167. if (int.Parse(Ainfo.rs) <= 0)
  13168. {
  13169. continue;
  13170. }
  13171. var hotelText = string.Empty;
  13172. switch (item)
  13173. {
  13174. case "SGR":
  13175. hotelText = "单人间";
  13176. break;
  13177. case "JSES":
  13178. hotelText = "小套房";
  13179. break;
  13180. case "SUITE":
  13181. hotelText = "套房";
  13182. break;
  13183. case "TBR":
  13184. hotelText = "双人间";
  13185. break;
  13186. }
  13187. if (item != "TBR")
  13188. {
  13189. 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";
  13190. }
  13191. else
  13192. {
  13193. 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";
  13194. }
  13195. index++;
  13196. }
  13197. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13198. }
  13199. }
  13200. index = 1;
  13201. foreach (var item in TzAirDescArr)
  13202. {
  13203. if (AinfoArr != null)
  13204. {
  13205. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13206. if (Ainfo != null)
  13207. {
  13208. if (int.Parse(Ainfo.rs) <= 0)
  13209. {
  13210. continue;
  13211. }
  13212. 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";
  13213. index++;
  13214. }
  13215. }
  13216. }
  13217. }
  13218. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13219. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13220. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13221. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13222. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13223. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13224. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13225. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13226. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13227. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13228. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13229. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13230. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13231. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13232. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13233. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13234. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13235. DickeyValue.Add("TzZCost", TzZCost);
  13236. foreach (var key in DickeyValue.Keys)
  13237. {
  13238. if (doc.Range.Bookmarks[key] != null)
  13239. {
  13240. Bookmark mark = doc.Range.Bookmarks[key];
  13241. mark.Text = DickeyValue[key];
  13242. }
  13243. }
  13244. byte[] bytes = null;
  13245. string strFileName = di.TeamName + "-客户报价.doc";
  13246. using (MemoryStream stream = new MemoryStream())
  13247. {
  13248. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13249. bytes = stream.ToArray();
  13250. }
  13251. return Ok(JsonView(true, "", new
  13252. {
  13253. Data = bytes,
  13254. strFileName,
  13255. }));
  13256. }
  13257. /// <summary>
  13258. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13259. /// </summary>
  13260. /// <param name="dto"></param>
  13261. /// <returns></returns>
  13262. [HttpPost]
  13263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13264. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13265. {
  13266. try
  13267. {
  13268. #region 参数验证
  13269. if (dto.DiId < 0)
  13270. {
  13271. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13272. }
  13273. List<int> cTableIds = new List<int>() {
  13274. 76 ,//酒店预订
  13275. 77 ,//行程
  13276. 79 ,//车/导游地接
  13277. 80 ,//签证
  13278. 81 ,//邀请/公务活
  13279. 82 ,//团组客户保险
  13280. 85 ,//机票预订
  13281. 98 ,//其他款项
  13282. 285 ,//收款退还
  13283. 751 ,//酒店早餐
  13284. 1015 // 超支费用
  13285. };
  13286. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13287. {
  13288. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13289. }
  13290. #endregion
  13291. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13292. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13293. if (_GroupCostParameters.Count <= 0)
  13294. {
  13295. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13296. }
  13297. if (_GroupCostParameters[0].IsShare == 0)
  13298. {
  13299. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13300. }
  13301. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13302. //处理date为空问题
  13303. if (_GroupCosts.Count > 0)
  13304. {
  13305. for (int i = 0; i < _GroupCosts.Count; i++)
  13306. {
  13307. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13308. {
  13309. if (i > 0)
  13310. {
  13311. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13312. }
  13313. }
  13314. }
  13315. }
  13316. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13317. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13318. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13319. string currCode = "";
  13320. #region currCode 验证
  13321. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13322. if (isInt)
  13323. {
  13324. var currData = currDatas.Find(it => it.Id == intCurrency);
  13325. if (currData != null)
  13326. {
  13327. currCode = currData.Name;
  13328. }
  13329. }
  13330. else
  13331. {
  13332. currCode = _GroupCostParameters[0].Currency.Trim();
  13333. }
  13334. #endregion
  13335. //op,酒店单段模式存储
  13336. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13337. {
  13338. CurrencyCode = currCode,
  13339. Rate = _GroupCostParameters[0].Rate,
  13340. CostType = _GroupCostParameters[0].CostType,
  13341. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13342. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13343. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13344. };
  13345. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13346. if (_GroupCostParameters.Count == 2)
  13347. {
  13348. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13349. }
  13350. foreach (var item in _GroupCostParameters)
  13351. {
  13352. decimal _rate = 1;
  13353. decimal _rate1 = item.Rate;
  13354. decimal _scale = 1;
  13355. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13356. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13357. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13358. //if (userInfo != null)
  13359. //{
  13360. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13361. // {
  13362. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13363. // {
  13364. // _scale = 1.00M;
  13365. // }
  13366. // }
  13367. //}
  13368. #endregion
  13369. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13370. {
  13371. CurrencyCode = currCode,
  13372. Rate = _rate1,
  13373. CostType = item.CostType,
  13374. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13375. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13376. CostTypeNumber = item.CostTypenumber
  13377. };
  13378. if (_GroupCostParameters.Count > 1)
  13379. {
  13380. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13381. }
  13382. else
  13383. {
  13384. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13385. }
  13386. if (dto.CTable == 79)//
  13387. {
  13388. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13389. modulePromptInfo.TotalCost = item.DJCB;
  13390. }
  13391. List<string> costTypes = new List<string>() { "A", "B" };
  13392. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13393. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13394. if (_GroupCostsDuplicates.Count() == 1)
  13395. {
  13396. _GroupCostsTypeData = _GroupCosts;
  13397. }
  13398. else
  13399. {
  13400. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13401. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13402. }
  13403. /*
  13404. * 76 酒店预订
  13405. * 77 行程
  13406. * 79 车/导游地接
  13407. * 80 签证
  13408. * 81 邀请/公务活动
  13409. * 82 团组客户保险
  13410. * 85 机票预订
  13411. * 98 其他款项
  13412. * 285 收款退还
  13413. * 751 酒店早餐
  13414. * 1015 超支费用
  13415. */
  13416. switch (dto.CTable)
  13417. {
  13418. case 76: // 酒店预订
  13419. _ModuleSubPromptInfo.AddRange(
  13420. _GroupCostsTypeData.Select(it => new
  13421. {
  13422. it.DAY,
  13423. it.Date,
  13424. it.ACCON,
  13425. it.ITIN,
  13426. it.SGR,
  13427. it.TBR,
  13428. it.JS_ES,
  13429. it.Suite
  13430. })
  13431. );
  13432. break;
  13433. case 79: // 车/导游地接
  13434. _ModuleSubPromptInfo.AddRange(
  13435. _GroupCostsTypeData.Select(it => new
  13436. {
  13437. Date = it.Date, //日期
  13438. CarFee = it.CarCost * _rate * _scale, //车费用
  13439. CarType = it.CarType, //车型
  13440. DriverFee = it.CFS * _rate * _scale, //司机工资
  13441. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13442. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13443. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13444. GuideFee = it.TGS * _rate * _scale, //导游费用
  13445. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13446. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13447. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13448. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13449. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13450. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13451. Breakfast = it.B * _rate * _scale, //早餐费
  13452. Lunch = it.L * _rate * _scale, //午餐费
  13453. Dinner = it.D * _rate * _scale, //晚餐费
  13454. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13455. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13456. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13457. TicketFee = it.EF * _rate * _scale, //门票费
  13458. TicketRemark = it.EFR, //门票费描述
  13459. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13460. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13461. SpentCash = it.PC * _rate * _scale, //零用金
  13462. LeadersFee = it.TLF * _rate * _scale, //领队费
  13463. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13464. })
  13465. );
  13466. break;
  13467. case 85: // 机票
  13468. List<dynamic> datas = new List<dynamic>();
  13469. datas.Add(
  13470. new
  13471. {
  13472. AirType = "经济舱",
  13473. AirNum = item.JJCRS,
  13474. AirDRCB = item.JJCCB,
  13475. AirZCB = (item.JJCRS * item.JJCCB)
  13476. }
  13477. );
  13478. datas.Add(
  13479. new
  13480. {
  13481. AirType = "公务舱",
  13482. AirNum = item.GWCRS,
  13483. AirDRCB = item.GWCCB,
  13484. AirZCB = (item.GWCRS * item.GWCCB)
  13485. }
  13486. );
  13487. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13488. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13489. modulePromptInfo.Data = new
  13490. {
  13491. airFeeData = datas,
  13492. airInitData = initDatas
  13493. };
  13494. _ModulePromptInfos.Add(modulePromptInfo);
  13495. break;
  13496. default:
  13497. break;
  13498. }
  13499. }
  13500. if (dto.CTable != 85)
  13501. {
  13502. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13503. _ModulePromptInfos.Add(_ModulePromptInfo);
  13504. }
  13505. _view.ModulePromptInfos = _ModulePromptInfos;
  13506. return Ok(JsonView(true, "操作成功!", _view));
  13507. }
  13508. catch (Exception ex)
  13509. {
  13510. return Ok(JsonView(false, ex.Message));
  13511. }
  13512. }
  13513. /// <summary>
  13514. /// 根据黑屏代码重新生成行程
  13515. /// </summary>
  13516. /// <param name="dto"></param>
  13517. /// <returns></returns>
  13518. [HttpPost]
  13519. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13520. {
  13521. var jw = JsonView(false);
  13522. var Create = _GroupCostRepository.
  13523. CreateGroupCostByBlackCode(dto.Diid);
  13524. jw.Msg = Create.Msg;
  13525. if (Create.Code == 0)
  13526. {
  13527. jw.Code = 200;
  13528. jw.Data = new
  13529. {
  13530. groupCost = Create.Data,
  13531. blackCodeIsTrue = true
  13532. };
  13533. }
  13534. else
  13535. {
  13536. jw.Code = 400;
  13537. jw.Data = new
  13538. {
  13539. groupCost = Create.Data,
  13540. blackCodeIsTrue = false,
  13541. };
  13542. }
  13543. return Ok(jw);
  13544. }
  13545. /// <summary>
  13546. /// 成本获取OP历史车费用
  13547. /// </summary>
  13548. /// <param name="dto"></param>
  13549. /// <returns></returns>
  13550. [HttpPost]
  13551. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13552. {
  13553. var jw = JsonView(false);
  13554. try
  13555. {
  13556. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13557. //获取现有所有车的数据
  13558. if (!dto.Param.IsNullOrWhiteSpace())
  13559. {
  13560. string sql = $@"
  13561. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13562. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13563. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13564. 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
  13565. AND gctggr.ServiceEndTime is not NULL
  13566. ORDER by gctggrc.id DESC
  13567. ";
  13568. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13569. var numeberResult = await Task.Run(() =>
  13570. {
  13571. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13572. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13573. return numberArr;
  13574. });
  13575. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13576. foreach (var item in numeberResult)
  13577. {
  13578. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13579. {
  13580. Country = "数据异常!",
  13581. City = string.Empty,
  13582. };
  13583. item.Area = find.Country + " " + find.City;
  13584. }
  13585. dbResult.AddRange(numeberResult);
  13586. if (dto.Param.Contains("、"))
  13587. {
  13588. var sp = dto.Param.Split("、");
  13589. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13590. .Where(x =>
  13591. {
  13592. return System.Array.Exists(sp, e =>
  13593. {
  13594. bool where = false;
  13595. if (x.Area != null)
  13596. {
  13597. where = x.Area.Contains(e);
  13598. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13599. {
  13600. return false;
  13601. }
  13602. }
  13603. if (x.PriceName != null && !where)
  13604. {
  13605. where = x.PriceName.Contains(e);
  13606. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13607. {
  13608. return false;
  13609. }
  13610. }
  13611. return where;
  13612. });
  13613. }).ToList();
  13614. }
  13615. else
  13616. {
  13617. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13618. .Where(x =>
  13619. {
  13620. bool where = false;
  13621. if (x.Area != null)
  13622. {
  13623. where = x.Area.Contains(dto.Param);
  13624. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13625. {
  13626. return false;
  13627. }
  13628. }
  13629. if (x.PriceName != null && !where)
  13630. {
  13631. where = x.PriceName.Contains(dto.Param);
  13632. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13633. {
  13634. return false;
  13635. }
  13636. }
  13637. return where;
  13638. }
  13639. )
  13640. .ToList();
  13641. }
  13642. }
  13643. var view = dbResult.Select(x =>
  13644. {
  13645. decimal dp = 0.00M;
  13646. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13647. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13648. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13649. {
  13650. if (startB && endB)
  13651. {
  13652. var timesp = endD.Subtract(startD);
  13653. if ((timesp.Days + 1) != 0)
  13654. {
  13655. dp = x.Price / (timesp.Days + 1);
  13656. }
  13657. }
  13658. }
  13659. else
  13660. {
  13661. dp = x.Price;
  13662. }
  13663. return new
  13664. {
  13665. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13666. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13667. x.Area,
  13668. x.id,
  13669. price = x.Price.ToString("F2"),
  13670. x.PriceName,
  13671. x.PriceContent,
  13672. x.TeamName,
  13673. x.DatePrice,
  13674. dayPrice = dp.ToString("F2"),
  13675. };
  13676. }).OrderByDescending(x => x.id).ToList();
  13677. jw = JsonView(true, "获取成功!", view);
  13678. }
  13679. catch (Exception e)
  13680. {
  13681. jw = JsonView(false, e.Message);
  13682. }
  13683. return Ok(jw);
  13684. }
  13685. #endregion
  13686. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13687. /// <summary>
  13688. /// 酒店预订
  13689. /// 酒店费用列表 根据团组Id查询
  13690. /// </summary>
  13691. /// <param name="_dto"></param>
  13692. /// <returns></returns>
  13693. [HttpPost]
  13694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13695. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13696. {
  13697. #region 参数验证
  13698. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13699. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13700. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13701. #region 团组操作权限验证 76 酒店预定模块
  13702. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13703. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13704. #endregion
  13705. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13706. #region 页面操作权限验证
  13707. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13708. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13709. #endregion
  13710. #endregion
  13711. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13712. }
  13713. /// <summary>
  13714. /// 酒店预订
  13715. /// 基础数据
  13716. /// </summary>
  13717. /// <param name="_dto"></param>
  13718. /// <returns></returns>
  13719. [HttpPost]
  13720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13721. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13722. {
  13723. #region 参数验证
  13724. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13725. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13726. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13727. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13728. #region 页面操作权限验证
  13729. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13730. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13731. #endregion
  13732. #region 团组操作权限验证 76 酒店预定模块
  13733. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13734. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13735. #endregion
  13736. #endregion
  13737. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13738. }
  13739. /// <summary>
  13740. /// 酒店预订
  13741. /// 创建 入住卷号码
  13742. /// </summary>
  13743. /// <param name="_dto"></param>
  13744. /// <returns></returns>
  13745. [HttpPost]
  13746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13747. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13748. {
  13749. #region 参数验证
  13750. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13751. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13752. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13753. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13754. #region 页面操作权限验证
  13755. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13756. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13757. #endregion
  13758. #region 团组操作权限验证 76 酒店预定模块
  13759. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13760. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13761. #endregion
  13762. #endregion
  13763. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13764. if (data.Code != 0)
  13765. {
  13766. return Ok(JsonView(false, data.Msg));
  13767. }
  13768. return Ok(JsonView(true, data.Msg, data.Data));
  13769. }
  13770. /// <summary>
  13771. /// 酒店预订
  13772. /// 详情
  13773. /// </summary>
  13774. /// <param name="_dto"></param>
  13775. /// <returns></returns>
  13776. [HttpPost]
  13777. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13778. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13779. {
  13780. #region 参数验证
  13781. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13782. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13783. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13784. #region 团组操作权限验证 76 酒店预定模块
  13785. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13786. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13787. #endregion
  13788. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13789. #region 页面操作权限验证
  13790. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13791. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13792. #endregion
  13793. #endregion
  13794. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13795. }
  13796. /// <summary>
  13797. /// 酒店预订
  13798. /// Add Or Edit
  13799. /// </summary>
  13800. /// <param name="_dto"></param>
  13801. /// <returns></returns>
  13802. [HttpPost]
  13803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13804. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13805. {
  13806. #region 参数验证
  13807. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13808. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13809. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13810. #region 团组操作权限验证 76 酒店预定模块
  13811. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13812. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13813. #endregion
  13814. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13815. #region 页面操作权限验证
  13816. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13817. if (_dto.Id == 0) // Add
  13818. {
  13819. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13820. }
  13821. else if (_dto.Id > 1) // Edit
  13822. {
  13823. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13824. }
  13825. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13826. #endregion
  13827. #endregion
  13828. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13829. if (_view.Code != 200)
  13830. {
  13831. return Ok(_view);
  13832. }
  13833. #region 成本无酒店价格数据进入超支
  13834. _sqlSugar.BeginTran();
  13835. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13836. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13837. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13838. for (int i = 0; i < groupCost.Count; i++)
  13839. {
  13840. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13841. {
  13842. groupCost[i].Date = groupCost[i - 1].Date;
  13843. }
  13844. }
  13845. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13846. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13847. List<Fin_GroupExtraCostDto_OP>();
  13848. if (start_Bool && end_Bool)
  13849. {
  13850. while (start_Time < end_Time)
  13851. {
  13852. foreach (var item in groupCost_Grp)
  13853. {
  13854. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13855. {
  13856. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13857. {
  13858. extraCostList.Add(new
  13859. Fin_GroupExtraCostDto_OP
  13860. {
  13861. Area = _dto.AreaId,
  13862. coefficient = 1.5M,
  13863. createUser = _dto.UserId,
  13864. currency = _dto.CardPriceCurrency,
  13865. diId = _dto.DiId,
  13866. ManagerConfirm = 0,
  13867. SupervisorConfirm = 0,
  13868. SYsupervisorConfirm = 0,
  13869. editType = 1,
  13870. PortType = 1,
  13871. price = _dto.CardPrice,
  13872. PriceCount = 1,
  13873. priceType = 1027,
  13874. priceDetailType = 1044,
  13875. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13876. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13877. });
  13878. }
  13879. }
  13880. }
  13881. start_Time = start_Time.AddDays(1);
  13882. }
  13883. }
  13884. if (extraCostList.Any())
  13885. {
  13886. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13887. }
  13888. _sqlSugar.CommitTran();
  13889. #endregion
  13890. #region 应用推送
  13891. try
  13892. {
  13893. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13894. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13895. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13896. var diId = _dto.DiId;
  13897. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13898. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13899. #region 操作记录
  13900. var opInfo = new Crm_TableOperationRecord() {
  13901. TableName = "Grp_HotelReservations",
  13902. PortType = _dto.PortType,
  13903. DataId = hotelId,
  13904. CreateUserId = _dto.UserId
  13905. };
  13906. var opStatus = OperationEnum.NoOperation;
  13907. if (_dto.Id<1) //添加操作
  13908. {
  13909. opInfo.OperationItem = OperationEnum.Add;
  13910. }
  13911. else if (_dto.Id > 0)
  13912. {
  13913. opInfo.OperationItem = OperationEnum.Edit;
  13914. }
  13915. string opRemark = string.Empty;
  13916. if (ccpInfo != null)
  13917. {
  13918. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13919. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13920. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13921. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13922. }
  13923. opInfo.Remark = opRemark;
  13924. await _tableorRep.AddAsync(opInfo);
  13925. #endregion
  13926. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13927. //2024-10-21 新增LZ UID
  13928. var userIds = new List<int>() { 21 };
  13929. string title = $"费用审核";
  13930. string content = "";
  13931. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13932. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13933. try
  13934. {
  13935. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13936. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13937. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13938. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13939. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13940. }
  13941. catch (Exception ex )
  13942. {
  13943. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13944. }
  13945. }
  13946. catch (Exception ex)
  13947. {
  13948. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13949. }
  13950. try
  13951. {
  13952. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13953. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13954. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13955. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13956. //自动审核
  13957. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13958. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13959. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13960. //2024-10-21 新增LZ UID
  13961. var userIds = new List<int>() { 21 };
  13962. string title = $"系统通知";
  13963. var diId = _dto.DiId;
  13964. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13965. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13966. string content = "";
  13967. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13968. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13969. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13970. }
  13971. catch (Exception ex)
  13972. {
  13973. }
  13974. #endregion
  13975. return Ok(_view);
  13976. }
  13977. /// <summary>
  13978. /// 酒店自动审核测试
  13979. /// Add Or Edit
  13980. /// </summary>
  13981. /// <param name="_dto"></param>
  13982. /// <returns></returns>
  13983. [HttpPost]
  13984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13985. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  13986. {
  13987. #region 应用推送
  13988. try
  13989. {
  13990. //自动审核
  13991. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  13992. }
  13993. catch (Exception ex)
  13994. {
  13995. return Ok(JsonView(false, "操作失败"));
  13996. }
  13997. #endregion
  13998. return Ok(JsonView(false, "操作成功"));
  13999. }
  14000. /// <summary>
  14001. /// 酒店预订
  14002. /// Del
  14003. /// </summary>
  14004. /// <param name="_dto"></param>
  14005. /// <returns></returns>
  14006. [HttpPost]
  14007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14008. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  14009. {
  14010. #region 参数验证
  14011. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14012. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14013. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14014. #region 团组操作权限验证 76 酒店预定模块
  14015. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14016. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14017. #endregion
  14018. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14019. #region 页面操作权限验证
  14020. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14021. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  14022. #endregion
  14023. #endregion
  14024. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  14025. #region 操作记录
  14026. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  14027. {
  14028. TableName = "Grp_HotelReservations",
  14029. PortType = _dto.PortType,
  14030. OperationItem = OperationEnum.Del,
  14031. DataId = _dto.Id,
  14032. CreateUserId = _dto.UserId
  14033. });
  14034. #endregion
  14035. return Ok(data);
  14036. }
  14037. /// <summary>
  14038. /// 酒店预订
  14039. /// 生成VOUCHER
  14040. /// 2024.05.06 之前版本
  14041. /// </summary>
  14042. /// <param name="_dto"></param>
  14043. /// <returns></returns>
  14044. [HttpPost]
  14045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14046. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  14047. {
  14048. try
  14049. {
  14050. #region 参数验证
  14051. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14052. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14053. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14054. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14055. #region 团组操作权限验证 76 酒店预定模块
  14056. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14057. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14058. #endregion
  14059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14060. #region 页面操作权限验证
  14061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14062. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14063. #endregion
  14064. #endregion
  14065. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14066. //判断数据是否完整
  14067. if (hr != null)
  14068. {
  14069. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14070. {
  14071. string strFileName = "HotelStatement/";
  14072. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14073. if (dele != null)
  14074. strFileName += dele.TourCode;
  14075. //载入模板
  14076. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14077. Document doc = new Document(sss);
  14078. DocumentBuilder builder = new DocumentBuilder(doc);
  14079. #region 替换Word模板书签内容
  14080. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14081. //入住卷预定号码
  14082. if (doc.Range.Bookmarks["VNO"] != null)
  14083. {
  14084. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14085. mark.Text = hr.CheckNumber;
  14086. }
  14087. //酒店时间
  14088. if (doc.Range.Bookmarks["Date"] != null)
  14089. {
  14090. Bookmark mark = doc.Range.Bookmarks["Date"];
  14091. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14092. }
  14093. //团号
  14094. if (doc.Range.Bookmarks["TNo"] != null)
  14095. {
  14096. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14097. mark.Text = dele.TourCode;
  14098. }
  14099. //预定号码
  14100. if (doc.Range.Bookmarks["BookingId"] != null)
  14101. {
  14102. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14103. mark.Text = hr.ReservationsNo;
  14104. }
  14105. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14106. {
  14107. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14108. mark.Text = hr.DetermineNo;
  14109. }
  14110. //酒店城市
  14111. if (doc.Range.Bookmarks["City"] != null)
  14112. {
  14113. Bookmark mark = doc.Range.Bookmarks["City"];
  14114. mark.Text = hr.City;
  14115. }
  14116. //酒店名称
  14117. if (doc.Range.Bookmarks["HName"] != null)
  14118. {
  14119. Bookmark mark = doc.Range.Bookmarks["HName"];
  14120. mark.Text = hr.HotelName;
  14121. }
  14122. //酒店地址
  14123. if (doc.Range.Bookmarks["Address"] != null)
  14124. {
  14125. Bookmark mark = doc.Range.Bookmarks["Address"];
  14126. mark.Text = hr.HotelAddress;
  14127. }
  14128. //酒店电话
  14129. if (doc.Range.Bookmarks["Tel"] != null)
  14130. {
  14131. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14132. mark.Text = hr.HotelTel;
  14133. }
  14134. //酒店传真
  14135. if (doc.Range.Bookmarks["Fax"] != null)
  14136. {
  14137. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14138. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14139. {
  14140. mark.Text = hr.HotelFax;
  14141. }
  14142. }
  14143. //入住时间
  14144. if (doc.Range.Bookmarks["CIn"] != null)
  14145. {
  14146. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14147. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14148. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14149. }
  14150. //退房时间
  14151. if (doc.Range.Bookmarks["COut"] != null)
  14152. {
  14153. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14154. Bookmark mark = doc.Range.Bookmarks["COut"];
  14155. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14156. }
  14157. //客户名称
  14158. if (doc.Range.Bookmarks["GName"] != null)
  14159. {
  14160. string guestName = "";
  14161. string[] clients = new string[] { };
  14162. if (hr.GuestName.Contains(","))
  14163. {
  14164. clients = hr.GuestName.Split(",");
  14165. }
  14166. else
  14167. {
  14168. clients = new string[] { hr.GuestName };
  14169. }
  14170. List<int> clientIds_int = new List<int>();
  14171. if (clients.Length > 0)
  14172. {
  14173. foreach (var item in clients)
  14174. {
  14175. if (item.IsNumeric())
  14176. {
  14177. clientIds_int.Add(int.Parse(item));
  14178. }
  14179. }
  14180. }
  14181. if (clientIds_int.Count > 0)
  14182. {
  14183. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14184. foreach (var client in _clientDatas)
  14185. {
  14186. //男
  14187. if (client.Sex == 0) guestName += $"Mr.";
  14188. //女
  14189. else if (client.Sex == 1) guestName += $"Ms.";
  14190. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14191. {
  14192. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14193. }
  14194. //guestName += $"{client.Pinyin},";
  14195. }
  14196. if (guestName.Length > 0)
  14197. {
  14198. guestName = guestName.Substring(0, guestName.Length - 1);
  14199. }
  14200. }
  14201. else
  14202. {
  14203. guestName = hr.GuestName;
  14204. }
  14205. Bookmark mark = doc.Range.Bookmarks["GName"];
  14206. mark.Text = guestName;
  14207. }
  14208. //房间介绍
  14209. if (doc.Range.Bookmarks["ROOM"] != null)
  14210. {
  14211. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14212. mark.Text = hr.RoomExplanation;
  14213. }
  14214. //报价描述
  14215. if (doc.Range.Bookmarks["NOTE"] != null)
  14216. {
  14217. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14218. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14219. if (ss != null)
  14220. mark.Text = ss.Name;
  14221. }
  14222. //入住时间
  14223. if (doc.Range.Bookmarks["CheckIn"] != null)
  14224. {
  14225. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14226. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14227. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14228. }
  14229. //退房时间
  14230. if (doc.Range.Bookmarks["CheckOut"] != null)
  14231. {
  14232. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14233. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14234. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14235. }
  14236. //日期
  14237. if (doc.Range.Bookmarks["DT"] != null)
  14238. {
  14239. Bookmark mark = doc.Range.Bookmarks["DT"];
  14240. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14241. }
  14242. //名称
  14243. if (doc.Range.Bookmarks["VName"] != null)
  14244. {
  14245. Bookmark mark = doc.Range.Bookmarks["VName"];
  14246. mark.Text = hr.HotelName;
  14247. }
  14248. //号码
  14249. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14250. {
  14251. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14252. mark.Text = hr.CheckNumber;
  14253. }
  14254. #endregion
  14255. strFileName += "VOUCHER.doc";
  14256. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14257. doc.Save(fileDir);
  14258. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14259. return Ok(JsonView(true, "操作成功!", Url));
  14260. }
  14261. else
  14262. {
  14263. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14264. }
  14265. }
  14266. else
  14267. {
  14268. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14269. }
  14270. }
  14271. catch (Exception ex)
  14272. {
  14273. return Ok(JsonView(false, ex.Message));
  14274. }
  14275. }
  14276. /// <summary>
  14277. /// 酒店预订
  14278. /// 生成VOUCHER
  14279. /// 2024.05.06 之后版本
  14280. /// </summary>
  14281. /// <param name="_dto"></param>
  14282. /// <returns></returns>
  14283. [HttpPost]
  14284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14285. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14286. {
  14287. #region 参数验证
  14288. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14289. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14290. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14291. #region 团组操作权限验证 76 酒店预定模块
  14292. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14293. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14294. #endregion
  14295. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14296. #region 页面操作权限验证
  14297. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14298. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14299. #endregion
  14300. #endregion
  14301. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14302. //判断数据是否完整
  14303. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14304. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14305. string strFileName = "HotelStatement/";
  14306. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14307. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14308. #region 数据处理
  14309. List<int> guestIds = new List<int>();
  14310. int index = 0;
  14311. foreach (var item in hrDtas)
  14312. {
  14313. if (item.GuestName.Contains(","))
  14314. {
  14315. string[] guestIdArr = item.GuestName.Split(',');
  14316. foreach (var guestIdStr in guestIdArr)
  14317. {
  14318. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14319. if (guestBool)
  14320. {
  14321. guestIds.Add(guestId);
  14322. }
  14323. }
  14324. }
  14325. else guestNames += item.GuestName;
  14326. var voucherInfo = new HotelVoucherInfoView()
  14327. {
  14328. HotelName = item.HotelName,
  14329. CheckInDate = item.CheckInDate,
  14330. CheckOutDate = item.CheckOutDate,
  14331. ConfirmationNumber = item.DetermineNo.Trim(),
  14332. RoomType = item.RoomExplanation
  14333. };
  14334. vouchers.Add(voucherInfo);
  14335. }
  14336. if (guestIds.Count > 0)
  14337. {
  14338. guestIds = guestIds.Distinct().ToList();
  14339. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14340. if (guestDatas.Count > 0)
  14341. {
  14342. guestNames = "";
  14343. foreach (var guest in guestDatas)
  14344. {
  14345. string guestName = "";
  14346. if (guest.Sex == 0) guestName += @"MR.";
  14347. else if (guest.Sex == 1) guestName += @"MS.";
  14348. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14349. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14350. guestNames += @$"{guestName.Trim()}、";
  14351. }
  14352. if (guestNames.Length > 0)
  14353. {
  14354. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14355. }
  14356. }
  14357. }
  14358. #endregion
  14359. //载入模板
  14360. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14361. Document doc = new Document(sss);
  14362. DocumentBuilder builder = new DocumentBuilder(doc);
  14363. if (doc.Range.Bookmarks["GuestName"] != null)
  14364. {
  14365. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14366. mark.Text = guestNames;
  14367. }
  14368. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14369. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14370. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14371. for (int i = 1; i <= vouchers.Count; i++)
  14372. {
  14373. HotelVoucherInfoView hviv = vouchers[i - 1];
  14374. builder.MoveToCell(0, i, 0, 0);
  14375. builder.Write(hviv.HotelName);
  14376. builder.MoveToCell(0, i, 1, 0);
  14377. builder.Write(hviv.CheckInDate);
  14378. builder.MoveToCell(0, i, 2, 0);
  14379. builder.Write(hviv.CheckOutDate);
  14380. builder.MoveToCell(0, i, 3, 0);
  14381. builder.Write(hviv.RoomType);
  14382. builder.MoveToCell(0, i, 4, 0);
  14383. builder.Write(hviv.ConfirmationNumber);
  14384. }
  14385. //删除多余行
  14386. int currRowIndex = vouchers.Count + 1;
  14387. int delRows = 21 - currRowIndex;
  14388. if (delRows > 0)
  14389. {
  14390. for (int i = 0; i < delRows; i++)
  14391. {
  14392. table.Rows.RemoveAt(currRowIndex);
  14393. //cultivateRowIndex++;
  14394. }
  14395. }
  14396. strFileName += "VOUCHER.docx";
  14397. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14398. doc.Save(fileDir);
  14399. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14400. return Ok(JsonView(true, "操作成功!", Url));
  14401. }
  14402. /// <summary>
  14403. /// 酒店预订
  14404. /// 生成VOUCHER 批量生成
  14405. /// New
  14406. /// </summary>
  14407. /// <param name="_dto"></param>
  14408. /// <returns></returns>
  14409. [HttpPost]
  14410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14411. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14412. {
  14413. #region 参数验证
  14414. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14415. if (_dto.PageId < 1) _dto.PageId = 28;
  14416. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14417. #region 团组操作权限验证 76 酒店预定模块
  14418. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14419. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14420. #endregion
  14421. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14422. #region 页面操作权限验证
  14423. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14424. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14425. #endregion
  14426. #endregion
  14427. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14428. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14429. .OrderBy(x => x.CheckInDate)
  14430. .ToListAsync();
  14431. //判断数据是否完整
  14432. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14433. string strFileName = "HotelStatement/";
  14434. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14435. if (dele != null)
  14436. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14437. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14438. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14439. .Where(it => it.IsDel == 0)
  14440. .ToListAsync();
  14441. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14442. for (int i = 0; i < hrDtas.Count; i++)
  14443. {
  14444. string guestNames = string.Empty;
  14445. List<int> guestIds = new List<int>();
  14446. var item = hrDtas[i];
  14447. //处理客户姓名
  14448. if (item.GuestName.Contains(","))
  14449. {
  14450. string[] guestIdArr = item.GuestName.Split(',');
  14451. foreach (var guestIdStr in guestIdArr)
  14452. if (int.TryParse(guestIdStr, out int guestId))
  14453. guestIds.Add(guestId);
  14454. }
  14455. else
  14456. {
  14457. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14458. if (guestIdBool)
  14459. {
  14460. guestIds.Add(guestId);
  14461. }
  14462. //NaN
  14463. if (item.GuestName.Contains("NaN"))
  14464. {
  14465. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14466. }
  14467. }
  14468. if (guestIds.Count > 0)
  14469. {
  14470. guestIds = guestIds.Distinct().ToList();
  14471. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14472. if (guestDatas1.Count > 0)
  14473. {
  14474. guestNames = "";
  14475. foreach (var guest in guestDatas1)
  14476. {
  14477. string guestName = "";
  14478. if (guest.Sex == 0) guestName += @"MR.";
  14479. else if (guest.Sex == 1) guestName += @"MS.";
  14480. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14481. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14482. guestNames += @$"{guestName.Trim()}、";
  14483. }
  14484. if (guestNames.Length > 0)
  14485. {
  14486. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14487. }
  14488. }
  14489. }
  14490. //if (!string.IsNullOrEmpty(guestNames))
  14491. //{
  14492. hrDtas[i].GuestName = guestNames;
  14493. //}
  14494. }
  14495. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14496. Document doc = new Document();
  14497. DocumentBuilder builder = new DocumentBuilder(doc);
  14498. try
  14499. {
  14500. builder.MoveToDocumentStart();
  14501. foreach (var item in hrDtas)
  14502. {
  14503. //标题
  14504. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14505. builder.ParagraphFormat.LineSpacing = 1;
  14506. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14507. builder.ParagraphFormat.Style.Font.Size = 9;
  14508. builder.ParagraphFormat.Style.Font.Bold = true;
  14509. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14510. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14511. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14512. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14513. builder.ParagraphFormat.LineSpacing = 1;
  14514. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14515. builder.ParagraphFormat.Style.Font.Size = 9;
  14516. builder.ParagraphFormat.Style.Font.Bold = true;
  14517. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14518. builder.StartTable();
  14519. // 设置边框颜色
  14520. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14521. //设置边框样式
  14522. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14523. //表格
  14524. #region 第一行
  14525. builder.InsertCell();
  14526. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14527. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14528. //builder.CellFormat.AllowAutoFit = false;
  14529. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14530. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14531. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14532. builder.CellFormat.WrapText = true; //自动换行
  14533. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14534. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14535. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14536. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14537. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14538. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14539. builder.Write("TOUR NO:");
  14540. builder.InsertCell();
  14541. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14542. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14543. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14544. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14545. builder.ParagraphFormat.Style.Font.Bold = false;
  14546. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14547. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14548. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14549. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14550. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14551. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14552. builder.Write($"{dele?.TourCode ?? "-"}");
  14553. builder.InsertCell();
  14554. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14555. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14556. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14557. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14558. builder.ParagraphFormat.Style.Font.Bold = false;
  14559. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14560. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14561. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14562. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14563. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14564. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14565. builder.Write($"CITY:");
  14566. builder.InsertCell();
  14567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14568. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14569. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14570. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14571. builder.ParagraphFormat.Style.Font.Bold = false;
  14572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14574. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14575. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14576. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14577. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14578. builder.Write($"{item.City}");
  14579. builder.EndRow();
  14580. #endregion
  14581. #region 第二行
  14582. builder.InsertCell();
  14583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14584. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14585. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14586. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14587. builder.ParagraphFormat.Style.Font.Bold = false;
  14588. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14589. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14590. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14591. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14592. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14593. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14594. builder.Write("CONFIRMATION NO:");
  14595. builder.InsertCell();
  14596. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14597. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14598. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14599. builder.ParagraphFormat.Style.Font.Bold = false;
  14600. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14601. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14602. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14603. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14604. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14605. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14606. builder.CellFormat.VerticalMerge = CellMerge.None;
  14607. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14608. builder.Write($"{item.DetermineNo}");
  14609. builder.InsertCell();
  14610. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14611. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14612. builder.InsertCell();
  14613. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14614. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14615. builder.EndRow();
  14616. #endregion
  14617. #region 第三行
  14618. builder.InsertCell();
  14619. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14620. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14621. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14622. builder.ParagraphFormat.Style.Font.Bold = false;
  14623. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14624. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14625. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14626. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14627. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14628. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14629. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14630. builder.Write($"HOTEL NAME:");
  14631. builder.InsertCell();
  14632. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14633. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14634. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14635. builder.ParagraphFormat.Style.Font.Bold = false;
  14636. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14637. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14638. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14639. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14640. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14641. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14642. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14643. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14644. builder.Write($"{item.HotelName}");
  14645. builder.InsertCell();
  14646. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14647. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14648. builder.InsertCell();
  14649. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14650. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14651. builder.EndRow();
  14652. #endregion
  14653. #region 第四行
  14654. builder.InsertCell();
  14655. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14656. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14657. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14658. builder.ParagraphFormat.Style.Font.Bold = false;
  14659. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14660. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14661. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14662. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14663. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14664. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14665. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14666. builder.Write($"HOTEL ADDRESS:");
  14667. builder.InsertCell();
  14668. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14669. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14670. builder.ParagraphFormat.Style.Font.Size = 8;
  14671. builder.ParagraphFormat.Style.Font.Bold = false;
  14672. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14673. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14674. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14675. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14676. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14677. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14678. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14679. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14680. builder.Write($"{item.HotelAddress}");
  14681. builder.InsertCell();
  14682. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14683. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14684. builder.InsertCell();
  14685. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14686. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14687. builder.EndRow();
  14688. #endregion
  14689. #region 第五行
  14690. builder.InsertCell();
  14691. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14692. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14693. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14694. builder.ParagraphFormat.Style.Font.Bold = false;
  14695. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14696. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14697. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14698. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14699. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14700. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14701. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14702. builder.Write("TEL:");
  14703. builder.InsertCell();
  14704. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14705. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14706. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14707. builder.ParagraphFormat.Style.Font.Bold = false;
  14708. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14709. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14710. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14711. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14712. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14713. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14714. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14715. builder.Write($"{item.HotelTel}");
  14716. builder.InsertCell();
  14717. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14718. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14719. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14720. builder.ParagraphFormat.Style.Font.Bold = false;
  14721. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14722. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14723. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14724. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14725. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14726. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14727. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14728. builder.Write($"FAX:");
  14729. builder.InsertCell();
  14730. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14731. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14732. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14733. builder.ParagraphFormat.Style.Font.Bold = false;
  14734. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14735. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14736. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14737. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14738. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14739. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14740. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14741. builder.Write($"{item.HotelFax}");
  14742. builder.EndRow();
  14743. #endregion
  14744. #region 第六行
  14745. builder.InsertCell();
  14746. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14747. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14748. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14749. builder.ParagraphFormat.Style.Font.Bold = false;
  14750. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14751. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14752. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14753. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14754. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14755. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14756. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14757. builder.Write("CHECK IN:");
  14758. builder.InsertCell();
  14759. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14760. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14761. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14762. builder.ParagraphFormat.Style.Font.Bold = false;
  14763. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14764. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14765. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14766. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14767. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14768. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14769. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14770. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14771. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14772. builder.Write($"{checkInStr}");
  14773. builder.InsertCell();
  14774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14775. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14776. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14777. builder.ParagraphFormat.Style.Font.Bold = false;
  14778. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14779. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14780. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14781. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14782. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14783. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14784. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14785. builder.Write($"CHECK OUT:");
  14786. builder.InsertCell();
  14787. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14788. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14789. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14790. builder.ParagraphFormat.Style.Font.Bold = false;
  14791. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14792. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14793. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14794. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14795. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14796. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14797. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14798. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14799. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14800. builder.Write($"{checkOutStr}");
  14801. builder.EndRow();
  14802. #endregion
  14803. #region 第七行
  14804. builder.InsertCell();
  14805. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14806. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14807. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14808. builder.ParagraphFormat.Style.Font.Bold = false;
  14809. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14810. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14811. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14812. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14813. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14814. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14815. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14816. builder.Write($"GUEST NAME:");
  14817. builder.InsertCell();
  14818. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14819. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14820. builder.ParagraphFormat.Style.Font.Size = 8;
  14821. builder.ParagraphFormat.Style.Font.Bold = false;
  14822. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14823. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14824. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14825. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14826. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14827. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14828. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14829. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14830. builder.Write($"{item.GuestName}");
  14831. builder.InsertCell();
  14832. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14833. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14834. builder.InsertCell();
  14835. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14836. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14837. builder.EndRow();
  14838. #endregion
  14839. #region 第八行
  14840. builder.InsertCell();
  14841. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14842. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14843. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14844. builder.ParagraphFormat.Style.Font.Bold = false;
  14845. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14846. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14847. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14848. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14849. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14850. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14851. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14852. builder.Write($"ROOM TYPE:");
  14853. builder.InsertCell();
  14854. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14855. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14856. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14857. builder.ParagraphFormat.Style.Font.Bold = false;
  14858. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14859. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14860. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14861. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14862. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14863. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14864. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14865. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14866. builder.Write($"{item.RoomExplanation}");
  14867. builder.InsertCell();
  14868. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14869. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14870. builder.InsertCell();
  14871. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14872. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14873. builder.EndRow();
  14874. #endregion
  14875. #region 第九行
  14876. builder.InsertCell();
  14877. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14878. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14879. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14880. builder.ParagraphFormat.Style.Font.Bold = false;
  14881. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14882. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14883. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14884. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14885. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14886. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14887. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14888. builder.Write($"NOTE:");
  14889. builder.InsertCell();
  14890. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14891. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14892. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14893. builder.ParagraphFormat.Style.Font.Bold = false;
  14894. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14895. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14896. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14897. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14898. builder.Write($"ROOM WITH BREAKFAST AND TAX ONLY.\r\nTHIS SERVICE IS PAYABLE BY C-TRIP. FOR EXTRA CHARGE TO BE COLLECTED FROM THE GUEST.");
  14899. builder.InsertCell();
  14900. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14901. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14902. builder.InsertCell();
  14903. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14904. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14905. builder.EndRow();
  14906. #endregion
  14907. builder.EndTable();
  14908. //换行
  14909. builder.Writeln("");
  14910. builder.Writeln("");
  14911. }
  14912. #region 获取文档中的所有表格 设置文字自适应
  14913. // 获取文档中的所有表格。
  14914. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14915. {
  14916. // 遍历表格中的所有行。
  14917. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14918. {
  14919. foreach (Cell cell in row.Cells)
  14920. {
  14921. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14922. cellFormat.Width = 0;
  14923. }
  14924. }
  14925. }
  14926. #endregion
  14927. #region 设置页眉
  14928. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14929. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14930. if (System.IO.File.Exists(voucherHeaderPath))
  14931. {
  14932. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14933. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14934. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14935. Shape shape = builder.InsertImage(imageBytes);
  14936. // 调整图片位置
  14937. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14938. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14939. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14940. shape.Left = 0; // 将图片距离页面左边缘的距离
  14941. shape.Width = 81; // 设置图片宽度
  14942. shape.Height = 36; // 设置图片高度
  14943. }
  14944. //靠右
  14945. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14946. //// 设置页脚上下边距
  14947. //builder.PageSetup.HeaderDistance = 42;
  14948. // 添加页眉线
  14949. Aspose.Words.Border borderHeader = null;
  14950. try
  14951. {
  14952. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14953. }
  14954. catch (Exception e)
  14955. {
  14956. // TODO Auto-generated catch block
  14957. //e.printStackTrace();
  14958. }
  14959. borderHeader.Shadow = true;
  14960. borderHeader.DistanceFromText = 2;
  14961. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14962. #endregion
  14963. }
  14964. catch (Exception ex)
  14965. {
  14966. }
  14967. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14968. doc.Save(fileDir);
  14969. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14970. return Ok(JsonView(true, "操作成功!", Url));
  14971. }
  14972. /// <summary>
  14973. /// 酒店预订
  14974. /// 生成 预定成本 Excel
  14975. /// </summary>
  14976. /// <param name="_dto"></param>
  14977. /// <returns></returns>
  14978. [HttpPost]
  14979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14980. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  14981. {
  14982. #region 参数验证
  14983. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  14984. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  14985. if (!vadalitorRes.IsValid)
  14986. {
  14987. var errors = new StringBuilder();
  14988. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  14989. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  14990. }
  14991. #region 团组操作权限验证 76 酒店预定模块
  14992. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14993. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14994. #endregion
  14995. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14996. #region 页面操作权限验证
  14997. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14998. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14999. #endregion
  15000. #endregion
  15001. decimal _rate = 1.00M;
  15002. string _currency = string.Empty;
  15003. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  15004. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15005. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  15006. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  15007. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  15008. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  15009. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  15010. if (_GroupCostParameter == null)
  15011. {
  15012. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  15013. bool isIntType = int.TryParse(_currency, out int currId);
  15014. if (isIntType)
  15015. {
  15016. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15017. }
  15018. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15019. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15020. if (currInfo == null)
  15021. {
  15022. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15023. }
  15024. else _rate = currInfo.Rate;
  15025. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  15026. {
  15027. _rate = _GroupCostParameter.Rate;
  15028. }
  15029. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15030. string strFileName = "HotelStatement/";
  15031. string guestNames = ""; //格式Mr.xxx Ms.xxx
  15032. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15033. var rateDatas = new List<dynamic>();
  15034. #region 数据处理
  15035. foreach (var item in hrDtas)
  15036. {
  15037. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15038. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15039. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15040. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15041. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15042. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  15043. {
  15044. continue;
  15045. }
  15046. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15047. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  15048. string singleRoomFeeStr = string.Empty,
  15049. doubleRoomFeeStr = string.Empty,
  15050. suiteRoomFeeStr = string.Empty,
  15051. otherRoomFeeStr = string.Empty,
  15052. payMoneyStr = string.Empty,
  15053. cardPriceStr = string.Empty;
  15054. if (roomCurr.Equals("CNY"))
  15055. {
  15056. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15057. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15058. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15059. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15060. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15061. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15062. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15063. }
  15064. else
  15065. {
  15066. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15067. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15068. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15069. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15070. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15071. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15072. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15073. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15074. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15075. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15076. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15077. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15078. if (ccpPaymentCurrency.Equals("CNY"))
  15079. {
  15080. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15081. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15082. }
  15083. else
  15084. {
  15085. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15086. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15087. }
  15088. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15089. if (hotelcardPriceCurrency.Equals("CNY"))
  15090. {
  15091. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15092. }
  15093. else
  15094. {
  15095. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15096. }
  15097. }
  15098. string breakfastPriceStr = string.Empty,
  15099. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15100. governmentRentStr = string.Empty,
  15101. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15102. cityTaxStr = string.Empty,
  15103. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15104. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15105. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15106. {
  15107. if (breakfastCurrency1.Equals("CNY"))
  15108. {
  15109. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15110. }
  15111. else
  15112. {
  15113. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15114. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15115. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15116. }
  15117. }
  15118. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15119. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15120. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15121. {
  15122. if (governmentRentCurrency.Equals("CNY"))
  15123. {
  15124. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15125. }
  15126. else
  15127. {
  15128. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15129. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15130. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15131. }
  15132. }
  15133. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15134. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15135. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15136. {
  15137. if (cityTaxStrCurrency1.Equals("CNY"))
  15138. {
  15139. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15140. }
  15141. else
  15142. {
  15143. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15144. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15145. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15146. }
  15147. }
  15148. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15149. int payDId = roomInfo?.PayDId ?? 0;
  15150. pcfds.Add(new HotelReservations_PCFD_View()
  15151. {
  15152. City = item.City,
  15153. HotelName = item.HotelName,
  15154. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15155. // SingleRoomCount = item.SingleRoomCount,
  15156. SingleRoomPrice = singleRoomFeeStr,
  15157. // DoubleRoomCount = item.DoubleRoomCount,
  15158. DoubleRoomPrice = doubleRoomFeeStr,
  15159. //SuiteRoomCount = item.SuiteRoomCount,
  15160. SuiteRoomPrice = suiteRoomFeeStr,
  15161. OtherRoomPrice = otherRoomFeeStr,
  15162. //OtherRoomCount = item.OtherRoomCount,
  15163. BreakfastPrice = breakfastPriceStr,
  15164. GovernmentRent = governmentRentStr,
  15165. CityTax = cityTaxStr,
  15166. RoomExplanation = item.RoomExplanation,
  15167. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15168. PayTime = roomInfo?.ConsumptionDate,
  15169. BankNo = roomInfo?.BankNo,
  15170. PayMoney = payMoneyStr,
  15171. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15172. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15173. CardPrice = cardPriceStr,
  15174. Remark = ccpInfo.Remark
  15175. });
  15176. }
  15177. #endregion
  15178. //载入模板
  15179. WorkbookDesigner designer = new WorkbookDesigner();
  15180. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15181. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15182. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15183. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15184. var rateDatas1 = rateDatas.Distinct();
  15185. var rateStr = string.Empty;
  15186. foreach (var item in rateDatas1)
  15187. {
  15188. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15189. }
  15190. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15191. designer.SetDataSource("Opertor", userInfo.CnName);
  15192. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15193. dt.TableName = "ViewMyHotelReservations";
  15194. designer.SetDataSource(dt);
  15195. designer.Process();
  15196. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15197. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15198. designer.Workbook.Save(serverPath);
  15199. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15200. #region 删除指定行
  15201. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15202. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15203. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15204. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15205. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15206. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15207. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15208. cssIndex = dt.Columns["CityTax"].Ordinal,
  15209. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15210. remarkIndex = dt.Columns["Remark"].Ordinal;
  15211. //删除指定列
  15212. foreach (DataRow item in dt.Rows)
  15213. {
  15214. string singleStr = item["SingleRoomPrice"].ToString();
  15215. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15216. if (containsDigitButNotZero1) singleDel = false;
  15217. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15218. string doubleStr = item["DoubleRoomPrice"].ToString();
  15219. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15220. if (containsDigitButNotZero2) doubleDel = false;
  15221. string suiteStr = item["SuiteRoomPrice"].ToString();
  15222. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15223. if (containsDigitButNotZero3) suiteDel = false;
  15224. string otherStr = item["OtherRoomPrice"].ToString();
  15225. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15226. if (containsDigitButNotZero4) otherDel = false;
  15227. string zcStr = item["BreakfastPrice"].ToString();
  15228. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15229. if (containsDigitButNotZero5) zcDel = false;
  15230. string dsStr = item["GovernmentRent"].ToString();
  15231. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15232. if (containsDigitButNotZero6) dsDel = false;
  15233. string cssStr = item["CityTax"].ToString();
  15234. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15235. if (containsDigitButNotZero7) cssDel = false;
  15236. string cpStr = item["ConsumptionPatterns"].ToString();
  15237. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15238. string remarkStr = item["Remark"].ToString();
  15239. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15240. }
  15241. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15242. DeleteColumn(serverPath, cpIndex, cpDel);
  15243. DeleteColumn(serverPath, dsIndex, dsDel);
  15244. DeleteColumn(serverPath, cssIndex, cssDel);
  15245. DeleteColumn(serverPath, zcIndex, zcDel);
  15246. DeleteColumn(serverPath, otherIndex, otherDel);
  15247. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15248. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15249. DeleteColumn(serverPath, singleIndex, singleDel);
  15250. #endregion
  15251. //只保留第一个表格
  15252. DeleteSheet(serverPath);
  15253. return Ok(JsonView(true, "操作成功", url = rst));
  15254. }
  15255. else
  15256. {
  15257. _currency = _GroupCostParameter.Currency;
  15258. bool isIntType = int.TryParse(_currency, out int currId);
  15259. if (isIntType)
  15260. {
  15261. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15262. }
  15263. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15264. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15265. if (currInfo == null)
  15266. {
  15267. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15268. }
  15269. if (!_currency.ToUpper().Equals("CNY"))
  15270. {
  15271. _rate = _GroupCostParameter.Rate;
  15272. }
  15273. _rate = currInfo.Rate;
  15274. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15275. //string strFileName = "HotelStatement/";
  15276. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15277. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15278. #region 数据处理
  15279. foreach (var item in hrDtas)
  15280. {
  15281. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15282. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15283. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15284. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15285. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15286. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15287. string singleRoomFeeStr = string.Empty,
  15288. doubleRoomFeeStr = string.Empty,
  15289. suiteRoomFeeStr = string.Empty,
  15290. otherRoomFeeStr = string.Empty,
  15291. payMoneyStr = string.Empty,
  15292. cardPriceStr = string.Empty;
  15293. if (roomCurr.Equals(_currency))
  15294. {
  15295. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15296. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15297. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15298. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15299. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15300. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15301. }
  15302. else
  15303. {
  15304. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15305. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15306. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15307. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15308. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15309. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15310. }
  15311. string breakfastPriceStr = string.Empty,
  15312. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15313. governmentRentStr = string.Empty,
  15314. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15315. cityTaxStrStr = string.Empty,
  15316. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15317. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15318. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15319. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15320. int payDId = roomInfo?.PayDId ?? 0;
  15321. pcfds.Add(new HotelReservations_PCFD_View()
  15322. {
  15323. City = item.City,
  15324. HotelName = item.HotelName,
  15325. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15326. // SingleRoomCount = item.SingleRoomCount,
  15327. SingleRoomPrice = singleRoomFeeStr,
  15328. // DoubleRoomCount = item.DoubleRoomCount,
  15329. DoubleRoomPrice = doubleRoomFeeStr,
  15330. //SuiteRoomCount = item.SuiteRoomCount,
  15331. SuiteRoomPrice = suiteRoomFeeStr,
  15332. OtherRoomPrice = otherRoomFeeStr,
  15333. //OtherRoomCount = item.OtherRoomCount,
  15334. BreakfastPrice = breakfastPriceStr,
  15335. GovernmentRent = governmentRentStr,
  15336. CityTax = cityTaxStrStr,
  15337. RoomExplanation = item.RoomExplanation,
  15338. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15339. PayTime = roomInfo?.ConsumptionDate,
  15340. BankNo = roomInfo?.BankNo,
  15341. PayMoney = payMoneyStr,
  15342. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15343. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15344. CardPrice = cardPriceStr,
  15345. Remark = ccpInfo.Remark
  15346. });
  15347. }
  15348. #endregion
  15349. //载入模板
  15350. WorkbookDesigner designer = new WorkbookDesigner();
  15351. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15352. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15353. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15354. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15355. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15356. designer.SetDataSource("Opertor", userInfo.CnName);
  15357. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15358. dt.TableName = "ViewMyHotelReservations";
  15359. designer.SetDataSource(dt);
  15360. designer.Process();
  15361. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15362. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15363. designer.Workbook.Save(serverPath);
  15364. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15365. #region 删除指定行
  15366. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15367. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15368. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15369. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15370. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15371. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15372. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15373. cssIndex = dt.Columns["CityTax"].Ordinal,
  15374. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15375. remarkIndex = dt.Columns["Remark"].Ordinal;
  15376. //删除指定列
  15377. foreach (DataRow item in dt.Rows)
  15378. {
  15379. string singleStr = item["SingleRoomPrice"].ToString();
  15380. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15381. if (containsDigitButNotZero1) singleDel = false;
  15382. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15383. string doubleStr = item["DoubleRoomPrice"].ToString();
  15384. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15385. if (containsDigitButNotZero2) doubleDel = false;
  15386. string suiteStr = item["SuiteRoomPrice"].ToString();
  15387. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15388. if (containsDigitButNotZero3) suiteDel = false;
  15389. string otherStr = item["OtherRoomPrice"].ToString();
  15390. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15391. if (containsDigitButNotZero4) otherDel = false;
  15392. string zcStr = item["BreakfastPrice"].ToString();
  15393. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15394. if (containsDigitButNotZero5) zcDel = false;
  15395. string dsStr = item["GovernmentRent"].ToString();
  15396. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15397. if (containsDigitButNotZero6) dsDel = false;
  15398. string cssStr = item["CityTax"].ToString();
  15399. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15400. if (containsDigitButNotZero7) cssDel = false;
  15401. string cpStr = item["ConsumptionPatterns"].ToString();
  15402. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15403. string remarkStr = item["Remark"].ToString();
  15404. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15405. }
  15406. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15407. DeleteColumn(serverPath, cpIndex, cpDel);
  15408. DeleteColumn(serverPath, dsIndex, dsDel);
  15409. DeleteColumn(serverPath, cssIndex, cssDel);
  15410. DeleteColumn(serverPath, zcIndex, zcDel);
  15411. DeleteColumn(serverPath, otherIndex, otherDel);
  15412. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15413. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15414. DeleteColumn(serverPath, singleIndex, singleDel);
  15415. #endregion
  15416. //只保留第一个表格
  15417. DeleteSheet(serverPath);
  15418. return Ok(JsonView(true, "操作成功", url = rst));
  15419. }
  15420. return Ok(JsonView(false));
  15421. }
  15422. /// <summary>
  15423. /// 删除指定列
  15424. /// </summary>
  15425. /// <param name="file"></param>
  15426. /// <param name="columnIndex"></param>
  15427. /// <param name="isDel"></param>
  15428. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15429. {
  15430. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15431. //wb.Save(file);
  15432. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15433. if (sheet1 != null)
  15434. {
  15435. if (isDel)
  15436. {
  15437. Cells cells = sheet1.Cells;
  15438. cells.DeleteColumn(columnIndex);
  15439. }
  15440. }
  15441. wb.Save(file);
  15442. }
  15443. /// <summary>
  15444. /// 删除sheet
  15445. /// </summary>
  15446. /// <param name="file"></param>
  15447. /// <param name="sheetName"></param>
  15448. private void DeleteSheet(string file, string sheetName = "")
  15449. {
  15450. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15451. //wb.Save(file);
  15452. List<string> sheets = new List<string>();
  15453. foreach (var item in wb.Worksheets)
  15454. {
  15455. sheets.Add(item.Name);
  15456. }
  15457. if (sheets.Count > 0)
  15458. {
  15459. sheets.RemoveAt(0);//不删除第一个sheet
  15460. foreach (var item in sheets)
  15461. {
  15462. wb.Worksheets.RemoveAt(item);
  15463. }
  15464. }
  15465. wb.Save(file);
  15466. }
  15467. /// <summary>
  15468. /// 酒店预订
  15469. /// 确认单
  15470. /// </summary>
  15471. /// <param name="_dto"></param>
  15472. /// <returns></returns>
  15473. [HttpPost]
  15474. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15475. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15476. {
  15477. try
  15478. {
  15479. #region 参数验证
  15480. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15481. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15482. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15483. #region 团组操作权限验证 76 酒店预定模块
  15484. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15485. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15486. #endregion
  15487. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15488. #region 页面操作权限验证
  15489. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15490. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15491. #endregion
  15492. #endregion
  15493. //团组信息
  15494. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15495. //酒店数据
  15496. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15497. if (listhoteldata.Count < 0)
  15498. {
  15499. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15500. }
  15501. //利datatable存储
  15502. DataTable dt = new DataTable();
  15503. dt.Columns.Add("CheckInDate", typeof(string));
  15504. dt.Columns.Add("City", typeof(string));
  15505. dt.Columns.Add("Hotel", typeof(string));
  15506. dt.Columns.Add("Room", typeof(string));
  15507. for (int i = 0; i < listhoteldata.Count; i++)
  15508. {
  15509. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15510. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15511. while (dayStart < dayEnd)
  15512. {
  15513. string temp = "";
  15514. DataRow row = dt.NewRow();
  15515. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15516. row["City"] = listhoteldata[i].City;
  15517. row["Hotel"] = listhoteldata[i].HotelName;
  15518. if (listhoteldata[i].SingleRoomCount > 0)
  15519. {
  15520. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15521. }
  15522. if (listhoteldata[i].DoubleRoomCount > 0)
  15523. {
  15524. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15525. }
  15526. if (listhoteldata[i].SuiteRoomCount > 0)
  15527. {
  15528. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15529. }
  15530. if (listhoteldata[i].OtherRoomCount > 0)
  15531. {
  15532. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15533. }
  15534. row["Room"] = temp;
  15535. dt.Rows.Add(row);
  15536. dayStart = dayStart.AddDays(1);
  15537. }
  15538. }
  15539. Dictionary<string, string> dic = new Dictionary<string, string>();
  15540. dic.Add("Dele", di.TeamName);
  15541. dic.Add("City", di.VisitCountry);
  15542. //模板路径
  15543. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15544. //载入模板
  15545. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15546. DocumentBuilder builder = new DocumentBuilder(doc);
  15547. foreach (var key in dic.Keys)
  15548. {
  15549. builder.MoveToBookmark(key);
  15550. builder.Write(dic[key]);
  15551. }
  15552. //获取word里所有表格
  15553. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15554. //获取所填表格的序数
  15555. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15556. var rowStart = tableOne.Rows[0]; //获取第1行
  15557. //循环赋值
  15558. for (int i = 0; i < dt.Rows.Count; i++)
  15559. {
  15560. builder.MoveToCell(0, i + 1, 0, 0);
  15561. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15562. builder.MoveToCell(0, i + 1, 1, 0);
  15563. builder.Write(dt.Rows[i]["City"].ToString());
  15564. builder.MoveToCell(0, i + 1, 2, 0);
  15565. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15566. builder.MoveToCell(0, i + 1, 3, 0);
  15567. builder.Write(dt.Rows[i]["Room"].ToString());
  15568. }
  15569. //删除多余行
  15570. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15571. {
  15572. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15573. }
  15574. string strFileName = di.TeamName + "酒店确认单.doc";
  15575. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15576. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15577. return Ok(JsonView(true, "成功", url));
  15578. }
  15579. catch (Exception ex)
  15580. {
  15581. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15582. }
  15583. }
  15584. #endregion
  15585. #region 团组状态
  15586. /// <summary>
  15587. /// 团组状态列表 Page
  15588. /// </summary>
  15589. /// <param name="dto">团组列表请求dto</param>
  15590. /// <returns></returns>
  15591. [HttpPost]
  15592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15593. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15594. {
  15595. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15596. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15597. {
  15598. string sqlWhere = string.Empty;
  15599. if (dto.IsSure == 0) //未完成
  15600. {
  15601. sqlWhere += string.Format(@" And IsSure = 0");
  15602. }
  15603. else if (dto.IsSure == 1) //已完成
  15604. {
  15605. sqlWhere += string.Format(@" And IsSure = 1");
  15606. }
  15607. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15608. {
  15609. string tj = dto.SearchCriteria;
  15610. 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}%')",
  15611. tj, tj, tj, tj, tj);
  15612. }
  15613. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15614. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15615. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15616. From (
  15617. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15618. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15619. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15620. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15621. From Grp_DelegationInfo gdi
  15622. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15623. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15624. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15625. Where gdi.IsDel = 0 {0}
  15626. ) temp ", sqlWhere);
  15627. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15628. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15629. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15630. }
  15631. else
  15632. {
  15633. return Ok(JsonView(false, "查询失败"));
  15634. }
  15635. }
  15636. /// <summary>
  15637. /// 团组状态
  15638. /// 设置操作完成
  15639. /// </summary>
  15640. /// <param name="dto">团组列表请求dto</param>
  15641. /// <returns></returns>
  15642. [HttpPost]
  15643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15644. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15645. {
  15646. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15647. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15648. {
  15649. Id = dto.Id,
  15650. IsSure = 1
  15651. };
  15652. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15653. .UpdateColumns(it => new { it.IsSure })
  15654. .WhereColumns(it => new { it.Id })
  15655. .ExecuteCommandAsync();
  15656. if (result > 0)
  15657. {
  15658. return Ok(JsonView(true, "操作完成!"));
  15659. }
  15660. return Ok(JsonView(false, "操作失败!"));
  15661. }
  15662. #endregion
  15663. #region 保险费用录入
  15664. /// <summary>
  15665. /// 根据团组Id查询保险费用列表
  15666. /// </summary>
  15667. /// <param name="dto"></param>
  15668. /// <returns></returns>
  15669. [HttpPost]
  15670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15671. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15672. {
  15673. Result groupData = await _customersRep.CustomersByDiId(dto);
  15674. if (groupData.Code != 0)
  15675. {
  15676. return Ok(JsonView(false, groupData.Msg));
  15677. }
  15678. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15679. }
  15680. /// <summary>
  15681. /// 根据保险费用Id查询保险费用详细
  15682. /// </summary>
  15683. /// <param name="dto"></param>
  15684. /// <returns></returns>
  15685. [HttpPost]
  15686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15687. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15688. {
  15689. try
  15690. {
  15691. Result groupData = await _customersRep.CustomersById(dto);
  15692. if (groupData.Code != 0)
  15693. {
  15694. return Ok(JsonView(false, groupData.Msg));
  15695. }
  15696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15697. }
  15698. catch (Exception ex)
  15699. {
  15700. return Ok(JsonView(false, ex.Message));
  15701. }
  15702. }
  15703. /// <summary>
  15704. /// 保险费用录入页面初始化绑定
  15705. /// </summary>
  15706. /// <param name="dto"></param>
  15707. /// <returns></returns>
  15708. [HttpPost]
  15709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15710. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15711. {
  15712. try
  15713. {
  15714. Result groupData = await _customersRep.CustomersInitialize(dto);
  15715. if (groupData.Code != 0)
  15716. {
  15717. return Ok(JsonView(false, groupData.Msg));
  15718. }
  15719. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15720. }
  15721. catch (Exception ex)
  15722. {
  15723. return Ok(JsonView(false, ex.Message));
  15724. }
  15725. }
  15726. /// <summary>
  15727. /// 保险费用操作(Status:1.新增,2.修改)
  15728. /// </summary>
  15729. /// <param name="dto"></param>
  15730. /// <returns></returns>
  15731. [HttpPost]
  15732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15733. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15734. {
  15735. Result groupData = await _customersRep.OpCustomers(dto);
  15736. if (groupData.Code != 0)
  15737. {
  15738. return Ok(JsonView(false, groupData.Msg));
  15739. }
  15740. #region 应用推送
  15741. try
  15742. {
  15743. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15744. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15745. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15746. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15747. //自动审核
  15748. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15749. //2024-10-21 新增LZ UID
  15750. var userIds = new List<int>() { 21 };
  15751. string title = $"系统通知";
  15752. var diId = dto.DiId;
  15753. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15754. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15755. string content = "";
  15756. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15757. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15758. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15759. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15760. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15761. }
  15762. catch (Exception ex)
  15763. {
  15764. }
  15765. #endregion
  15766. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15767. }
  15768. /// <summary>
  15769. /// 保险文件上传
  15770. /// </summary>
  15771. /// <param name="file"></param>
  15772. /// <returns></returns>
  15773. [HttpPost]
  15774. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15775. public async Task<IActionResult> UploadCus(IFormFile file)
  15776. {
  15777. try
  15778. {
  15779. if (file != null)
  15780. {
  15781. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15782. //文件名称
  15783. string projectFileName = file.FileName;
  15784. //上传的文件的路径
  15785. string filePath = "";
  15786. if (!Directory.Exists(fileDir))
  15787. {
  15788. Directory.CreateDirectory(fileDir);
  15789. }
  15790. //上传的文件的路径
  15791. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15792. using (FileStream fs = System.IO.File.Create(filePath))
  15793. {
  15794. file.CopyTo(fs);
  15795. fs.Flush();
  15796. }
  15797. return Ok(JsonView(true, "上传成功!", projectFileName));
  15798. }
  15799. else
  15800. {
  15801. return Ok(JsonView(false, "上传失败!"));
  15802. }
  15803. }
  15804. catch (Exception ex)
  15805. {
  15806. return Ok(JsonView(false, "程序错误!"));
  15807. throw;
  15808. }
  15809. }
  15810. /// <summary>
  15811. /// 保险删除指定文件
  15812. /// </summary>
  15813. /// <param name="dto"></param>
  15814. /// <returns></returns>
  15815. [HttpPost]
  15816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15817. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15818. {
  15819. try
  15820. {
  15821. string filePath = "";
  15822. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15823. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15824. //int id = 0;
  15825. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15826. // 删除该文件
  15827. try
  15828. {
  15829. System.IO.File.Delete(filePath);
  15830. 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()
  15831. {
  15832. Attachment = "",
  15833. }).ExecuteCommandAsync();
  15834. if (result != 0)
  15835. {
  15836. return Ok(JsonView(true, "成功!"));
  15837. }
  15838. else
  15839. {
  15840. return Ok(JsonView(false, "失败!"));
  15841. }
  15842. }
  15843. catch (Exception)
  15844. {
  15845. 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()
  15846. {
  15847. Attachment = "",
  15848. }).ExecuteCommandAsync();
  15849. if (result != 0)
  15850. {
  15851. return Ok(JsonView(true, "成功!"));
  15852. }
  15853. else
  15854. {
  15855. return Ok(JsonView(false, "失败!"));
  15856. }
  15857. }
  15858. }
  15859. catch (Exception ex)
  15860. {
  15861. return Ok(JsonView(false, "程序错误!"));
  15862. throw;
  15863. }
  15864. }
  15865. /// <summary>
  15866. /// 保险费用操作(删除)
  15867. /// </summary>
  15868. /// <param name="dto"></param>
  15869. /// <returns></returns>
  15870. [HttpPost]
  15871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15872. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15873. {
  15874. try
  15875. {
  15876. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15877. if (!res)
  15878. {
  15879. return Ok(JsonView(false, "删除失败"));
  15880. }
  15881. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15882. {
  15883. IsDel = 1,
  15884. DeleteUserId = dto.DeleteUserId,
  15885. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15886. }).ExecuteCommandAsync();
  15887. return Ok(JsonView(true, "删除成功!"));
  15888. }
  15889. catch (Exception ex)
  15890. {
  15891. return Ok(JsonView(false, "程序错误!"));
  15892. throw;
  15893. }
  15894. }
  15895. #endregion
  15896. #region 接团客户名单 PageId 104
  15897. /// <summary>
  15898. /// 接团客户名单
  15899. /// 迁移数据(慎用!)
  15900. /// </summary>
  15901. /// <param name="dto"></param>
  15902. /// <returns></returns>
  15903. [HttpPost]
  15904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15905. public async Task<IActionResult> PostTourClientListChange()
  15906. {
  15907. try
  15908. {
  15909. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15910. //var groupClinetData1
  15911. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15912. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15913. int updateCount = 0;
  15914. if (oldOAClientList.Count > 0)
  15915. {
  15916. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15917. _sqlSugar.BeginTran();
  15918. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15919. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15920. foreach (var item in oldOAClientList)
  15921. {
  15922. int comId = 0;
  15923. string format = "yyyy-MM-dd HH:mm:ss";
  15924. string data11 = "1990-01-01 00:00";
  15925. var data1 = IsValidDate(item.OPdate, format);
  15926. if (data1) data11 = item.OPdate;
  15927. //客户公司验证
  15928. if (!string.IsNullOrEmpty(item.Company))
  15929. {
  15930. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15931. if (clientComInfo == null) // add
  15932. {
  15933. var addInfo = new Crm_CustomerCompany()
  15934. {
  15935. CompanyAbbreviation = "",
  15936. CompanyFullName = item.Company,
  15937. Address = "",
  15938. PostCodes = "",
  15939. LastedOpUserId = item.OPer,
  15940. LastedOpDt = Convert.ToDateTime(data11),
  15941. CreateUserId = item.OPer,
  15942. CreateTime = Convert.ToDateTime(data11),
  15943. IsDel = 0
  15944. };
  15945. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15946. if (comId1 > 0) comId = comId1;
  15947. }
  15948. else comId = clientComInfo.Id;
  15949. }
  15950. //客户人员验证
  15951. int clientId = 0;
  15952. string name = item.LastName + item.Name;
  15953. if (!string.IsNullOrEmpty(name))
  15954. {
  15955. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15956. if (clientInfo == null)
  15957. {
  15958. DateTime? dateTime = null;
  15959. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15960. if (isDt) dateTime = birthDayDt;
  15961. var addInfo1 = new Crm_DeleClient()
  15962. {
  15963. CrmCompanyId = comId,
  15964. DiId = -1,
  15965. LastName = item.LastName,
  15966. FirstName = item.Name,
  15967. OldName = "",
  15968. Pinyin = item.Pinyin,
  15969. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15970. Marriage = 0,
  15971. Phone = item.Phone,
  15972. Job = item.Job,
  15973. BirthDay = dateTime
  15974. };
  15975. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  15976. if (clientId1 > 0) clientId = clientId1;
  15977. }
  15978. else clientId = clientInfo.Id;
  15979. }
  15980. if (clientId < 1)
  15981. {
  15982. continue;
  15983. }
  15984. int airType = 0;
  15985. if (item.AirType == "超经舱") airType = 459;
  15986. else if (item.AirType == "公务舱") airType = 458;
  15987. else if (item.AirType == "经济舱") airType = 460;
  15988. else if (item.AirType == "其他") airType = 565;
  15989. else if (item.AirType == "头等舱") airType = 457;
  15990. var _TourClientListEntity = new Grp_TourClientList()
  15991. {
  15992. DiId = item.Diid,
  15993. ClientId = clientId,
  15994. CreateUserId = item.OPer,
  15995. CreateTime = Convert.ToDateTime(data11),
  15996. Remark = item.Remark,
  15997. IsDel = item.Isdel,
  15998. ShippingSpaceTypeId = airType,
  15999. ShippingSpaceSpecialNeeds = item.AirRemark,
  16000. HotelSpecialNeeds = item.RoomType
  16001. };
  16002. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  16003. if (_TourClientList > 0)
  16004. {
  16005. updateCount++;
  16006. }
  16007. }
  16008. _sqlSugar.CommitTran();
  16009. }
  16010. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  16011. }
  16012. catch (Exception ex)
  16013. {
  16014. _sqlSugar.RollbackTran();
  16015. return Ok(JsonView(false, ex.Message));
  16016. }
  16017. return Ok(JsonView(true));
  16018. }
  16019. private bool IsValidDate(string dateString, string format)
  16020. {
  16021. DateTime dateValue;
  16022. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  16023. return valid;
  16024. }
  16025. /// <summary>
  16026. /// 接团客户名单
  16027. /// 根据团组Id查询List
  16028. /// </summary>
  16029. /// <param name="dto"></param>
  16030. /// <returns></returns>
  16031. [HttpPost]
  16032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16033. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  16034. {
  16035. #region 参数验证
  16036. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  16037. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  16038. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  16039. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16040. #region 页面操作权限验证
  16041. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16042. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16043. #endregion
  16044. #endregion
  16045. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  16046. if (viewData.Code != 0)
  16047. {
  16048. return Ok(JsonView(false, viewData.Msg));
  16049. }
  16050. return Ok(JsonView(viewData.Data));
  16051. }
  16052. /// <summary>
  16053. /// 接团客户名单
  16054. /// 基础数据 Init
  16055. /// </summary>
  16056. /// <param name="_dto"></param>
  16057. /// <returns></returns>
  16058. [HttpPost]
  16059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16060. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16061. {
  16062. #region 参数验证
  16063. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16064. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16065. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16066. #region 页面操作权限验证
  16067. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16068. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16069. #endregion
  16070. #endregion
  16071. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16072. }
  16073. /// <summary>
  16074. /// 接团客户名单
  16075. /// 根据 Id查询 Details
  16076. /// </summary>
  16077. /// <param name="_dto"></param>
  16078. /// <returns></returns>
  16079. [HttpPost]
  16080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16081. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16082. {
  16083. #region 参数验证
  16084. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16085. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16086. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16087. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16088. #region 页面操作权限验证
  16089. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16090. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16091. #endregion
  16092. #endregion
  16093. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16094. if (viewData.Code != 0)
  16095. {
  16096. return Ok(JsonView(false, viewData.Msg));
  16097. }
  16098. return Ok(JsonView(viewData.Data));
  16099. }
  16100. /// <summary>
  16101. /// 接团客户名单
  16102. /// Add Or Edit
  16103. /// </summary>
  16104. /// <param name="_dto"></param>
  16105. /// <returns></returns>
  16106. [HttpPost]
  16107. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16108. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16109. {
  16110. #region 参数验证
  16111. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16112. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16113. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16114. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16115. #region 页面操作权限验证
  16116. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16117. if (_dto.Id == 0) //添加
  16118. {
  16119. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16120. }
  16121. else if (_dto.Id >= 0) //修改
  16122. {
  16123. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16124. }
  16125. #endregion
  16126. #endregion
  16127. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16128. if (viewData.Code != 0)
  16129. {
  16130. return Ok(JsonView(false, viewData.Msg));
  16131. }
  16132. return Ok(JsonView(true));
  16133. }
  16134. /// <summary>
  16135. /// 接团客户名单
  16136. /// json字符串 AddMultiple(添加多个)
  16137. /// </summary>
  16138. /// <param name="_dto"></param>
  16139. /// <returns></returns>
  16140. [HttpPost]
  16141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16142. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16143. {
  16144. #region 参数验证
  16145. string jsonLabel = _dto.JsonLabel;
  16146. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16147. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16148. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16149. #region 页面操作权限验证
  16150. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16151. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16152. #endregion
  16153. #endregion
  16154. var request = new TourClientListAddMultipleDto();
  16155. request.DiId = _dto.DiId;
  16156. request.UserId = _dto.UserId;
  16157. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16158. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16159. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16160. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16161. var infos = new List<TourClientListInfo>();
  16162. foreach (var data in datas)
  16163. {
  16164. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16165. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16166. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16167. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16168. {
  16169. continue;
  16170. }
  16171. infos.Add(new TourClientListInfo() {
  16172. IsAccompany = 1,
  16173. LastName = lastName,
  16174. FirstName = firstName,
  16175. Pinyin = lastNameEn + @"/" + firstNameEn,
  16176. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  16177. CompanyFullName = data.CompanyFullName,
  16178. Job = data.Job
  16179. });
  16180. }
  16181. if (infos.Any())
  16182. {
  16183. var viewData = await _tourClientListRep._AddMultiple(request);
  16184. if (viewData.Code != 0)
  16185. {
  16186. return Ok(JsonView(false, viewData.Msg));
  16187. }
  16188. return Ok(JsonView(true));
  16189. }
  16190. return Ok(JsonView(false));
  16191. }
  16192. /// <summary>
  16193. /// 接团客户名单
  16194. /// AddMultiple(添加多个)
  16195. /// </summary>
  16196. /// <param name="_dto"></param>
  16197. /// <returns></returns>
  16198. [HttpPost]
  16199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16200. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16201. {
  16202. #region 参数验证
  16203. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16204. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16205. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16206. #region 页面操作权限验证
  16207. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16208. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16209. #endregion
  16210. #endregion
  16211. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16212. if (viewData.Code != 0)
  16213. {
  16214. return Ok(JsonView(false, viewData.Msg));
  16215. }
  16216. return Ok(JsonView(true));
  16217. }
  16218. /// <summary>
  16219. /// 接团客户名单
  16220. /// Del
  16221. /// </summary>
  16222. /// <param name="_dto"></param>
  16223. /// <returns></returns>
  16224. [HttpPost]
  16225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16226. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16227. {
  16228. #region 参数验证
  16229. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16230. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16231. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16232. #region 页面操作权限验证
  16233. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16234. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16235. #endregion
  16236. #endregion
  16237. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16238. if (viewData.Code != 0)
  16239. {
  16240. return Ok(JsonView(false, viewData.Msg));
  16241. }
  16242. return Ok(JsonView(true));
  16243. }
  16244. /// <summary>
  16245. /// 接团客户名单
  16246. /// 文件下载 客户名单
  16247. /// </summary>
  16248. /// <param name="_dto"></param>
  16249. /// <returns></returns>
  16250. [HttpPost]
  16251. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16252. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16253. {
  16254. #region 参数验证
  16255. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16256. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16257. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16258. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16259. #region 页面操作权限验证
  16260. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16261. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16262. #endregion
  16263. #endregion
  16264. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16265. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16266. From Grp_TourClientList tcl
  16267. Left Join
  16268. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16269. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16270. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16271. From Crm_DeleClient dc
  16272. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16273. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16274. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16275. Where dc.IsDel = 0) temp
  16276. On temp.DcId =tcl.ClientId
  16277. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16278. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16279. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16280. //载入模板
  16281. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16282. if (_dto.Language == 1)
  16283. {
  16284. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16285. }
  16286. //载入模板
  16287. var doc = new Document(tempPath);
  16288. DocumentBuilder builder = new DocumentBuilder(doc);
  16289. //获取word里所有表格
  16290. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16291. //获取所填表格的序数
  16292. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16293. var rowStart = tableOne.Rows[0]; //获取第1行
  16294. if (_dto.Language == 0)
  16295. {
  16296. //循环赋值
  16297. for (int i = 0; i < DcList.Count; i++)
  16298. {
  16299. EncryptionProcessor.DecryptProperties(DcList[i]);
  16300. builder.MoveToCell(0, i + 1, 0, 0);
  16301. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16302. builder.MoveToCell(0, i + 1, 1, 0);
  16303. int sex = DcList[i].Sex;
  16304. string sexStr = string.Empty;
  16305. if (sex == 0) sexStr = "男";
  16306. else if (sex == 1) sexStr = "女";
  16307. else sexStr = "未设置";
  16308. builder.Write(sexStr);
  16309. builder.MoveToCell(0, i + 1, 2, 0);
  16310. string birthDay = DcList[i].BirthDay;
  16311. string birthDayStr = string.Empty;
  16312. if (!string.IsNullOrEmpty(birthDay))
  16313. {
  16314. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16315. }
  16316. builder.Write(birthDayStr);
  16317. builder.MoveToCell(0, i + 1, 3, 0);
  16318. string company = "";
  16319. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16320. {
  16321. company = DcList[i].CompanyFullName.ToString();
  16322. }
  16323. builder.Write(company);
  16324. builder.MoveToCell(0, i + 1, 4, 0);
  16325. builder.Write(DcList[i].Job);
  16326. }
  16327. }
  16328. else if (_dto.Language == 1)
  16329. {
  16330. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16331. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16332. List<string> transArrayStr = new List<string>();
  16333. string transStrRes1 = "";
  16334. for (int i = 0; i < DcList.Count; i++)
  16335. {
  16336. var dc = DcList[i];
  16337. EncryptionProcessor.DecryptProperties(dc);
  16338. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16339. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16340. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16341. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16342. else transStrRes1 += $"{str1}|";
  16343. }
  16344. //string transStrRes = "0 & Provincial Health & Health Commission Deputy Director | 1 & Provincial People's Hospital & Provincial People's Hospital Chief Accountant | 2 & Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College & North Sichuan Medical College | 3 & Provincial Health Commission Planning & Provincial Health Commission Planning and Information Division Director | 4 &-& Deputy Director | 5 & Provincial Health Commission population and Family Division & Provincial Health Commission population and Family Division Director";
  16345. string transStrRes = "";
  16346. if (transStrRes1.Length > 0)
  16347. {
  16348. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16349. }
  16350. //0、 Deputy Director of the Provincial Health and Health Commission | 1、 Chief Accountant of the provincial People's Hospital | 2、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 3、 Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director | 5、 Director of the population and Family Department of the Provincial Health and Health Commission | 3、 Secretary of the Party Committee of the Affiliated Hospital of North Sichuan Medical College | 4、 Deputy Director of the Planning and Information Department of the Provincial Health and Health Commission | 4、 Deputy Director of the population and Family Department of the Provincial Health and Health Commission | 5、 Director of the population and Family Department of the Provincial Health and Health Commission
  16351. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16352. //List<string> transArray = new List<string> { };
  16353. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16354. if (transStrRes.Contains("|"))
  16355. {
  16356. string[] transArray1 = transStrRes.Split('|');
  16357. if (transArray1.Length > 0)
  16358. {
  16359. foreach (var item in transArray1)
  16360. {
  16361. if (item.Contains("&"))
  16362. {
  16363. string[] transArray2 = item.Split('&');
  16364. int index = 0;
  16365. string companyName = "", job = "";
  16366. if (transArray2.Length > 0)
  16367. {
  16368. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16369. if (1 < transArray2.Length) companyName = transArray2[1];
  16370. if (2 < transArray2.Length) job = transArray2[2];
  16371. }
  16372. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16373. }
  16374. }
  16375. }
  16376. }
  16377. //循环赋值
  16378. for (int i = 0; i < DcList.Count; i++)
  16379. {
  16380. string PYName = "";
  16381. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16382. {
  16383. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16384. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16385. PYName = PY_First + " " + PY_Last;
  16386. }
  16387. else
  16388. {
  16389. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16390. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16391. PYName = PY_First + " " + PY_Last;
  16392. }
  16393. builder.MoveToCell(0, i + 1, 0, 0);
  16394. builder.Write(PYName);
  16395. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16396. builder.MoveToCell(0, i + 1, 1, 0);
  16397. builder.Write(sex);
  16398. DateTime birthDt;
  16399. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16400. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16401. builder.MoveToCell(0, i + 1, 2, 0);
  16402. builder.Write(birthday);
  16403. string company = string.Empty, job = string.Empty;
  16404. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16405. if (dcTransInfo != null)
  16406. {
  16407. company = dcTransInfo.CompanyName;
  16408. job = dcTransInfo.Job;
  16409. }
  16410. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16411. {
  16412. //查询对照表
  16413. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16414. if (tempCec != null)
  16415. {
  16416. company = tempCec.enName;
  16417. }
  16418. //翻译
  16419. else
  16420. {
  16421. }
  16422. }
  16423. builder.MoveToCell(0, i + 1, 3, 0);
  16424. builder.Write(company);
  16425. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16426. {
  16427. //查询对照表
  16428. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16429. if (tempPec != null)
  16430. {
  16431. job = tempPec.enName;
  16432. }
  16433. //翻译
  16434. else
  16435. {
  16436. }
  16437. }
  16438. builder.MoveToCell(0, i + 1, 4, 0);
  16439. builder.Write(job);
  16440. }
  16441. }
  16442. //删除多余行
  16443. while (tableOne.Rows.Count > DcList.Count + 1)
  16444. {
  16445. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16446. }
  16447. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16448. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16449. doc.Save(fileDir);
  16450. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16451. return Ok(JsonView(true, "操作成功!", Url));
  16452. }
  16453. private class TranslateInfo
  16454. {
  16455. public int Index { get; set; }
  16456. public string CompanyName { get; set; }
  16457. public string Job { get; set; }
  16458. }
  16459. #endregion
  16460. #region 团组倒推表
  16461. /// <summary>
  16462. /// 倒推表基础数据
  16463. /// Init
  16464. /// </summary>
  16465. /// <param name="dto"></param>
  16466. /// <returns></returns>
  16467. [HttpPost]
  16468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16469. public async Task<IActionResult> PostInvertedListInit()
  16470. {
  16471. var viewData = await _invertedListRep._Init();
  16472. if (viewData.Code != 0)
  16473. {
  16474. return Ok(JsonView(false, viewData.Msg));
  16475. }
  16476. return Ok(JsonView(viewData.Data));
  16477. }
  16478. /// <summary>
  16479. /// 倒推表
  16480. /// Info
  16481. /// </summary>
  16482. /// <param name="dto"></param>
  16483. /// <returns></returns>
  16484. [HttpPost]
  16485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16486. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16487. {
  16488. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16489. if (viewData.Code != 0)
  16490. {
  16491. return Ok(JsonView(false, viewData.Msg));
  16492. }
  16493. return Ok(JsonView(viewData.Data));
  16494. }
  16495. /// <summary>
  16496. /// 倒推表
  16497. /// Create
  16498. /// </summary>
  16499. /// <param name="dto"></param>
  16500. /// <returns></returns>
  16501. [HttpPost]
  16502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16503. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16504. {
  16505. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16506. if (viewData.Code != 0)
  16507. {
  16508. return Ok(JsonView(false, viewData.Msg));
  16509. }
  16510. return Ok(JsonView(viewData.Data));
  16511. }
  16512. /// <summary>
  16513. /// 倒推表
  16514. /// Update
  16515. /// </summary>
  16516. /// <param name="dto"></param>
  16517. /// <returns></returns>
  16518. [HttpPost]
  16519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16520. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16521. {
  16522. var viewData = await _invertedListRep._Update(dto);
  16523. if (viewData.Code != 0)
  16524. {
  16525. return Ok(JsonView(false, viewData.Msg));
  16526. }
  16527. return Ok(JsonView(viewData.Data));
  16528. }
  16529. /// <summary>
  16530. /// 倒推表
  16531. /// File Download
  16532. /// </summary>
  16533. /// <param name="dto"></param>
  16534. /// <returns></returns>
  16535. [HttpPost]
  16536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16537. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16538. {
  16539. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16540. if (info2.Code != 0)
  16541. {
  16542. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16543. }
  16544. var info1 = info2.Data as InvertedListInfoView;
  16545. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16546. string teamName = "";
  16547. if (info != null) teamName = info.TeamName;
  16548. //载入模板
  16549. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  16550. DocumentBuilder builder = new DocumentBuilder(doc);
  16551. //利用键值对存放数据
  16552. Dictionary<string, string> dic = new Dictionary<string, string>();
  16553. dic.Add("TeamName", teamName);
  16554. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16555. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16556. dic.Add("BPRemark", info1.ApprovalDataRemark);
  16557. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16558. dic.Add("SQRemark", info1.ApprovalRemark);
  16559. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16560. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16561. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16562. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  16563. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16564. dic.Add("QZRemark", info1.VisaInformationRemark);
  16565. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16566. dic.Add("SQQZRemark", info1.SendVisaRemark);
  16567. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16568. dic.Add("CQRemark", info1.IssueVisaRemark);
  16569. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16570. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16571. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16572. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16573. #region 填充word模板书签内容
  16574. foreach (var key in dic.Keys)
  16575. {
  16576. builder.MoveToBookmark(key);
  16577. builder.Write(dic[key]);
  16578. }
  16579. #endregion
  16580. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16581. string fileName = $"{teamName}团出行准备流程表.doc";
  16582. string filePath = fileDir + $@"InvertedList/{fileName}";
  16583. doc.Save(filePath);
  16584. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16585. return Ok(JsonView(true, "操作成功!", Url));
  16586. }
  16587. #endregion
  16588. #region 三公签证费用(签证费、代办费)
  16589. /// <summary>
  16590. /// 三公签证费用(签证费、代办费)
  16591. /// List
  16592. /// </summary>
  16593. /// <returns></returns>
  16594. [HttpPost]
  16595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16596. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16597. {
  16598. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16599. if (_view.Code != 0)
  16600. {
  16601. return Ok(JsonView(false, _view.Msg));
  16602. }
  16603. return Ok(JsonView(true, "操作成功!", _view.Data));
  16604. }
  16605. /// <summary>
  16606. /// 三公签证费用(签证费、代办费)
  16607. /// Add Or Update
  16608. /// </summary>
  16609. /// <returns></returns>
  16610. [HttpPost]
  16611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16612. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16613. {
  16614. var _view = await _visaFeeInfoRep._Update(_dto);
  16615. if (_view.Code != 0)
  16616. {
  16617. return Ok(JsonView(false, _view.Msg));
  16618. }
  16619. return Ok(JsonView(true, _view.Msg));
  16620. }
  16621. #endregion
  16622. #region 酒店询价
  16623. /// <summary>
  16624. /// 酒店询价
  16625. /// Init
  16626. /// </summary>
  16627. /// <param name="dto"></param>
  16628. /// <returns></returns>
  16629. [HttpPost]
  16630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16631. public async Task<IActionResult> PostHotelInquiryInit()
  16632. {
  16633. var res = await _hotelInquiryRep._Init();
  16634. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16635. return Ok(JsonView(true, res.Msg, res.Data));
  16636. }
  16637. /// <summary>
  16638. /// 酒店询价
  16639. /// page Item
  16640. /// </summary>
  16641. /// <param name="_dto"></param>
  16642. /// <returns></returns>
  16643. [HttpPost]
  16644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16645. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16646. {
  16647. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16648. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16649. var view = res.Data as PageDataViewBase;
  16650. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16651. }
  16652. /// <summary>
  16653. /// 酒店询价
  16654. /// info
  16655. /// </summary>
  16656. /// <param name="_dto"></param>
  16657. /// <returns></returns>
  16658. [HttpPost]
  16659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16660. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16661. {
  16662. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16663. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16664. return Ok(JsonView(true, res.Msg, res.Data));
  16665. }
  16666. /// <summary>
  16667. /// 酒店询价
  16668. /// Add Or Edit
  16669. /// </summary>
  16670. /// <param name="_dto"></param>
  16671. /// <returns></returns>
  16672. [HttpPost]
  16673. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16674. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16675. {
  16676. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16677. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16678. return Ok(JsonView(true, res.Msg, res.Data));
  16679. }
  16680. /// <summary>
  16681. /// 酒店询价
  16682. /// Del
  16683. /// </summary>
  16684. /// <param name="_dto"></param>
  16685. /// <returns></returns>
  16686. [HttpPost]
  16687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16688. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16689. {
  16690. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16691. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16692. return Ok(JsonView(true, res.Msg, res.Data));
  16693. }
  16694. #endregion
  16695. #region 下载匹配op行程单
  16696. /// <summary>
  16697. /// 匹配op行程单
  16698. /// Init
  16699. /// </summary>
  16700. /// <param name="dto">团组列表请求dto</param>
  16701. /// <returns></returns>
  16702. [HttpPost]
  16703. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16704. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16705. {
  16706. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16707. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16708. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16709. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16710. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16711. .Where(it => it.IsDel == 0)
  16712. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16713. .OrderByDescending(it => it.CreateUserId)
  16714. .ToList();
  16715. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16716. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16717. var diids = groupInfos.Select(it => it.Id).ToList();
  16718. List<string> countrys = new List<string>();
  16719. foreach (var item in country)
  16720. {
  16721. var data = _groupRepository.FormartTeamName(item);
  16722. var dataArray = _groupRepository.GroupSplitCountry(data);
  16723. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16724. }
  16725. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16726. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16727. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16728. foreach (var item in areaItem)
  16729. {
  16730. string areaStr = item.Value;
  16731. if (!string.IsNullOrEmpty(areaStr))
  16732. {
  16733. string[] str1 = areaStr.Split("-");
  16734. if (str1.Length > 0)
  16735. {
  16736. areaArray.AddRange(str1);
  16737. }
  16738. }
  16739. }
  16740. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  16741. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  16742. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  16743. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  16744. .ToList();
  16745. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  16746. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  16747. .Where(it => countriesIds.Contains(it.Id))
  16748. .Select(it => new { it.Id, Name = it.Name_CN })
  16749. .ToList();
  16750. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  16751. .Select(it => it.TeamName).ToList();
  16752. stopwatch.Stop();
  16753. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  16754. }
  16755. ///// <summary>
  16756. ///// 匹配op行程单
  16757. ///// Init 查询区域数据
  16758. ///// </summary>
  16759. ///// <param name="dto">团组列表请求dto</param>
  16760. ///// <returns></returns>
  16761. //[HttpPost]
  16762. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16763. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  16764. //{
  16765. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16766. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  16767. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  16768. // if (string.IsNullOrEmpty(countriesDataStr))
  16769. // {
  16770. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  16771. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  16772. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  16773. // }
  16774. // else
  16775. // {
  16776. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  16777. // }
  16778. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  16779. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  16780. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  16781. // List<dynamic> childList = new List<dynamic>();
  16782. // int parentId = dto.CountriesId;
  16783. // if (provinceData.Count > 1)
  16784. // {
  16785. // foreach (var item1 in provinceData)
  16786. // {
  16787. // List<dynamic> childList1 = new List<dynamic>();
  16788. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  16789. // foreach (var item2 in citiesData1)
  16790. // {
  16791. // List<dynamic> childList2 = new List<dynamic>();
  16792. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16793. // foreach (var item3 in countiesData1)
  16794. // {
  16795. // childList2.Add(new
  16796. // {
  16797. // id = item3.Id,
  16798. // parentId = item2.Id,
  16799. // level = "district",
  16800. // name = item3.Name_CN,
  16801. // });
  16802. // }
  16803. // childList1.Add(new
  16804. // {
  16805. // id = item2.Id,
  16806. // parentId = item1.Id,
  16807. // level = "city",
  16808. // name = item2.Name_CN,
  16809. // childList = childList2
  16810. // });
  16811. // }
  16812. // childList.Add(new
  16813. // {
  16814. // id = item1.Id,
  16815. // parentId = parentId,
  16816. // level = "province",
  16817. // name = item1.Name_CN,
  16818. // childList = childList1
  16819. // });
  16820. // }
  16821. // //城市
  16822. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  16823. // foreach (var item2 in citiesData2)
  16824. // {
  16825. // List<dynamic> childList22 = new List<dynamic>();
  16826. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16827. // foreach (var item3 in countiesData1)
  16828. // {
  16829. // childList22.Add(new
  16830. // {
  16831. // id = item3.Id,
  16832. // parentId = item2.Id,
  16833. // level = "district",
  16834. // name = item3.Name_CN,
  16835. // });
  16836. // }
  16837. // childList.Add(new
  16838. // {
  16839. // id = item2.Id,
  16840. // parentId = parentId,
  16841. // level = "city",
  16842. // name = item2.Name_CN,
  16843. // childList = childList22
  16844. // });
  16845. // }
  16846. // }
  16847. // else
  16848. // {
  16849. // foreach (var item2 in citiesData)
  16850. // {
  16851. // string cname = item2.Name_CN;
  16852. // List<dynamic> childList1 = new List<dynamic>();
  16853. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16854. // foreach (var item3 in countiesData1)
  16855. // {
  16856. // childList1.Add(new
  16857. // {
  16858. // Id = item3.Id,
  16859. // parentId = item2.Id,
  16860. // level = "district",
  16861. // name = item3.Name_CN
  16862. // });
  16863. // }
  16864. // childList.Add(new
  16865. // {
  16866. // id = item2.Id,
  16867. // parentId = parentId,
  16868. // level = "city",
  16869. // name = item2.Name_CN,
  16870. // childList = childList1
  16871. // });
  16872. // }
  16873. // }
  16874. // stopwatch.Stop();
  16875. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  16876. //}
  16877. /// <summary>
  16878. /// 匹配op行程单
  16879. /// 接团信息列表 Page
  16880. /// </summary>
  16881. /// <param name="dto">团组列表请求dto</param>
  16882. /// <returns></returns>
  16883. [HttpPost]
  16884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16885. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  16886. {
  16887. var swatch = new Stopwatch();
  16888. swatch.Start();
  16889. #region 参数验证
  16890. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16891. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16892. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16893. #region 页面操作权限验证
  16894. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16895. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  16896. #endregion
  16897. #endregion
  16898. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16899. {
  16900. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  16901. string sqlWhere = "";
  16902. if (!string.IsNullOrEmpty(dto.Country))
  16903. {
  16904. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  16905. }
  16906. if (!string.IsNullOrEmpty(dto.Area))
  16907. {
  16908. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  16909. }
  16910. if (!string.IsNullOrEmpty(dto.TeamName))
  16911. {
  16912. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  16913. }
  16914. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  16915. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  16916. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  16917. swatch.Stop();
  16918. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  16919. }
  16920. else
  16921. {
  16922. return Ok(JsonView(false, "查询失败"));
  16923. }
  16924. }
  16925. /// <summary>
  16926. /// 匹配op行程单
  16927. /// 行程单下载
  16928. /// </summary>
  16929. /// <param name="dto">团组列表请求dto</param>
  16930. /// <returns></returns>
  16931. [HttpPost]
  16932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16933. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  16934. {
  16935. #region 参数验证
  16936. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16937. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16938. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16939. #region 页面操作权限验证
  16940. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16941. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  16942. #endregion
  16943. #endregion
  16944. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16945. {
  16946. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  16947. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  16948. }
  16949. else
  16950. {
  16951. return Ok(JsonView(false, "下载失败!"));
  16952. }
  16953. }
  16954. #endregion
  16955. #region 国家信息 数据 注释
  16956. //[HttpPost]
  16957. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  16958. //{
  16959. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  16960. // foreach (var item in dto)
  16961. // {
  16962. // infos.Add(new Grp_GroupsTaskAssignment()
  16963. // {
  16964. // DIId = item,
  16965. // CTId = 82,
  16966. // UId = 248,
  16967. // IsEnable = 1,
  16968. // CreateUserId = 233,
  16969. // CreateTime = DateTime.Now,
  16970. // IsDel = 0
  16971. // });
  16972. // infos.Add(new Grp_GroupsTaskAssignment()
  16973. // {
  16974. // DIId = item,
  16975. // CTId = 82,
  16976. // UId = 286,
  16977. // IsEnable = 1,
  16978. // CreateUserId = 233,
  16979. // CreateTime = DateTime.Now,
  16980. // IsDel = 0
  16981. // });
  16982. // }
  16983. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  16984. // return Ok("操作成功");
  16985. //}
  16986. //public class paramJsonDto
  16987. //{
  16988. // public List<CountriesInfo> str { get; set; }
  16989. //}
  16990. //[HttpPost]
  16991. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  16992. //{
  16993. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  16994. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  16995. // List<Sys_Cities> cities = new List<Sys_Cities>();
  16996. // List<Sys_Cities> districts = new List<Sys_Cities>();
  16997. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  16998. // _sqlSugar.BeginTran();
  16999. // int countitiesIndex = 0;
  17000. // foreach (var item in dto.str)
  17001. // {
  17002. // dynamic data = item.c;
  17003. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  17004. // if (data != null)
  17005. // {
  17006. // countitiesIndex++;
  17007. // foreach (var item1 in data)
  17008. // {
  17009. // string cnname = item1.cn;
  17010. // string enname = item1.en;
  17011. // Sys_Cities provinceInfo = new Sys_Cities()
  17012. // {
  17013. // CountriesId = countriesId,
  17014. // Name_CN = cnname,
  17015. // Name_EN = enname,
  17016. // ParentId = 0,
  17017. // IsCapital = 1,
  17018. // CreateUserId = 208,
  17019. // CreateTime = DateTime.Now,
  17020. // IsDel = 0
  17021. // };
  17022. // if (item1.lv == "province") //省份
  17023. // {
  17024. // provinceInfo.Level = 1;
  17025. // int provinceId = 0;
  17026. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  17027. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  17028. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17029. // var data1 = item1.c;
  17030. // foreach (var item2 in data1)
  17031. // {
  17032. // if (item2.lv == "city")
  17033. // {
  17034. // string citycnname = item2.cn;
  17035. // string cityenname = item2.en;
  17036. // Sys_Cities cityInfo = new Sys_Cities()
  17037. // {
  17038. // CountriesId = countriesId,
  17039. // ParentId = provinceId,
  17040. // Level = 2,
  17041. // Name_CN = citycnname,
  17042. // Name_EN = cityenname,
  17043. // IsCapital = 1,
  17044. // CreateUserId = 208,
  17045. // CreateTime = DateTime.Now,
  17046. // IsDel = 0
  17047. // };
  17048. // if (item2.c != null)
  17049. // {
  17050. // int cityId = 0;
  17051. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17052. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17053. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17054. // foreach (var item3 in item2.c)
  17055. // {
  17056. // if (item3.lv == "district")
  17057. // {
  17058. // var districtInfo = new Sys_Cities()
  17059. // {
  17060. // CountriesId = countriesId,
  17061. // Name_CN = item3.cn,
  17062. // Name_EN = item3.en,
  17063. // Level = 3,
  17064. // ParentId = cityId,
  17065. // IsCapital = 1,
  17066. // CreateUserId = 208,
  17067. // CreateTime = DateTime.Now,
  17068. // IsDel = 0
  17069. // };
  17070. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17071. // //{
  17072. // districts.Add(districtInfo);
  17073. // //}
  17074. // }
  17075. // }
  17076. // }
  17077. // else
  17078. // {
  17079. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17080. // //{
  17081. // cities.Add(cityInfo);
  17082. // //}
  17083. // }
  17084. // }
  17085. // }
  17086. // }
  17087. // else if (item1.lv == "city")//城市
  17088. // {
  17089. // provinceInfo.Level = 2;
  17090. // if (item1.c != null)
  17091. // {
  17092. // int cityId = 0;
  17093. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17094. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17095. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17096. // foreach (var item3 in item1.c)
  17097. // {
  17098. // if (item3.lv == "district")
  17099. // {
  17100. // var districtInfo = new Sys_Cities()
  17101. // {
  17102. // CountriesId = countriesId,
  17103. // Name_CN = item3.cn,
  17104. // Name_EN = item3.en,
  17105. // Level = 3,
  17106. // ParentId = cityId,
  17107. // IsCapital = 1,
  17108. // CreateUserId = 208,
  17109. // CreateTime = DateTime.Now,
  17110. // IsDel = 0
  17111. // };
  17112. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17113. // //{
  17114. // districts.Add(districtInfo);
  17115. // //}
  17116. // }
  17117. // }
  17118. // }
  17119. // else
  17120. // {
  17121. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17122. // //{
  17123. // cities.Add(provinceInfo);
  17124. // //}
  17125. // }
  17126. // }
  17127. // }
  17128. // }
  17129. // }
  17130. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17131. // cities = cities.Distinct().ToList();
  17132. // districts = districts.Distinct().ToList();
  17133. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17134. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17135. // cities.AddRange(districts);
  17136. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17137. // //_sqlSugar.RollbackTran();
  17138. // _sqlSugar.CommitTran();
  17139. // return Ok(JsonView(false, "操作成功!"));
  17140. //}
  17141. //[HttpPost]
  17142. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17143. //{
  17144. // List<CountitiesInfo> infos = dto.MyProperty;
  17145. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17146. // _sqlSugar.BeginTran();
  17147. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17148. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17149. // foreach (var item in infos)
  17150. // {
  17151. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17152. // if (countryInfo != null)
  17153. // {
  17154. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17155. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17156. // if (cityInfo1 != null)
  17157. // {
  17158. // cityInfo1.IsCapital = 0;
  17159. // cityInfos.Add(cityInfo1);
  17160. // }
  17161. // }
  17162. // }
  17163. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17164. // .UpdateColumns(it => it.IsCapital)
  17165. // .WhereColumns(it => it.Id)
  17166. // .ExecuteCommand();
  17167. // //_sqlSugar.RollbackTran();
  17168. // _sqlSugar.CommitTran();
  17169. // return Ok(JsonView(false, "操作成功!"));
  17170. //}
  17171. //public class CounrtiesDto
  17172. //{
  17173. // public List<CountitiesInfo> MyProperty { get; set; }
  17174. //}
  17175. //public class CountitiesInfo
  17176. //{
  17177. // /// <summary>
  17178. // /// 圣约翰
  17179. // /// </summary>
  17180. // public string capital_name_chinese { get; set; }
  17181. // /// <summary>
  17182. // ///
  17183. // /// </summary>
  17184. // public string capital_name { get; set; }
  17185. // /// <summary>
  17186. // ///
  17187. // /// </summary>
  17188. // public string country_type { get; set; }
  17189. // /// <summary>
  17190. // /// 安提瓜和巴布达
  17191. // /// </summary>
  17192. // public string country_name_chinese { get; set; }
  17193. // /// <summary>
  17194. // /// 安提瓜和巴布达
  17195. // /// </summary>
  17196. // public string country_name_chinese_short { get; set; }
  17197. // /// <summary>
  17198. // /// 安提瓜和巴布达
  17199. // /// </summary>
  17200. // public string country_name_chinese_UN { get; set; }
  17201. // /// <summary>
  17202. // ///
  17203. // /// </summary>
  17204. // public string country_name_english_abbreviation { get; set; }
  17205. // /// <summary>
  17206. // ///
  17207. // /// </summary>
  17208. // public string country_name_english_formal { get; set; }
  17209. // /// <summary>
  17210. // ///
  17211. // /// </summary>
  17212. // public string country_name_english_UN { get; set; }
  17213. // /// <summary>
  17214. // ///
  17215. // /// </summary>
  17216. // public string continent_name { get; set; }
  17217. // /// <summary>
  17218. // ///
  17219. // /// </summary>
  17220. // public string subregion_name { get; set; }
  17221. // /// <summary>
  17222. // ///
  17223. // /// </summary>
  17224. // public string country_code2 { get; set; }
  17225. // /// <summary>
  17226. // ///
  17227. // /// </summary>
  17228. // public string country_code3 { get; set; }
  17229. // /// <summary>
  17230. // ///
  17231. // /// </summary>
  17232. // public string phone_code { get; set; }
  17233. //}
  17234. //public class CountriesInfo : BasicInfo
  17235. //{
  17236. // public List<CitiesInfo> c { get; set; }
  17237. //}
  17238. //public class CitiesInfo : BasicInfo
  17239. //{
  17240. // public List<AreaInfo> c { get; set; }
  17241. //}
  17242. //public class AreaInfo : BasicInfo
  17243. //{
  17244. // public List<AreaInfo> c { get; set; }
  17245. //}
  17246. //public class BasicInfo
  17247. //{
  17248. // public string code { get; set; }
  17249. // public string cn { get; set; }
  17250. // public string lv { get; set; }
  17251. // public string en { get; set; }
  17252. //}
  17253. #endregion
  17254. #region 查看邀请方
  17255. /// <summary>
  17256. /// 查看邀请方
  17257. /// 邀请方信息 Init
  17258. /// </summary>
  17259. /// <param name="dto"></param>
  17260. /// <returns></returns>
  17261. [HttpPost]
  17262. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17263. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17264. {
  17265. string sqlWhere = string.Empty;
  17266. if (!string.IsNullOrEmpty(dto.Search))
  17267. {
  17268. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17269. }
  17270. string sql = string.Format($@"Select
  17271. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17272. Id,
  17273. UnitName
  17274. From Res_InvitationOfficialActivityData
  17275. Where IsDel = 0
  17276. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17277. RefAsync<int> total = 0;
  17278. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17279. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17280. }
  17281. /// <summary>
  17282. /// 查看邀请方
  17283. /// 国家信息 Init
  17284. /// </summary>
  17285. /// <param name="dto"></param>
  17286. /// <returns></returns>
  17287. [HttpPost]
  17288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17289. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17290. {
  17291. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17292. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17293. var diids = groupInfos.Select(it => it.Id).ToList();
  17294. List<string> countrys = new List<string>();
  17295. foreach (var item in country)
  17296. {
  17297. var data = _groupRepository.FormartTeamName(item);
  17298. var dataArray = _groupRepository.GroupSplitCountry(data);
  17299. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17300. }
  17301. countrys = countrys.Distinct().ToList();
  17302. for (int i = 0; i < countrys.Count; i++)
  17303. {
  17304. string item = countrys[i];
  17305. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17306. {
  17307. countrys.Remove(item);
  17308. i--;
  17309. }
  17310. }
  17311. RefAsync<int> total = 0;
  17312. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17313. .Where(it => countrys.Contains(it.Name_CN))
  17314. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17315. .Select(it => new { id = it.Id, name = it.Name_CN })
  17316. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17317. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17318. }
  17319. /// <summary>
  17320. /// 查看邀请方
  17321. /// 城市信息 Init
  17322. /// </summary>
  17323. /// <param name="dto"></param>
  17324. /// <returns></returns>
  17325. [HttpPost]
  17326. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17327. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17328. {
  17329. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17330. RefAsync<int> total = 0;
  17331. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17332. .Where(it => it.CountriesId == dto.CountiesId)
  17333. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17334. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17335. .Select(it => new { id = it.Id, name = it.Name_CN })
  17336. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17337. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17338. }
  17339. /// <summary>
  17340. /// 查看邀请方
  17341. /// 团组名称 Init
  17342. /// </summary>
  17343. /// <param name="dto"></param>
  17344. /// <returns></returns>
  17345. [HttpPost]
  17346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17347. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17348. {
  17349. var watch = new Stopwatch();
  17350. watch.Start();
  17351. RefAsync<int> total = 0;
  17352. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17353. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17354. .Where((oa, di) => oa.IsDel == 0)
  17355. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17356. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17357. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17358. .Distinct()
  17359. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17360. watch.Stop();
  17361. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17362. }
  17363. /// <summary>
  17364. /// 查看邀请方
  17365. /// 团组 & 邀请方信息
  17366. /// </summary>
  17367. /// <param name="dto"></param>
  17368. /// <returns></returns>
  17369. [HttpPost]
  17370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17371. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17372. {
  17373. var watch = new Stopwatch();
  17374. watch.Start();
  17375. RefAsync<int> total = 0;
  17376. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17377. .AS("Grp_DelegationInfo")
  17378. .Includes(x => x.InvitingInfos)
  17379. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17380. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17381. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17382. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17383. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17384. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17385. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17386. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17387. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17388. infos.ForEach(x =>
  17389. {
  17390. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17391. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17392. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17393. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17394. });
  17395. watch.Stop();
  17396. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17397. }
  17398. #endregion
  17399. #region 报批行程
  17400. /// <summary>
  17401. /// 报批行程初始化
  17402. /// </summary>
  17403. /// <param name="dto"></param>
  17404. /// <returns></returns>
  17405. [HttpPost]
  17406. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17407. {
  17408. const int chiNumber = 5;
  17409. var jw = JsonView(false);
  17410. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17411. var group = groupList.First();
  17412. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17413. group = groupList.First(x => x.Id == diid);
  17414. if (group == null)
  17415. {
  17416. jw.Msg = "暂无团组!";
  17417. return Ok(jw);
  17418. }
  17419. var data = new
  17420. {
  17421. groupList = groupList.Select(x => new
  17422. {
  17423. x.TeamName,
  17424. x.Id
  17425. }),
  17426. content = new ArrayList(),
  17427. groupInfo = new
  17428. {
  17429. group.VisitDays,
  17430. group.TourCode,
  17431. group.VisitPNumber,
  17432. group.TeamName,
  17433. group.Id,
  17434. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17435. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17436. },
  17437. };
  17438. var resultArr = new ArrayList();
  17439. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17440. if (content.Count == 0)
  17441. {
  17442. var stay = "-";
  17443. var cityPath = "-";
  17444. //添加城市路径以及住宿地
  17445. //黑屏代码数据
  17446. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17447. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17448. {
  17449. jw = JsonView(true, "黑屏代码有误!", data);
  17450. return Ok(jw);
  17451. }
  17452. foreach (DataRow row in dtBlack.Rows)
  17453. {
  17454. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17455. {
  17456. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17457. return Ok(jw);
  17458. }
  17459. }
  17460. //黑屏代码获取时间区间
  17461. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17462. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17463. _sqlSugar.BeginTran();
  17464. for (int i = 0; i < timeArr.Count; i++)
  17465. {
  17466. stay = "-";
  17467. cityPath = "-";
  17468. DateTime NewData = DateTime.Parse(timeArr[i]);
  17469. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17470. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17471. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17472. if (tbSelect.Length > 0)
  17473. {
  17474. List<string> threeCodeStr = new List<string>();
  17475. foreach (var item in tbSelect)
  17476. {
  17477. var threeCode = item["Three"].ToString() ?? "";
  17478. if (threeCode.Length == 6)
  17479. {
  17480. var start = threeCode.Substring(0, 3);
  17481. var end = threeCode.Substring(3, 3);
  17482. if (threeCodeStr.Count == 0)
  17483. {
  17484. threeCodeStr.Add(start);
  17485. threeCodeStr.Add(end);
  17486. }
  17487. else
  17488. {
  17489. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17490. {
  17491. threeCodeStr.Add(end);
  17492. }
  17493. else
  17494. {
  17495. threeCodeStr.Add(start);
  17496. threeCodeStr.Add(end);
  17497. }
  17498. }
  17499. }
  17500. }
  17501. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17502. var last = threeCodeStr.Last();
  17503. foreach (var item in threeCodeStr)
  17504. {
  17505. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17506. if (item.Equals(last))
  17507. {
  17508. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17509. }
  17510. }
  17511. cityPath = cityPath.Trim('-');
  17512. }
  17513. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17514. appro.Diid = diid ?? -1;
  17515. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17516. appro.Id = thisId;
  17517. appro.CreateUserId = dto.UserId;
  17518. appro.CreateTime = DateTime.Now;
  17519. content.Add(appro);
  17520. }
  17521. _sqlSugar.CommitTran();
  17522. }
  17523. foreach (var x in content)
  17524. {
  17525. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17526. if (chiList.Count < chiNumber)
  17527. {
  17528. for (int i = chiList.Count; i < chiNumber; i++)
  17529. {
  17530. chiList.Add(new Grp_ApprovalTravelDetails());
  17531. }
  17532. }
  17533. resultArr.Add(new
  17534. {
  17535. x.Id,
  17536. x.Date,
  17537. x.Diid,
  17538. chiList = chiList.Select(x1 => new
  17539. {
  17540. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17541. x1.Details,
  17542. x1.ParentId,
  17543. x1.Id
  17544. })
  17545. });
  17546. }
  17547. data = data with
  17548. {
  17549. content = resultArr,
  17550. };
  17551. jw = JsonView(true, "获取成功!", data);
  17552. return Ok(jw);
  17553. }
  17554. /// <summary>
  17555. /// 报批行程删除
  17556. /// </summary>
  17557. /// <param name="dto"></param>
  17558. /// <returns></returns>
  17559. [HttpPost]
  17560. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17561. {
  17562. var jw = JsonView(false);
  17563. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17564. if (group == null)
  17565. {
  17566. jw.Msg = "团组参数有误!";
  17567. return Ok(jw);
  17568. }
  17569. try
  17570. {
  17571. _sqlSugar.BeginTran();
  17572. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17573. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17574. {
  17575. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17576. DeleteUserId = dto.uesrId,
  17577. IsDel = 1
  17578. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17579. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17580. {
  17581. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17582. DeleteUserId = dto.uesrId,
  17583. IsDel = 1
  17584. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17585. _sqlSugar.CommitTran();
  17586. jw = JsonView(true, "删除成功");
  17587. }
  17588. catch (Exception ex)
  17589. {
  17590. jw = JsonView(false, ex.Message);
  17591. }
  17592. return Ok(jw);
  17593. }
  17594. /// <summary>
  17595. /// 报批行程保存
  17596. /// </summary>
  17597. /// <param name="dto"></param>
  17598. /// <returns></returns>
  17599. [HttpPost]
  17600. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17601. {
  17602. var jw = JsonView(false);
  17603. var Find = dto.Arr.Find(x => x.id == 0);
  17604. if (Find != null)
  17605. {
  17606. jw.Msg = "生成的ID为0!";
  17607. return Ok(jw);
  17608. }
  17609. foreach (var item in dto.Arr)
  17610. {
  17611. foreach (var chi in item.chiList)
  17612. {
  17613. if (chi.parentId == 0)
  17614. {
  17615. chi.parentId = item.id;
  17616. }
  17617. }
  17618. }
  17619. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17620. _sqlSugar.BeginTran();
  17621. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17622. {
  17623. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17624. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17625. {
  17626. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17627. DeleteUserId = dto.UserId,
  17628. IsDel = 1
  17629. }).ExecuteCommand();
  17630. }
  17631. try
  17632. {
  17633. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17634. {
  17635. CreateTime = DateTime.Now,
  17636. CreateUserId = dto.UserId,
  17637. Details = x.details,
  17638. ParentId = x.parentId,
  17639. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17640. Remark = "",
  17641. IsDel = 0
  17642. }).ToList()).ExecuteCommand();
  17643. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17644. {
  17645. Id = x.id,
  17646. Details = x.details,
  17647. ParentId = x.parentId,
  17648. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17649. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17650. {
  17651. Details = x.Details,
  17652. ParentId = x.ParentId,
  17653. Time = x.Time
  17654. }).ExecuteCommand();
  17655. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17656. {
  17657. Id = x.id,
  17658. Date = x.date,
  17659. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17660. {
  17661. Date = x.Date
  17662. }).ExecuteCommand();
  17663. _sqlSugar.CommitTran();
  17664. jw = JsonView(true, "保存成功!");
  17665. }
  17666. catch (Exception ex)
  17667. {
  17668. _sqlSugar.RollbackTran();
  17669. jw = JsonView(false, "保存失败!" + ex.Message);
  17670. }
  17671. return Ok(jw);
  17672. }
  17673. /// <summary>
  17674. /// 报批行程生成
  17675. /// </summary>
  17676. /// <param name="dto"></param>
  17677. /// <returns></returns>
  17678. [HttpPost]
  17679. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17680. {
  17681. var jw = JsonView(false);
  17682. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17683. if (group == null)
  17684. {
  17685. jw.Msg = "暂无该团组!";
  17686. return Ok(jw);
  17687. }
  17688. //黑屏代码数据
  17689. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17690. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17691. {
  17692. jw.Msg = "黑屏代码有误!";
  17693. return Ok(jw);
  17694. }
  17695. foreach (DataRow row in dtBlack.Rows)
  17696. {
  17697. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17698. {
  17699. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17700. return Ok(jw);
  17701. }
  17702. }
  17703. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17704. var resultArr = new ArrayList();
  17705. if (officialActivitiesArr.Count == 0)
  17706. {
  17707. jw.Msg = "暂无公务出访信息!";
  17708. return Ok(jw);
  17709. }
  17710. try
  17711. {
  17712. _sqlSugar.BeginTran();
  17713. DeleteApprovalJourney(new
  17714. Domain.Dtos.Groups.DeleteApprovalJourney
  17715. {
  17716. Diid = dto.Diid,
  17717. uesrId = dto.Userid
  17718. });
  17719. var stay = "-";
  17720. var cityPath = "-";
  17721. //添加城市路径以及住宿地
  17722. //黑屏代码获取时间区间
  17723. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17724. var empty = "【未收入该三字码!请机票同事录入】";
  17725. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17726. for (int i = 0; i < timeArr.Count; i++)
  17727. {
  17728. stay = "-";
  17729. cityPath = "-";
  17730. var chiarr = new List<Grp_ApprovalTravelDetails>();
  17731. DateTime NewData = DateTime.Parse(timeArr[i]);
  17732. 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();
  17733. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17734. if (tbSelect.Length > 0)
  17735. {
  17736. List<string> threeCodeStr = new List<string>();
  17737. bool isTrade = false;
  17738. string trip = string.Empty;
  17739. var rowLast = tbSelect.Last();
  17740. var rowFirst = tbSelect.First();
  17741. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  17742. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  17743. var takeOffTime = DateTime.Parse(timeArr[i]);
  17744. var fallToTime = DateTime.Parse(timeArr[i]);
  17745. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  17746. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  17747. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  17748. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  17749. foreach (var item in tbSelect)
  17750. {
  17751. var start = string.Empty;
  17752. var end = string.Empty;
  17753. var threeCode = item["Three"].ToString() ?? "";
  17754. if (threeCode.Length == 6)
  17755. {
  17756. start = threeCode.Substring(0, 3);
  17757. end = threeCode.Substring(3, 3);
  17758. if (threeCodeStr.Count == 0)
  17759. {
  17760. threeCodeStr.Add(start);
  17761. threeCodeStr.Add(end);
  17762. }
  17763. else
  17764. {
  17765. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17766. {
  17767. threeCodeStr.Add(end);
  17768. }
  17769. else
  17770. {
  17771. threeCodeStr.Add(start);
  17772. threeCodeStr.Add(end);
  17773. }
  17774. }
  17775. }
  17776. //处理机票信息
  17777. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  17778. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  17779. if (start_Object == null)
  17780. {
  17781. start_Object = new Res_ThreeCode()
  17782. {
  17783. AirPort = empty,
  17784. AirPort_En = empty,
  17785. City = empty,
  17786. Country = empty,
  17787. Four = empty,
  17788. Three = empty,
  17789. };
  17790. }
  17791. if (end_Object == null)
  17792. {
  17793. end_Object = new Res_ThreeCode()
  17794. {
  17795. AirPort = empty,
  17796. AirPort_En = empty,
  17797. City = empty,
  17798. Country = empty,
  17799. Four = empty,
  17800. Three = empty,
  17801. };
  17802. }
  17803. //机型判断
  17804. string airModel = item["AirModel"].ToString();
  17805. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  17806. string flightTime = item["FlightTime"].ToString();
  17807. if (flightTime!.Contains(":"))
  17808. {
  17809. flightTime = flightTime.Replace(":", "小时");
  17810. flightTime += "分钟";
  17811. }
  17812. if (flightTime.Contains("H"))
  17813. {
  17814. flightTime = flightTime.Replace("H", "小时");
  17815. }
  17816. if (flightTime.Contains("M"))
  17817. {
  17818. flightTime = flightTime.Replace("M", "分钟");
  17819. }
  17820. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  17821. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  17822. {
  17823. flightTime = flightDataTime.Hour > 0
  17824. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  17825. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  17826. ? flightDataTime.Minute.ToString() + "分钟" : "";
  17827. }
  17828. //航班号
  17829. string flightcode = item["Fliagtcode"].ToString();
  17830. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  17831. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  17832. if (aircompany == null)
  17833. {
  17834. aircompany = new Res_AirCompany
  17835. {
  17836. CnName = hsEmpty,
  17837. EnName = hsEmpty,
  17838. ShortCode = hsEmpty,
  17839. };
  17840. }
  17841. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  17842. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  17843. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  17844. if (isTrade)
  17845. {
  17846. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  17847. }
  17848. else
  17849. {
  17850. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  17851. }
  17852. }
  17853. chiarr.Add(new Grp_ApprovalTravelDetails
  17854. {
  17855. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  17856. CreateTime = DateTime.Now,
  17857. CreateUserId = dto.Userid,
  17858. ParentId = 0,
  17859. Details = trip
  17860. });
  17861. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17862. var last = threeCodeStr.Last();
  17863. foreach (var item in threeCodeStr)
  17864. {
  17865. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17866. if (item.Equals(last))
  17867. {
  17868. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17869. }
  17870. }
  17871. cityPath = cityPath.Trim('-');
  17872. }
  17873. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17874. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17875. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17876. appro.Diid = dto.Diid;
  17877. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17878. appro.Id = thisId;
  17879. appro.CreateUserId = dto.Userid;
  17880. appro.CreateTime = DateTime.Now;
  17881. foreach (var item in gwinfo)
  17882. {
  17883. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  17884. chi.Details = "拜访" + item.Client;
  17885. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  17886. {
  17887. chi.Details += "," + item.ReqSample;
  17888. }
  17889. chi.ParentId = thisId;
  17890. chi.Time = item.Time;
  17891. chiarr.Add(chi);
  17892. }
  17893. if (chiarr.Count < 5)
  17894. {
  17895. for (int j = chiarr.Count; j < 5; j++)
  17896. {
  17897. chiarr.Add(new
  17898. Grp_ApprovalTravelDetails());
  17899. }
  17900. }
  17901. resultArr.Add(new
  17902. {
  17903. appro.Id,
  17904. appro.Date,
  17905. appro.Diid,
  17906. chiList = chiarr.Select(x1 => new
  17907. {
  17908. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17909. x1.Details,
  17910. x1.ParentId,
  17911. x1.Id
  17912. })
  17913. });
  17914. }
  17915. _sqlSugar.CommitTran();
  17916. jw = JsonView(true, "生成成功!", resultArr);
  17917. }
  17918. catch (Exception ex)
  17919. {
  17920. jw.Code = 400;
  17921. jw.Msg = "生成失败!" + ex.Message;
  17922. }
  17923. return Ok(jw);
  17924. }
  17925. /// <summary>
  17926. /// 报批行程word导出
  17927. /// </summary>
  17928. /// <param name="dto"></param>
  17929. /// <returns></returns>
  17930. [HttpPost]
  17931. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  17932. {
  17933. var jw = JsonView(false);
  17934. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17935. if (group == null)
  17936. {
  17937. jw.Msg = "暂无该团组!";
  17938. return Ok(jw);
  17939. }
  17940. //模板路径
  17941. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  17942. //载入模板
  17943. Document doc = new Document(tempPath);
  17944. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17945. //获取所填表格的序数
  17946. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17947. Aspose.Words.Tables.Row titleRowClone = null;
  17948. Aspose.Words.Tables.Row CenterRowClone = null;
  17949. int index = 0;
  17950. int indexChi = 0;
  17951. int SetIndex = 0;
  17952. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  17953. //获取数据,放到datatable
  17954. foreach (var item in ApprovalTravelArr)
  17955. {
  17956. if (index > 0)
  17957. {
  17958. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  17959. tableOne.AppendChild(titleRowClone);
  17960. }
  17961. var textTime = item.Date;
  17962. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  17963. SetCells(tableOne, doc, SetIndex, 0, textTime);
  17964. SetIndex++;
  17965. if (ChiRep.Count > 0)
  17966. {
  17967. foreach (var itemChi in ChiRep)
  17968. {
  17969. var txtTime = itemChi.Time;
  17970. var txtDetail = itemChi.Details;
  17971. if (indexChi > 0)
  17972. {
  17973. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17974. tableOne.AppendChild(CenterRowClone);
  17975. }
  17976. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  17977. {
  17978. SetCells(tableOne, doc, SetIndex, 0, "");
  17979. SetCells(tableOne, doc, SetIndex, 1, "");
  17980. indexChi++;
  17981. SetIndex++;
  17982. break;
  17983. }
  17984. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  17985. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  17986. indexChi++;
  17987. SetIndex++;
  17988. }
  17989. }
  17990. else
  17991. {
  17992. if (indexChi > 0)
  17993. {
  17994. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17995. tableOne.AppendChild(CenterRowClone);
  17996. }
  17997. SetCells(tableOne, doc, SetIndex, 0, "");
  17998. SetCells(tableOne, doc, SetIndex, 1, "");
  17999. indexChi++;
  18000. SetIndex++;
  18001. }
  18002. index++;
  18003. }
  18004. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  18005. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18006. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  18007. jw.Code = 200;
  18008. jw.Msg = "";
  18009. return Ok(jw);
  18010. }
  18011. private string intToString(int numberVal)
  18012. {
  18013. string numberval = numberVal.ToString();
  18014. Dictionary<char, string> Number = new Dictionary<char, string>();
  18015. Number.Add('1', "一");
  18016. Number.Add('2', "二");
  18017. Number.Add('3', "三");
  18018. Number.Add('4', "四");
  18019. Number.Add('5', "五");
  18020. Number.Add('6', "六");
  18021. Number.Add('7', "七");
  18022. Number.Add('8', "八");
  18023. Number.Add('9', "九");
  18024. string stringNumberVal = string.Empty;
  18025. for (int i = 0; i < numberval.Length; i++)
  18026. {
  18027. if (i == 0)
  18028. {
  18029. stringNumberVal += Number[numberval[i]];
  18030. }
  18031. else if (i >= 1)
  18032. {
  18033. if (numberval[i] == '0')
  18034. {
  18035. stringNumberVal = "十";
  18036. }
  18037. else
  18038. {
  18039. stringNumberVal += "十" + Number[numberval[i]];
  18040. }
  18041. }
  18042. }
  18043. return stringNumberVal;
  18044. }
  18045. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  18046. {
  18047. //获取table中的某个单元格,从0开始
  18048. Cell lshCell = table.Rows[rows].Cells[cells];
  18049. //将单元格中段落移除
  18050. foreach (Node item in lshCell.Paragraphs)
  18051. {
  18052. lshCell.Paragraphs.Remove(item);
  18053. }
  18054. if (val.Contains("\r\n"))
  18055. {
  18056. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18057. foreach (var item in spArr)
  18058. {
  18059. //新建一个段落
  18060. Paragraph p = new Paragraph(doc);
  18061. var r = new Run(doc, item);
  18062. //把设置的值赋给之前新建的段落
  18063. p.AppendChild(r);
  18064. //将此段落加到单元格内
  18065. lshCell.AppendChild(p);
  18066. }
  18067. }
  18068. else
  18069. {
  18070. //新建一个段落
  18071. Paragraph p = new Paragraph(doc);
  18072. var r = new Run(doc, val);
  18073. //把设置的值赋给之前新建的段落
  18074. p.AppendChild(r);
  18075. //将此段落加到单元格内
  18076. lshCell.AppendChild(p);
  18077. }
  18078. }
  18079. [HttpPost]
  18080. public async Task<IActionResult> ServerHttp(string paramStr)
  18081. {
  18082. paramStr = paramStr.TrimEnd('\'');
  18083. paramStr = paramStr.TrimStart('\'');
  18084. JsonView jw = JsonView(false);
  18085. JObject param = JObject.Parse(paramStr);
  18086. if (!param.ContainsKey("url"))
  18087. {
  18088. jw.Msg = "url null";
  18089. return Ok(jw);
  18090. }
  18091. string url = param["url"]!.ToString();
  18092. var methon = "get";
  18093. Dictionary<string, string> headValues = null;
  18094. string bodyStr = string.Empty;
  18095. if (param.ContainsKey("methon"))
  18096. {
  18097. methon = param["methon"]!.ToString().ToLower();
  18098. }
  18099. if (param.ContainsKey("header"))
  18100. {
  18101. var header = param["header"]!.ToString();
  18102. JObject headerJobject = JObject.Parse(header);
  18103. headValues = new Dictionary<string, string>();
  18104. foreach (JProperty item in headerJobject.Properties())
  18105. {
  18106. var value = item.Value.ToString();
  18107. var head = item.Path;
  18108. headValues.Add(head, value);
  18109. }
  18110. }
  18111. HttpClient client = new HttpClient();
  18112. string responseString = string.Empty;
  18113. StringContent content = null;
  18114. if (headValues != null)
  18115. {
  18116. foreach (var item in headValues.Keys)
  18117. {
  18118. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18119. {
  18120. if (param.ContainsKey("body"))
  18121. {
  18122. bodyStr = param["body"]!.ToString();
  18123. }
  18124. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18125. }
  18126. else
  18127. {
  18128. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18129. }
  18130. }
  18131. }
  18132. try
  18133. {
  18134. if (methon == "get")
  18135. {
  18136. responseString = await client.GetStringAsync(url);
  18137. }
  18138. else if (methon == "post")
  18139. {
  18140. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18141. {
  18142. Content = content
  18143. };
  18144. var response = await client.SendAsync(request);
  18145. try
  18146. {
  18147. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18148. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18149. {
  18150. using (StreamReader reader = new StreamReader(gzipStream))
  18151. {
  18152. responseString = await reader.ReadToEndAsync();
  18153. }
  18154. }
  18155. }
  18156. catch (Exception)
  18157. {
  18158. responseString = await response.Content.ReadAsStringAsync();
  18159. }
  18160. }
  18161. else
  18162. {
  18163. responseString = "methon error";
  18164. }
  18165. jw = JsonView(true, "success", responseString);
  18166. }
  18167. catch (Exception ex)
  18168. {
  18169. jw.Msg = "error " + ex.Message;
  18170. jw.Data = ex.StackTrace;
  18171. }
  18172. finally
  18173. {
  18174. client.Dispose();
  18175. }
  18176. return Ok(jw);
  18177. }
  18178. #endregion
  18179. #region 团组接待意见调查
  18180. /// <summary>
  18181. /// 团组接待意见调查 - 信息管理
  18182. /// 基础数据(团组)
  18183. /// </summary>
  18184. /// <param name="dto"></param>
  18185. /// <returns></returns>
  18186. [HttpGet]
  18187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18188. public async Task<IActionResult> OpinionaireInit()
  18189. {
  18190. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18191. .Select(x => new
  18192. {
  18193. x.Id,
  18194. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18195. })
  18196. .OrderByDescending(x => x.Id)
  18197. .ToListAsync();
  18198. return Ok(JsonView(groupData, groupData.Count));
  18199. }
  18200. /// <summary>
  18201. /// 团组接待意见调查 - 信息管理
  18202. /// 列表
  18203. /// </summary>
  18204. /// <param name="groupId"></param>
  18205. /// <returns></returns>
  18206. [HttpGet("{groupId}")]
  18207. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18208. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18209. {
  18210. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18211. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18212. .Select(x => new
  18213. {
  18214. x.Id,
  18215. x.TourGuideName,
  18216. x.CityName,
  18217. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18218. x.CreateTime
  18219. })
  18220. .OrderBy(x => x.Id)
  18221. .ToListAsync();
  18222. return Ok(JsonView(data));
  18223. }
  18224. /// <summary>
  18225. /// 团组接待意见调查 - 信息管理
  18226. /// 保存
  18227. /// </summary>
  18228. /// <param name="dto"></param>
  18229. /// <returns></returns>
  18230. [HttpPost]
  18231. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18232. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18233. {
  18234. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18235. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18236. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18237. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18238. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18239. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18240. _opinionaireRep.BeginTran();
  18241. if (addData != null && addData.Count > 0)
  18242. {
  18243. foreach (var item in addData)
  18244. {
  18245. item.CreateUserId = currUserInfo.UserId;
  18246. item.DiId = dto.DiId;
  18247. }
  18248. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18249. }
  18250. if (updData != null && updData.Count > 0)
  18251. {
  18252. var upd = await _opinionaireRep._sqlSugar
  18253. .Updateable(updData)
  18254. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18255. .WhereColumns(x => new { x.Id })
  18256. .ExecuteCommandAsync();
  18257. }
  18258. _opinionaireRep.CommitTran();
  18259. return Ok(JsonView("操作成功!"));
  18260. }
  18261. /// <summary>
  18262. /// 团组接待意见调查 - 信息管理
  18263. /// 删除
  18264. /// </summary>
  18265. /// <param name="id"></param>
  18266. /// <returns></returns>
  18267. [HttpDelete("{id}")]
  18268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18269. public async Task<IActionResult> OpinionaireManageDel(int id)
  18270. {
  18271. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18272. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18273. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18274. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18275. if (!del) return Ok(JsonView("操作失败!"));
  18276. return Ok(JsonView("操作成功!"));
  18277. }
  18278. /// <summary>
  18279. /// 团组接待意见调查 - 用户
  18280. /// 列表
  18281. /// </summary>
  18282. /// <param name="id"></param>
  18283. /// <returns></returns>
  18284. [HttpGet("{diId}")]
  18285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18286. public async Task<IActionResult> OpinionaireUserList(int diId)
  18287. {
  18288. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18289. var sql = string.Format(@"
  18290. SELECT
  18291. o.Id,
  18292. o.DiId,
  18293. di.TeamName AS 'GroupName',
  18294. di.VisitPNumber AS 'PeopleNumber',
  18295. di.ClientName AS 'LeadGroup',
  18296. di.VisitCountry AS 'Travel',
  18297. di.VisitDays AS 'Days',
  18298. o.CityName,
  18299. o.TourGuideName,
  18300. o.Catering,
  18301. o.CateringReason,
  18302. o.Stay,
  18303. o.StayReason,
  18304. o.[Route],
  18305. o.RouteReason,
  18306. o.OfficialActivity,
  18307. o.OfficialActivityReason,
  18308. o.TourGuide,
  18309. o.TourGuideReason,
  18310. o.[Translate],
  18311. o.TranslateReason,
  18312. o.Trip,
  18313. o.TripReason,
  18314. o.ESFileName,
  18315. o.SignatureDate,
  18316. o.Remark
  18317. FROM
  18318. Grp_Opinionaire o
  18319. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18320. WHERE
  18321. o.IsDel = 0
  18322. AND o.DiId = {0}
  18323. ORDER BY
  18324. o.Id ASC", diId);
  18325. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18326. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18327. return Ok(JsonView(data));
  18328. }
  18329. /// <summary>
  18330. /// 团组接待意见调查 - 用户
  18331. /// 保存
  18332. /// </summary>
  18333. /// <param name="id"></param>
  18334. /// <returns></returns>
  18335. [HttpPost]
  18336. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18337. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18338. {
  18339. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18340. foreach (var item in dto)
  18341. {
  18342. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18343. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18344. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18345. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18346. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18347. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18348. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18349. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18350. }
  18351. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18352. if (!Directory.Exists(filePathBase))
  18353. {
  18354. Directory.CreateDirectory(filePathBase);
  18355. }
  18356. #region 上传文件
  18357. var filePaths = new List<string>();
  18358. foreach (var item in dto)
  18359. {
  18360. var file = item.File;
  18361. // 将文件保存到指定位置
  18362. var filePath = Path.Combine(filePathBase, file.FileName);
  18363. using (var stream = new FileStream(filePath, FileMode.Create))
  18364. {
  18365. await file.CopyToAsync(stream);
  18366. }
  18367. //验证文件是否上传成功
  18368. if (!System.IO.File.Exists(filePath))
  18369. {
  18370. foreach (var filePathStr in filePaths)
  18371. {
  18372. System.IO.File.Delete(filePathStr);
  18373. }
  18374. return Ok(JsonView(false, "文件上传失败!"));
  18375. }
  18376. item.ESFileName = file.FileName;
  18377. }
  18378. #endregion
  18379. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18380. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18381. .UpdateColumns(x => new
  18382. {
  18383. x.Catering,
  18384. x.CateringReason,
  18385. x.Stay,
  18386. x.StayReason,
  18387. x.Route,
  18388. x.RouteReason,
  18389. x.OfficialActivity,
  18390. x.OfficialActivityReason,
  18391. x.TourGuide,
  18392. x.TourGuideReason,
  18393. x.Translate,
  18394. x.TranslateReason,
  18395. x.Trip,
  18396. x.TripReason,
  18397. x.ESFileName,
  18398. x.SignatureDate,
  18399. x.Remark
  18400. })
  18401. .WhereColumns(x => new { x.Id })
  18402. .ExecuteCommandAsync();
  18403. if (upd < 1)
  18404. {
  18405. foreach (var filePathStr in filePaths)
  18406. {
  18407. System.IO.File.Delete(filePathStr);
  18408. }
  18409. return Ok(JsonView(false));
  18410. }
  18411. return Ok(JsonView(true));
  18412. }
  18413. #endregion
  18414. #region 团组餐厅相关信息
  18415. /// <summary>
  18416. /// 团组相关餐厅信息
  18417. /// 基础数据(团组)
  18418. /// </summary>
  18419. /// <returns></returns>
  18420. [HttpGet]
  18421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18422. public async Task<IActionResult> RestaurantInit()
  18423. {
  18424. return Ok(await _restaurantRep.InitAsync());
  18425. }
  18426. /// <summary>
  18427. /// 团组相关餐厅信息
  18428. /// Item
  18429. /// </summary>
  18430. /// <param name="dto"></param>
  18431. /// <returns></returns>
  18432. [HttpPost]
  18433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18434. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18435. {
  18436. int portType = dto.PortType,
  18437. groupId = dto.GroupId;
  18438. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
  18439. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18440. return Ok(await _restaurantRep.ItemAsync(portType,groupId));
  18441. }
  18442. /// <summary>
  18443. /// 团组相关餐厅信息
  18444. /// List
  18445. /// </summary>
  18446. /// <param name="dto"></param>
  18447. /// <returns></returns>
  18448. [HttpPost]
  18449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18450. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18451. {
  18452. int portType = dto.PortType,
  18453. groupId = dto.GroupId;
  18454. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18455. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18456. var sql = string.Format(@" SELECT
  18457. ri.Id,
  18458. ri.GroupId,
  18459. ri.Date,
  18460. ri.StartTime,
  18461. ri.EndTime,
  18462. CASE WHEN ri.Type = 1 THEN '早餐'
  18463. WHEN ri.Type = 2 THEN '午餐'
  18464. WHEN ri.Type = 3 THEN '晚餐'
  18465. ELSE '其他'
  18466. END AS 'Type',
  18467. ri.Name,
  18468. ri.Address,
  18469. ri.Tel,
  18470. ri.Remark,
  18471. ri.CreateTime,
  18472. u.CnName AS CreateUserName
  18473. FROM
  18474. Grp_RestaurantInfo ri
  18475. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18476. WHERE
  18477. ri.IsDel = 0
  18478. AND ri.GroupId = {0}
  18479. ORDER BY
  18480. ri.Date ASC
  18481. ", groupId);
  18482. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18483. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18484. return Ok(JsonView(infos));
  18485. }
  18486. /// <summary>
  18487. /// 团组相关餐厅信息
  18488. /// Info
  18489. /// </summary>
  18490. /// <param name="dto"></param>
  18491. /// <returns></returns>
  18492. [HttpPost]
  18493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18494. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18495. {
  18496. int portType = dto.PortType,
  18497. id = dto.Id;
  18498. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18499. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18500. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18501. }
  18502. /// <summary>
  18503. /// 团组相关餐厅信息
  18504. /// Op
  18505. /// </summary>
  18506. /// <param name="dto"></param>
  18507. /// <returns></returns>
  18508. [HttpPost]
  18509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18510. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18511. {
  18512. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18513. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18514. if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18515. return Ok(await _restaurantRep.OpAsync(dto));
  18516. }
  18517. /// <summary>
  18518. /// 团组相关餐厅信息
  18519. /// Del
  18520. /// </summary>
  18521. /// <param name="dto"></param>
  18522. /// <returns></returns>
  18523. [HttpPost]
  18524. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18525. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18526. {
  18527. int userId = dto.DeleteUserId;
  18528. var id = dto.Id;
  18529. if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
  18530. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18531. return Ok(await _restaurantRep.DelAsync(dto));
  18532. }
  18533. #endregion
  18534. // /// <summary>
  18535. // ///
  18536. // /// </summary>
  18537. // /// <param name="_dto"></param>
  18538. // /// <returns></returns>
  18539. // [HttpPost]
  18540. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18541. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18542. // {
  18543. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18544. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18545. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18546. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18547. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18548. // dic_psg.Add("客人", 974);
  18549. // dic_psg.Add("司机", 975);
  18550. // dic_psg.Add("导游", 976);
  18551. // dic_psg.Add("公司内部人员", 977);
  18552. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18553. // foreach (var item in list_visa)
  18554. // {
  18555. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18556. // temp.Id = item.Id;
  18557. // temp.DIId = item.DIId;
  18558. // temp.VisaClient = item.VisaClient;
  18559. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18560. // temp.VisaCurrency = item.VisaCurrency;
  18561. // temp.IsThird = item.IsThird;
  18562. // if (dic_psg.ContainsKey(item.PassengerType))
  18563. // {
  18564. // temp.PassengerType = dic_psg[item.PassengerType];
  18565. // }
  18566. // else {
  18567. // temp.PassengerType = -1;
  18568. // }
  18569. // temp.VisaNumber = item.VisaNumber;
  18570. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18571. // temp.CreateUserId = item.Operators;
  18572. // DateTime dt_ct;
  18573. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18574. // if (b_ct)
  18575. // {
  18576. // temp.CreateTime = dt_ct;
  18577. // }
  18578. // else
  18579. // {
  18580. // temp.CreateTime = DateTime.Now;
  18581. // }
  18582. // temp.DeleteTime = "";
  18583. // temp.DeleteUserId = 0;
  18584. // temp.Remark = item.Remark;
  18585. // if (string.IsNullOrEmpty(temp.Remark)) {
  18586. // temp.Remark = "";
  18587. // }
  18588. // temp.IsDel = item.IsDel;
  18589. // temp.VisaDescription = item.VisaAttachment;
  18590. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18591. //([Id]
  18592. // ,[DIId]
  18593. // ,[VisaClient]
  18594. // ,[VisaPrice]
  18595. // ,[VisaCurrency]
  18596. // ,[IsThird]
  18597. // ,[PassengerType]
  18598. // ,[VisaNumber]
  18599. // ,[VisaFreeNumber]
  18600. // ,[CreateUserId]
  18601. // ,[CreateTime]
  18602. // ,[DeleteTime]
  18603. // ,[DeleteUserId]
  18604. // ,[Remark]
  18605. // ,[IsDel]
  18606. // ,[visaDescription])
  18607. // VALUES
  18608. // ({0},{1},'{2}',{3},{4}
  18609. //,{5},{6},{7},{8},{9}
  18610. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18611. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18612. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18613. //);
  18614. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18615. // }
  18616. // return Ok(JsonView(true, "操作成功!"));
  18617. // }
  18618. /// <summary>
  18619. /// 123132123
  18620. /// </summary>
  18621. /// <param name="_dto"></param>
  18622. /// <returns></returns>
  18623. [HttpPost]
  18624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18625. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18626. {
  18627. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18628. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18629. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18630. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18631. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18632. dicDetail.Add(789, 1034);
  18633. dicDetail.Add(790, 1035);
  18634. dicDetail.Add(791, 1036);
  18635. dicDetail.Add(792, 1037);
  18636. dicDetail.Add(793, 1038);
  18637. dicDetail.Add(794, 1039);
  18638. dicDetail.Add(795, 1040);
  18639. dicDetail.Add(796, 1041);
  18640. dicDetail.Add(797, 1042);
  18641. dicDetail.Add(798, 1043);
  18642. dicDetail.Add(801, 1044);
  18643. dicDetail.Add(802, 1045);
  18644. dicDetail.Add(803, 1046);
  18645. Dictionary<int, int> dic = new Dictionary<int, int>();
  18646. dic.Add(806, 1027);
  18647. dic.Add(807, 1028);
  18648. dic.Add(808, 1029);
  18649. dic.Add(809, 1030);
  18650. dic.Add(810, 1031);
  18651. dic.Add(811, 1032);
  18652. dic.Add(812, 1033);
  18653. foreach (var item in list_visa)
  18654. {
  18655. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18656. temp.Coefficient = item.coefficient;
  18657. DateTime dtCrt;
  18658. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18659. if (b1)
  18660. {
  18661. temp.CreateTime = dtCrt;
  18662. }
  18663. else
  18664. {
  18665. temp.CreateTime = DateTime.Now;
  18666. }
  18667. temp.CreateUserId = item.Operators;
  18668. temp.DeleteTime = "";
  18669. temp.DeleteUserId = 0;
  18670. temp.DiId = int.Parse(item.DIID);
  18671. temp.FilePath = item.FilePath;
  18672. temp.IsDel = item.IsDel;
  18673. temp.Price = item.Price;
  18674. temp.PriceCount = 1;
  18675. temp.PriceCurrency = item.Currency;
  18676. int detailId = 0;
  18677. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18678. {
  18679. detailId = dicDetail[item.PriceTypeDetail];
  18680. }
  18681. temp.PriceDetailType = detailId;
  18682. temp.PriceDt = DateTime.Now;
  18683. temp.PriceName = item.PriceName;
  18684. temp.PriceSum = item.Price;
  18685. int tid = 0;
  18686. if (dic.ContainsKey(item.PriceType))
  18687. {
  18688. tid = dic[item.PriceType];
  18689. }
  18690. temp.PriceType = tid;
  18691. temp.Remark = item.Remark;
  18692. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18693. }
  18694. return Ok(JsonView(true, "操作成功!"));
  18695. }
  18696. [HttpPost]
  18697. public IActionResult TimeTest()
  18698. {
  18699. var jw = JsonView(false, "error");
  18700. _sqlSugar.BeginTran();
  18701. try
  18702. {
  18703. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18704. .Select(x => new Crm_NewClientData
  18705. {
  18706. Id = x.Id,
  18707. Client = x.Client,
  18708. Contact = x.Contact,
  18709. Location = x.Location,
  18710. })
  18711. .ToList();
  18712. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  18713. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18714. Stopwatch stopwatch = new Stopwatch();
  18715. // 开始计时
  18716. stopwatch.Start();
  18717. foreach (var item in clientList)
  18718. {
  18719. EncryptionProcessor.DecryptProperties(item);
  18720. }
  18721. stopwatch.Stop();
  18722. jw.Code = 200;
  18723. jw.Data = stopwatch.ElapsedMilliseconds;
  18724. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  18725. }
  18726. catch (Exception ex)
  18727. {
  18728. jw.Code = 400;
  18729. jw.Msg = ex.Message;
  18730. }
  18731. return Ok(jw);
  18732. }
  18733. }
  18734. }