GroupsController.cs 1002 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630
  1. using Aspose.Cells;
  2. using Aspose.Words;
  3. using Aspose.Words.Drawing;
  4. using Aspose.Words.Tables;
  5. using DiffMatchPatch;
  6. using Microsoft.AspNetCore.SignalR;
  7. using Microsoft.EntityFrameworkCore.Query.Internal;
  8. using NPOI.HSSF.UserModel;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.UserModel;
  11. using NPOI.SS.Util;
  12. using NPOI.XSSF.UserModel;
  13. using OASystem.API.Middlewares;
  14. using OASystem.API.OAMethodLib;
  15. using OASystem.API.OAMethodLib.APNs;
  16. using OASystem.API.OAMethodLib.File;
  17. using OASystem.API.OAMethodLib.Hub.HubClients;
  18. using OASystem.API.OAMethodLib.Hub.Hubs;
  19. using OASystem.API.OAMethodLib.JuHeAPI;
  20. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  21. using OASystem.Domain.AesEncryption;
  22. using OASystem.Domain.Dtos.CRM;
  23. using OASystem.Domain.Dtos.FileDto;
  24. using OASystem.Domain.Dtos.Financial;
  25. using OASystem.Domain.Dtos.Groups;
  26. using OASystem.Domain.Entities.Customer;
  27. using OASystem.Domain.Entities.Financial;
  28. using OASystem.Domain.Entities.Groups;
  29. using OASystem.Domain.ViewModels.Financial;
  30. using OASystem.Domain.ViewModels.Groups;
  31. using OASystem.Infrastructure.Repositories.CRM;
  32. using OASystem.Infrastructure.Repositories.Financial;
  33. using OASystem.Infrastructure.Repositories.Groups;
  34. using OfficeOpenXml;
  35. using Org.BouncyCastle.Asn1.Ocsp;
  36. using Org.BouncyCastle.Utilities.Encoders;
  37. using Quartz.Util;
  38. using SqlSugar.Extensions;
  39. using System.Collections;
  40. using System.Data;
  41. using System.Diagnostics;
  42. using System.Globalization;
  43. using System.IO.Compression;
  44. using static OASystem.API.OAMethodLib.JWTHelper;
  45. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  46. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  47. using Bookmark = Aspose.Words.Bookmark;
  48. using Cell = Aspose.Words.Tables.Cell;
  49. using Table = Aspose.Words.Tables.Table;
  50. namespace OASystem.API.Controllers
  51. {
  52. /// <summary>
  53. /// 团组相关
  54. /// </summary>
  55. //[Authorize]
  56. [Route("api/[controller]/[action]")]
  57. public class GroupsController : ControllerBase
  58. {
  59. private readonly ILogger<GroupsController> _logger;
  60. private readonly GrpScheduleRepository _grpScheduleRep;
  61. private readonly IMapper _mapper;
  62. private readonly DelegationInfoRepository _groupRepository;
  63. private readonly TaskAssignmentRepository _taskAssignmentRep;
  64. private readonly AirTicketResRepository _airTicketResRep;
  65. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  66. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  67. private readonly DelegationEnDataRepository _delegationEnDataRep;
  68. private readonly DelegationVisaRepository _delegationVisaRep;
  69. private readonly VisaPriceRepository _visaPriceRep;
  70. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  71. private readonly HotelPriceRepository _hotelPriceRep;
  72. private readonly CustomersRepository _customersRep;
  73. private readonly MessageRepository _message;
  74. private readonly SqlSugarClient _sqlSugar;
  75. private readonly TourClientListRepository _tourClientListRep;
  76. private readonly TeamRateRepository _teamRateRep;
  77. #region 成本相关
  78. private readonly CheckBoxsRepository _checkBoxs;
  79. private readonly GroupCostRepository _GroupCostRepository;
  80. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  81. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  82. #endregion
  83. private readonly SetDataRepository _setDataRep;
  84. private string url;
  85. private string path;
  86. private readonly EnterExitCostRepository _enterExitCostRep;
  87. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  88. private readonly UsersRepository _usersRep;
  89. private readonly IJuHeApiService _juHeApi;
  90. private readonly InvertedListRepository _invertedListRep;
  91. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  92. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  93. private readonly ThreeCodeRepository _threeCodeRepository;
  94. private readonly HotelInquiryRepository _hotelInquiryRep;
  95. private readonly FeeAuditRepository _feeAuditRep;
  96. private readonly VisaCommissionRepository _visaCommissionRep;
  97. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  98. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  99. private readonly List<CurrencyInfo> _currencyInit;
  100. private readonly List<int> _portTypeData;
  101. private readonly TableOperationRecordRepository _tableorRep;
  102. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  103. private readonly RestaurantRepository _restaurantRep;
  104. /// <summary>
  105. /// 构造函数
  106. /// </summary>
  107. /// <param name="logger"></param>
  108. /// <param name="mapper"></param>
  109. /// <param name="hubContext"></param>
  110. /// <param name="sqlSugar"></param>
  111. /// <param name="grpScheduleRep"></param>
  112. /// <param name="groupRepository"></param>
  113. /// <param name="taskAssignmentRep"></param>
  114. /// <param name="airTicketResRep"></param>
  115. /// <param name="decreasePaymentsRep"></param>
  116. /// <param name="InvitationOfficialActivitiesRep"></param>
  117. /// <param name="delegationEnDataRep"></param>
  118. /// <param name="enterExitCostRep"></param>
  119. /// <param name="delegationVisaRep"></param>
  120. /// <param name="message"></param>
  121. /// <param name="visaPriceRep"></param>
  122. /// <param name="carTouristGuideGroundRep"></param>
  123. /// <param name="checkBoxs"></param>
  124. /// <param name="GroupCostRepository"></param>
  125. /// <param name="CostTypeHotelNumberRepository"></param>
  126. /// <param name="GroupCostParameterRepository"></param>
  127. /// <param name="hotelPriceRep"></param>
  128. /// <param name="customersRep"></param>
  129. /// <param name="setDataRep"></param>
  130. /// <param name="tourClientListRep"></param>
  131. /// <param name="teamRateRep"></param>
  132. /// <param name="usersRep"></param>
  133. /// <param name="juHeApi"></param>
  134. /// <param name="invertedListRep"></param>
  135. /// <param name="visaFeeInfoRep"></param>
  136. /// <param name="ticketBlackCodeRep"></param>
  137. /// <param name="hotelInquiryRep"></param>
  138. /// <param name="threeCodeRepository"></param>
  139. /// <param name="feeAuditRep"></param>
  140. /// <param name="visaCommissionRep"></param>
  141. /// <param name="ffrRep"></param>
  142. /// <param name="opinionaireRep"></param>
  143. /// <param name="tableorRep"></param>
  144. /// <param name="enterExitCostDraftRep"></param>
  145. /// <param name="restaurantRep"></param>
  146. public GroupsController(
  147. ILogger<GroupsController> logger,
  148. IMapper mapper,
  149. IHubContext<ChatHub, IChatClient> hubContext,
  150. SqlSugarClient sqlSugar,
  151. GrpScheduleRepository grpScheduleRep,
  152. DelegationInfoRepository groupRepository,
  153. TaskAssignmentRepository taskAssignmentRep,
  154. AirTicketResRepository airTicketResRep,
  155. DecreasePaymentsRepository decreasePaymentsRep,
  156. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  157. DelegationEnDataRepository delegationEnDataRep,
  158. EnterExitCostRepository enterExitCostRep,
  159. DelegationVisaRepository delegationVisaRep,
  160. MessageRepository message,
  161. VisaPriceRepository visaPriceRep,
  162. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  163. CheckBoxsRepository checkBoxs,
  164. GroupCostRepository GroupCostRepository,
  165. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  166. GroupCostParameterRepository GroupCostParameterRepository,
  167. HotelPriceRepository hotelPriceRep,
  168. CustomersRepository customersRep,
  169. SetDataRepository setDataRep,
  170. TourClientListRepository tourClientListRep,
  171. TeamRateRepository teamRateRep,
  172. UsersRepository usersRep, IJuHeApiService juHeApi,
  173. InvertedListRepository invertedListRep,
  174. VisaFeeInfoRepository visaFeeInfoRep,
  175. TicketBlackCodeRepository ticketBlackCodeRep,
  176. HotelInquiryRepository hotelInquiryRep,
  177. ThreeCodeRepository threeCodeRepository,
  178. FeeAuditRepository feeAuditRep,
  179. VisaCommissionRepository visaCommissionRep,
  180. ForeignReceivablesRepository ffrRep,
  181. OpinionaireRepository opinionaireRep,
  182. TableOperationRecordRepository tableorRep,
  183. EnterExitCostDraftRepository enterExitCostDraftRep,
  184. RestaurantRepository restaurantRep
  185. )
  186. {
  187. _logger = logger;
  188. _mapper = mapper;
  189. _grpScheduleRep = grpScheduleRep;
  190. _groupRepository = groupRepository;
  191. _taskAssignmentRep = taskAssignmentRep;
  192. _airTicketResRep = airTicketResRep;
  193. _sqlSugar = sqlSugar;
  194. url = AppSettingsHelper.Get("ExcelBaseUrl");
  195. path = AppSettingsHelper.Get("ExcelBasePath");
  196. if (!System.IO.Directory.Exists(path))
  197. {
  198. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  199. }
  200. _decreasePaymentsRep = decreasePaymentsRep;
  201. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  202. _delegationEnDataRep = delegationEnDataRep;
  203. _enterExitCostRep = enterExitCostRep;
  204. _delegationVisaRep = delegationVisaRep;
  205. _message = message;
  206. _visaPriceRep = visaPriceRep;
  207. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  208. _checkBoxs = checkBoxs;
  209. _GroupCostRepository = GroupCostRepository;
  210. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  211. _GroupCostParameterRepository = GroupCostParameterRepository;
  212. _hotelPriceRep = hotelPriceRep;
  213. _customersRep = customersRep;
  214. _setDataRep = setDataRep;
  215. _tourClientListRep = tourClientListRep;
  216. _teamRateRep = teamRateRep;
  217. _hubContext = hubContext;
  218. _usersRep = usersRep;
  219. _juHeApi = juHeApi;
  220. _invertedListRep = invertedListRep;
  221. _visaFeeInfoRep = visaFeeInfoRep;
  222. _ticketBlackCodeRep = ticketBlackCodeRep;
  223. _hotelInquiryRep = hotelInquiryRep;
  224. _threeCodeRepository = threeCodeRepository;
  225. _feeAuditRep = feeAuditRep;
  226. _visaCommissionRep = visaCommissionRep;
  227. _ffrRep = ffrRep;
  228. _opinionaireRep = opinionaireRep;
  229. _currencyInit = new List<CurrencyInfo>()
  230. {
  231. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  232. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  233. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  234. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  235. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  236. };
  237. _portTypeData = new List<int>() { 2, 3 };
  238. _tableorRep = tableorRep;
  239. _enterExitCostDraftRep = enterExitCostDraftRep;
  240. _restaurantRep = restaurantRep;
  241. }
  242. #region 流程管控
  243. /// <summary>
  244. /// 获取团组流程管控信息
  245. /// </summary>
  246. /// <param name="paras">参数Json字符串</param>
  247. /// <returns></returns>
  248. [HttpPost]
  249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  250. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  251. {
  252. if (string.IsNullOrEmpty(_jsonDto.Paras))
  253. {
  254. return Ok(JsonView(false, "参数为空"));
  255. }
  256. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  257. if (_ScheduleDto != null)
  258. {
  259. if (_ScheduleDto.SearchType == 2)//获取列表
  260. {
  261. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  262. return Ok(JsonView(_grpScheduleViewList));
  263. }
  264. else//获取对象
  265. {
  266. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  267. if (_grpScheduleView != null)
  268. {
  269. return Ok(JsonView(_grpScheduleView));
  270. }
  271. }
  272. }
  273. else
  274. {
  275. return Ok(JsonView(false, "参数反序列化失败"));
  276. }
  277. return Ok(JsonView(false, "暂无数据!"));
  278. }
  279. /// <summary>
  280. /// 修改团组流程管控详细表数据
  281. /// </summary>
  282. /// <param name="paras"></param>
  283. /// <returns></returns>
  284. [HttpPost]
  285. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  286. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  287. {
  288. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  289. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  290. .SetColumns(it => it.Duty == _detail.Duty)
  291. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  292. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  293. .SetColumns(it => it.JobContent == _detail.JobContent)
  294. .SetColumns(it => it.Remark == _detail.Remark)
  295. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  296. .Where(s => s.Id == dto.Id)
  297. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  298. .ExecuteCommandAsync();
  299. if (result > 0)
  300. {
  301. return Ok(JsonView(true, "保存成功!"));
  302. }
  303. return Ok(JsonView(false, "保存失败!"));
  304. }
  305. /// <summary>
  306. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  307. /// </summary>
  308. /// <param name="dto"></param>
  309. /// <returns></returns>
  310. [HttpPost]
  311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  312. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  313. {
  314. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  315. _detail.IsDel = 1;
  316. _detail.DeleteUserId = dto.Duty;
  317. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  318. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  319. .SetColumns(it => it.IsDel == _detail.IsDel)
  320. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  321. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  322. .Where(it => it.Id == dto.Id)
  323. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  324. //.WhereColumns(s => s.Id == dto.Id)
  325. .ExecuteCommandAsync();
  326. if (result > 0)
  327. {
  328. return Ok(JsonView(true, "删除成功!"));
  329. }
  330. return Ok(JsonView(false, "删除失败!"));
  331. }
  332. /// <summary>
  333. /// 增加团组流程管控详细表数据
  334. /// </summary>
  335. /// <param name="dto"></param>
  336. /// <returns></returns>
  337. [HttpPost]
  338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  339. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  340. {
  341. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  342. if (DateTime.Now < _detail.ExpectBeginDt)
  343. {
  344. _detail.StepStatus = 0;
  345. }
  346. else
  347. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  348. _detail.StepStatus = 1;
  349. }
  350. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  351. if (result > 0)
  352. {
  353. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  354. return Ok(JsonView(true, "添加成功!", _result));
  355. }
  356. return Ok(JsonView(false, "添加失败!"));
  357. }
  358. #endregion
  359. #region 团组基本信息
  360. /// <summary>
  361. /// 接团信息列表
  362. /// </summary>
  363. /// <param name="dto">团组列表请求dto</param>
  364. /// <returns></returns>
  365. [HttpPost]
  366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  367. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  368. {
  369. var groupData = await _groupRepository.GetGroupList(dto);
  370. if (groupData.Code != 0)
  371. {
  372. return Ok(JsonView(false, groupData.Msg));
  373. }
  374. return Ok(JsonView(groupData.Data));
  375. }
  376. /// <summary>
  377. /// 分页查询团组列表
  378. /// </summary>
  379. /// <param name="dto"></param>
  380. /// <returns></returns>
  381. [HttpPost]
  382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  383. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  384. {
  385. var watch = new Stopwatch();
  386. watch.Start();
  387. RefAsync<int> total = 0;
  388. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  389. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  390. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  391. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  392. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  393. .Distinct()
  394. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  395. watch.Stop();
  396. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  397. }
  398. /// <summary>
  399. /// 接团信息列表 Page Init
  400. /// </summary>
  401. /// <returns></returns>
  402. [HttpPost]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> PostGroupPageListInit()
  405. {
  406. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  407. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  408. rankDatas.Insert(0, new { Id=0, Name ="全部" });
  409. var _view = new
  410. {
  411. depData = depDatas,
  412. rankData = rankDatas
  413. };
  414. return Ok(JsonView(true, "查询成功!", _view));
  415. }
  416. /// <summary>
  417. /// 接团信息列表 Page
  418. /// </summary>
  419. /// <param name="dto">团组列表请求dto</param>
  420. /// <returns></returns>
  421. [HttpPost]
  422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  423. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  424. {
  425. #region 参数验证
  426. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  427. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  428. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  429. #region 页面操作权限验证
  430. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  431. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  432. #endregion
  433. #endregion
  434. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  435. {
  436. string sqlWhere = string.Empty;
  437. if (dto.IsSure == 0) //未完成
  438. {
  439. sqlWhere += string.Format(@" And IsSure = 0");
  440. }
  441. else if (dto.IsSure == 1) //已完成
  442. {
  443. sqlWhere += string.Format(@" And IsSure = 1");
  444. }
  445. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  446. {
  447. string tj = dto.SearchCriteria;
  448. 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}%')",
  449. tj, tj, tj, tj, tj);
  450. }
  451. if (dto.Rank > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", dto.Rank);
  452. string sqlWhere1 = string.Empty;
  453. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  454. {
  455. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  456. }
  457. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  458. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  459. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  460. JietuanOperator,IsSure,CreateTime,IsBid
  461. From (
  462. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  463. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '管理员'
  464. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  465. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  466. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  467. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  468. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  469. From Grp_DelegationInfo gdi
  470. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  471. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  472. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  473. Where gdi.IsDel = 0 {0}
  474. ) temp{1}", sqlWhere, sqlWhere1);
  475. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  476. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  477. var _view = new
  478. {
  479. PageFuncAuth = pageFunAuthView,
  480. Data = _DelegationList
  481. };
  482. return Ok(JsonView(true, "查询成功!", _view, total));
  483. }
  484. else
  485. {
  486. return Ok(JsonView(false, "查询失败"));
  487. }
  488. }
  489. /// <summary>
  490. /// 团组列表
  491. /// </summary>
  492. /// <returns></returns>
  493. [HttpPost]
  494. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  495. {
  496. #region 参数验证
  497. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  498. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  499. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  500. #region 页面操作权限验证
  501. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  502. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  503. #endregion
  504. #endregion
  505. if (dto.PortType != 1 && dto.PortType != 2)
  506. {
  507. return Ok(JsonView(false, "查询失败!"));
  508. }
  509. string orderbyStr = "order by gdi.CreateTime Desc";
  510. string sqlWhere = string.Empty;
  511. if (dto.IsSure == 0) //未完成
  512. {
  513. sqlWhere += string.Format(@" And IsSure = 0");
  514. }
  515. else if (dto.IsSure == 1) //已完成
  516. {
  517. sqlWhere += string.Format(@" And IsSure = 1");
  518. }
  519. //团组类型
  520. if (dto.TeamDid > 0)
  521. {
  522. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  523. }
  524. //团组名称
  525. if (!string.IsNullOrEmpty(dto.TeamName))
  526. {
  527. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  528. }
  529. //客户名称
  530. if (!string.IsNullOrEmpty(dto.ClientName))
  531. {
  532. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  533. }
  534. //客户单位
  535. if (!string.IsNullOrEmpty(dto.ClientUnit))
  536. {
  537. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  538. }
  539. //出访时间
  540. if (!string.IsNullOrEmpty(dto.visitDataTime))
  541. {
  542. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  543. orderbyStr = "order by gdi.VisitDate";
  544. }
  545. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  546. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  547. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  548. JietuanOperator,IsSure,CreateTime
  549. From (
  550. Select row_number() over({0}) as Row_Number,
  551. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  552. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  553. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  554. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  555. From Grp_DelegationInfo gdi
  556. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  557. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  558. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  559. Where gdi.IsDel = 0 {1}
  560. ) temp ", orderbyStr, sqlWhere);
  561. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  562. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  563. #region 处理所属部门
  564. /*
  565. * 1.sq 和 gyy 等显示 市场部
  566. * 2.王鸽和主管及张总还有管理员号统一国交部
  567. * 2-1. 4 管理员 ,21 张海麟
  568. */
  569. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  570. List<int> userIds1 = new List<int>() { 4, 21 };
  571. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  572. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  573. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  574. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  575. .ToList();
  576. foreach (var item in _DelegationList)
  577. {
  578. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  579. }
  580. #endregion
  581. var _view = new
  582. {
  583. PageFuncAuth = pageFunAuthView,
  584. Data = _DelegationList
  585. };
  586. return Ok(JsonView(true, "查询成功!", _view, total));
  587. }
  588. /// <summary>
  589. /// 接团信息详情
  590. /// </summary>
  591. /// <param name="dto">团组info请求dto</param>
  592. /// <returns></returns>
  593. [HttpPost]
  594. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  595. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  596. {
  597. var groupData = await _groupRepository.GetGroupInfo(dto);
  598. if (groupData.Code != 0)
  599. {
  600. return Ok(JsonView(false, groupData.Msg));
  601. }
  602. return Ok(JsonView(groupData.Data));
  603. }
  604. /// <summary>
  605. /// 接团信息 编辑添加
  606. /// 基础信息数据源
  607. /// </summary>
  608. /// <param name="dto"></param>
  609. /// <returns></returns>
  610. [HttpPost]
  611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  612. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  613. {
  614. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  615. if (groupData.Code != 0)
  616. {
  617. return Ok(JsonView(false, groupData.Msg));
  618. }
  619. return Ok(JsonView(groupData.Data));
  620. }
  621. /// <summary>
  622. /// 接团信息 操作(增改)
  623. /// </summary>
  624. /// <param name="dto"></param>
  625. /// <returns></returns>
  626. [HttpPost]
  627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  628. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  629. {
  630. // 创建 Stopwatch 实例
  631. Stopwatch stopwatch = Stopwatch.StartNew();
  632. decimal ffrPrice = 0.00M;
  633. DateTime? visitDt = null;
  634. if (dto.Status == 2)
  635. {
  636. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  637. if (groupInfo != null)
  638. {
  639. ffrPrice = groupInfo.PaymentMoney;
  640. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  641. }
  642. }
  643. var groupData = await _groupRepository.GroupOperation(dto);
  644. if (groupData.Code != 0)
  645. {
  646. return Ok(JsonView(false, groupData.Msg));
  647. }
  648. int diId = 0;
  649. try
  650. {
  651. //添加时 默认加入团组汇率
  652. if (dto.Status == 1) //添加
  653. {
  654. diId = groupData.Data;
  655. //添加默认币种
  656. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  657. //默认分配权限
  658. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  659. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  660. var _managerIds = new List<int>() { 22, 32, 21 };
  661. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  662. if (userIds.Count > 0)
  663. {
  664. userIds.Add(208);
  665. //创建团组管控
  666. GroupStepForDelegation.CreateWorkStep(diId);
  667. //发送消息
  668. string groupName = dto.TeamName;
  669. string createGroupUser = string.Empty;
  670. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  671. if (userInfo != null) createGroupUser = userInfo.CnName;
  672. string title = $"系统通知";
  673. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  674. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  675. }
  676. //默认创建倒推表
  677. await _invertedListRep._Create(dto.UserId, diId);
  678. }
  679. else if (dto.Status == 2)
  680. {
  681. diId = dto.Id;
  682. }
  683. #region 签证人员团组时间通知
  684. #region 计算出访起止时间
  685. var startTime = new DateTime();
  686. var endTime = new DateTime();
  687. if (DateTime.TryParse(dto.VisitDate, out startTime))
  688. {
  689. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  690. }
  691. #endregion
  692. #endregion
  693. #region 团组操作默认添加/修改收款账单
  694. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  695. {
  696. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  697. .Where(x => x.IsDel == 0 &&
  698. x.Diid == diId &&
  699. x.Remark.Equals("预付款")
  700. )
  701. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  702. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  703. .FirstAsync();
  704. ffrInfo = new Fin_ForeignReceivables()
  705. {
  706. Diid = diId,
  707. PriceName = dto.ClientUnit,
  708. Price = dto.PaymentMoney,
  709. Count = 1,
  710. Unit = $"元",
  711. ItemSumPrice = dto.PaymentMoney,
  712. Rate = 1.0000M,
  713. Currency = 836,
  714. AddingWay = 0,
  715. CreateUserId = dto.UserId,
  716. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  717. Remark = $"预付款"
  718. };
  719. if (ffrInfo == null) //Add
  720. {
  721. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  722. }
  723. else //修改
  724. {
  725. await _sqlSugar.Updateable(ffrInfo)
  726. .UpdateColumns(x => new
  727. {
  728. x.PriceName,
  729. x.Price,
  730. x.ItemSumPrice,
  731. x.CreateTime,
  732. x.CreateUserId
  733. })
  734. .WhereColumns(x => x.Id)
  735. .ExecuteCommandAsync();
  736. }
  737. }
  738. #endregion
  739. if (diId > 0)
  740. {
  741. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  742. }
  743. // 停止计时
  744. stopwatch.Stop();
  745. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  746. }
  747. catch (Exception ex)
  748. {
  749. // 停止计时
  750. stopwatch.Stop();
  751. Logs("[response]" + JsonConvert.SerializeObject(dto));
  752. Logs(ex.Message);
  753. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  754. }
  755. // 停止计时
  756. stopwatch.Stop();
  757. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  758. }
  759. /// <summary>
  760. /// 接团流程操作(增改)
  761. /// 安卓端使用 建团时添加客户名单
  762. /// </summary>
  763. /// <param name="dto"></param>
  764. /// <returns></returns>
  765. [HttpPost]
  766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  767. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  768. {
  769. #region 参数验证
  770. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  771. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  772. #region 页面操作权限验证
  773. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  774. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  775. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  776. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  777. #endregion
  778. #endregion
  779. try
  780. {
  781. //_sqlSugar.BeginTran();
  782. decimal ffrPrice = 0.00M;
  783. DateTime? visitDt = null;
  784. if (dto.Status == 2)
  785. {
  786. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  787. if (groupInfo != null)
  788. {
  789. ffrPrice = groupInfo.PaymentMoney;
  790. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  791. }
  792. }
  793. var _dto = new GroupOperationDto();
  794. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  795. var groupData = await _groupRepository.GroupOperation(_dto);
  796. if (groupData.Code != 0)
  797. {
  798. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  799. }
  800. int diId = 0;
  801. //添加时 默认加入团组汇率
  802. if (dto.Status == 1) //添加
  803. {
  804. diId = groupData.Data;
  805. //添加默认币种
  806. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  807. //默认分配权限
  808. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  809. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  810. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  811. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  812. if (userIds.Count > 0)
  813. {
  814. userIds.Add(208);
  815. //创建团组管控
  816. GroupStepForDelegation.CreateWorkStep(diId);
  817. //发送消息
  818. string groupName = dto.TeamName;
  819. string createGroupUser = string.Empty;
  820. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  821. if (userInfo != null) createGroupUser = userInfo.CnName;
  822. string title = $"系统通知";
  823. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  824. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  825. }
  826. #region 应用推送
  827. try
  828. {
  829. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  830. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  831. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  832. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  833. {
  834. List<string> userList = new List<string>() { users.QiyeChatUserId };
  835. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  836. }
  837. }
  838. catch (Exception ex)
  839. {
  840. }
  841. #endregion
  842. //默认创建倒推表
  843. await _invertedListRep._Create(dto.UserId, diId);
  844. }
  845. if (dto.Status == 2)
  846. {
  847. diId = dto.Id;
  848. if (diId == 0)
  849. {
  850. //_sqlSugar.RollbackTran();
  851. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  852. }
  853. }
  854. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  855. if (viewData.Code != 0)
  856. {
  857. //_sqlSugar.RollbackTran();
  858. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  859. }
  860. #region 团组操作默认添加/修改收款账单
  861. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  862. {
  863. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  864. .Where(x => x.IsDel == 0 &&
  865. x.Diid == diId &&
  866. x.Remark.Equals("预付款")
  867. )
  868. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  869. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  870. .FirstAsync();
  871. ffrInfo = new Fin_ForeignReceivables()
  872. {
  873. Diid = diId,
  874. PriceName = dto.ClientUnit,
  875. Price = dto.PaymentMoney,
  876. Count = 1,
  877. Unit = $"元",
  878. ItemSumPrice = dto.PaymentMoney,
  879. Rate = 1.0000M,
  880. Currency = 836,
  881. AddingWay = 0,
  882. CreateUserId = dto.UserId,
  883. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  884. Remark = $"预付款"
  885. };
  886. if (ffrInfo == null) //Add
  887. {
  888. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  889. }
  890. else //修改
  891. {
  892. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  893. .UpdateColumns(x => new
  894. {
  895. x.PriceName,
  896. x.Price,
  897. x.ItemSumPrice,
  898. x.CreateTime,
  899. x.CreateUserId
  900. })
  901. .WhereColumns(x => x.Id)
  902. .ExecuteCommandAsync();
  903. }
  904. }
  905. #endregion
  906. #region 签证人员团组时间通知
  907. #region 计算出访起止时间
  908. var startTime = new DateTime();
  909. var endTime = new DateTime();
  910. if (DateTime.TryParse(dto.VisitDate, out startTime))
  911. {
  912. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  913. }
  914. #endregion
  915. if (diId > 0)
  916. {
  917. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  918. }
  919. #endregion
  920. //_sqlSugar.CommitTran();
  921. return Ok(JsonView(true, "添加成功"));
  922. }
  923. catch (Exception ex)
  924. {
  925. _sqlSugar.RollbackTran();
  926. return Ok(JsonView(false, ex.Message));
  927. }
  928. }
  929. /// <summary>
  930. /// 接团流程操作(增改)
  931. /// 安卓端使用 建团时添加客户名单
  932. /// </summary>
  933. /// <param name="dto"></param>
  934. /// <returns></returns>
  935. [HttpPost]
  936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  937. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  938. {
  939. #region 参数验证
  940. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  941. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  942. #region 页面操作权限验证
  943. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  944. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  946. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  947. #endregion
  948. #endregion
  949. _sqlSugar.BeginTran();
  950. decimal ffrPrice = 0.00M;
  951. DateTime? visitDt = null;
  952. if (dto.Status == 2)
  953. {
  954. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  955. if (groupInfo != null)
  956. {
  957. ffrPrice = groupInfo.PaymentMoney;
  958. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  959. }
  960. }
  961. var _dto = new GroupOperationDto();
  962. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  963. var groupData = await _groupRepository.GroupOperation(_dto);
  964. if (groupData.Code != 0)
  965. {
  966. _sqlSugar.RollbackTran();
  967. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  968. }
  969. try
  970. {
  971. int diId = 0;
  972. //添加时 默认加入团组汇率
  973. if (dto.Status == 1) //添加
  974. {
  975. diId = groupData.Data;
  976. //添加默认币种
  977. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  978. //默认分配权限
  979. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  980. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  981. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  982. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  983. if (userIds.Count > 0)
  984. {
  985. userIds.Add(208);
  986. //创建团组管控
  987. GroupStepForDelegation.CreateWorkStep(diId);
  988. //发送消息
  989. string groupName = dto.TeamName;
  990. string createGroupUser = string.Empty;
  991. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  992. if (userInfo != null) createGroupUser = userInfo.CnName;
  993. string title = $"系统通知";
  994. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  995. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  996. }
  997. #region 应用推送
  998. try
  999. {
  1000. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1001. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1002. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1003. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1004. {
  1005. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1006. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1007. }
  1008. }
  1009. catch (Exception ex)
  1010. {
  1011. _sqlSugar.CommitTran();
  1012. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1013. }
  1014. #endregion
  1015. //默认创建倒推表
  1016. await _invertedListRep._Create(dto.UserId, diId);
  1017. }
  1018. else if (dto.Status == 2)
  1019. {
  1020. diId = dto.Id;
  1021. if (diId == 0)
  1022. {
  1023. _sqlSugar.RollbackTran();
  1024. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1025. }
  1026. }
  1027. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1028. if (viewData.Code != 0)
  1029. {
  1030. _sqlSugar.RollbackTran();
  1031. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1032. }
  1033. #region 团组操作默认添加/修改收款账单
  1034. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1035. {
  1036. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1037. .Where(x => x.IsDel == 0 &&
  1038. x.Diid == diId &&
  1039. x.Remark.Equals("预付款")
  1040. )
  1041. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1042. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1043. .FirstAsync();
  1044. ffrInfo = new Fin_ForeignReceivables()
  1045. {
  1046. Diid = diId,
  1047. PriceName = dto.ClientUnit,
  1048. Price = dto.PaymentMoney,
  1049. Count = 1,
  1050. Unit = $"元",
  1051. ItemSumPrice = dto.PaymentMoney,
  1052. Rate = 1.0000M,
  1053. Currency = 836,
  1054. AddingWay = 0,
  1055. CreateUserId = dto.UserId,
  1056. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1057. Remark = $"预付款"
  1058. };
  1059. if (ffrInfo == null) //Add
  1060. {
  1061. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1062. }
  1063. else //修改
  1064. {
  1065. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1066. .UpdateColumns(x => new
  1067. {
  1068. x.PriceName,
  1069. x.Price,
  1070. x.ItemSumPrice,
  1071. x.CreateTime,
  1072. x.CreateUserId
  1073. })
  1074. .WhereColumns(x => x.Id)
  1075. .ExecuteCommandAsync();
  1076. }
  1077. }
  1078. #endregion
  1079. #region 签证人员团组时间通知
  1080. #region 计算出访起止时间
  1081. var startTime = new DateTime();
  1082. var endTime = new DateTime();
  1083. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1084. {
  1085. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1086. }
  1087. #endregion
  1088. if (diId > 0)
  1089. {
  1090. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1091. }
  1092. #endregion
  1093. _sqlSugar.CommitTran();
  1094. return Ok(JsonView(true));
  1095. }
  1096. catch (Exception ex)
  1097. {
  1098. _sqlSugar.RollbackTran();
  1099. return Ok(JsonView(false, ex.Message));
  1100. }
  1101. }
  1102. /// <summary>
  1103. /// 接团信息 操作(删除)
  1104. /// </summary>
  1105. /// <param name="dto"></param>
  1106. /// <returns></returns>
  1107. [HttpPost]
  1108. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1109. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1110. {
  1111. var diId = dto.Id;
  1112. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1113. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1114. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1115. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1116. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1117. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1118. #endregion
  1119. var groupData = await _groupRepository.GroupDel(dto);
  1120. if (groupData.Code != 0)
  1121. {
  1122. return Ok(JsonView(false, groupData.Msg));
  1123. }
  1124. return Ok(JsonView(true));
  1125. }
  1126. /// <summary>
  1127. /// 获取团组销售报价号
  1128. /// 团组添加时 使用
  1129. /// </summary>
  1130. /// <returns></returns>
  1131. [HttpPost]
  1132. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1133. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1134. {
  1135. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1136. if (groupData.Code != 0)
  1137. {
  1138. return Ok(JsonView(false, groupData.Msg));
  1139. }
  1140. object salesQuoteNo = new
  1141. {
  1142. SalesQuoteNo = groupData.Data
  1143. };
  1144. return Ok(JsonView(salesQuoteNo));
  1145. }
  1146. /// <summary>
  1147. /// 设置确认出团
  1148. /// </summary>
  1149. /// <param name="dto"></param>
  1150. /// <returns></returns>
  1151. [HttpPost]
  1152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1153. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1154. {
  1155. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1156. if (groupData.Code != 0)
  1157. {
  1158. return Ok(JsonView(false, groupData.Msg));
  1159. }
  1160. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1161. #region OA消息推送
  1162. try
  1163. {
  1164. string groupName = groupInfo.TeamName;
  1165. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1166. string title = $"系统通知";
  1167. string content = $"团组[{groupName}]已确认出团!";
  1168. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1169. }
  1170. catch (Exception ex)
  1171. {
  1172. }
  1173. #endregion
  1174. #region 应用推送
  1175. try
  1176. {
  1177. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1178. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1179. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1180. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1181. {
  1182. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1183. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1184. }
  1185. }
  1186. catch (Exception ex)
  1187. {
  1188. }
  1189. #endregion
  1190. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1191. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1192. }
  1193. /// <summary>
  1194. /// 获取团组名称data And 签证国别Data
  1195. /// </summary>
  1196. /// <param name="dto"></param>
  1197. /// <returns></returns>
  1198. [HttpPost]
  1199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1200. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1201. {
  1202. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1203. if (groupData.Code != 0)
  1204. {
  1205. return Ok(JsonView(false, groupData.Msg));
  1206. }
  1207. return Ok(JsonView(groupData.Data));
  1208. }
  1209. /// <summary>
  1210. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1211. /// </summary>
  1212. /// <returns></returns>
  1213. [HttpPost]
  1214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1215. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1216. {
  1217. try
  1218. {
  1219. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1220. if (groupData.Code != 0)
  1221. {
  1222. return Ok(JsonView(false, groupData.Msg));
  1223. }
  1224. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1225. }
  1226. catch (Exception ex)
  1227. {
  1228. return Ok(JsonView(false, "程序错误!"));
  1229. throw;
  1230. }
  1231. }
  1232. /// <summary>
  1233. /// 团组清单 Excel
  1234. /// </summary>
  1235. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1236. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1237. /// <returns></returns>
  1238. [HttpGet]
  1239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1240. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1241. {
  1242. DateTime _beginDt, _endDt;
  1243. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1244. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1245. if (!beginBool && !endBool)
  1246. {
  1247. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1248. }
  1249. string sql = string.Format(@"
  1250. SELECT
  1251. ROW_NUMBER,
  1252. Id,
  1253. SalesQuoteNo,
  1254. TourCode,
  1255. TeamTypeId,
  1256. TeamType,
  1257. TeamLevId,
  1258. TeamLev,
  1259. TeamName,
  1260. ClientName,
  1261. ClientUnit,
  1262. VisitDate,
  1263. VisitDays,
  1264. VisitPNumber,
  1265. JietuanOperatorId,
  1266. JietuanOperator,
  1267. IsSure,
  1268. CreateUserName,
  1269. IsBid
  1270. FROM
  1271. (
  1272. SELECT
  1273. ROW_NUMBER() OVER(
  1274. ORDER BY
  1275. gdi.CreateTime Desc
  1276. ) AS ROW_NUMBER,
  1277. gdi.Id,
  1278. SalesQuoteNo,
  1279. TourCode,
  1280. ssd.Id TeamTypeId,
  1281. ssd.Name TeamType,
  1282. ssd1.Id TeamLevId,
  1283. ssd1.Name TeamLev,
  1284. TeamName,
  1285. ClientName,
  1286. ClientUnit,
  1287. VisitDate,
  1288. VisitDays,
  1289. VisitPNumber,
  1290. JietuanOperator JietuanOperatorId,
  1291. su.CnName JietuanOperator,
  1292. IsSure,
  1293. gdi.CreateTime,
  1294. su1.CnName As CreateUserName,
  1295. gdi.IsBid
  1296. FROM
  1297. Grp_DelegationInfo gdi
  1298. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1299. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1300. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1301. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1302. WHERE
  1303. gdi.IsDel = 0
  1304. AND gdi.IsBid = 0
  1305. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1306. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1307. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1308. #region 处理所属部门
  1309. /*
  1310. * 1.sq 和 gyy 等显示 市场部
  1311. * 2.王鸽和主管及张总还有管理员号统一国交部
  1312. * 2-1. 4 管理员 ,21 张海麟
  1313. */
  1314. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1315. List<int> userIds1 = new List<int>() { 4, 21 };
  1316. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1317. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1318. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1319. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1320. .ToListAsync();
  1321. var droupIds = groupList.Select(it => it.Id).ToList();
  1322. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1323. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1324. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1325. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1326. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1327. {
  1328. DiId = tcl.DiId,
  1329. LastName = dc.LastName,
  1330. FirstName = dc.FirstName,
  1331. Sex = dc.Sex,
  1332. Birthday = dc.BirthDay,
  1333. Company = cc.CompanyFullName,
  1334. Job = dc.Job,
  1335. CreateTime = tcl.CreateTime,
  1336. })
  1337. .ToList();
  1338. foreach (var item in groupList)
  1339. {
  1340. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1341. string groupFirstName = "";
  1342. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1343. if (currDatas.Any())
  1344. {
  1345. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1346. }
  1347. item.GroupFirst = groupFirstName;
  1348. }
  1349. #endregion
  1350. #region Excel
  1351. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1352. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1353. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1354. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1355. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1356. //载入模板
  1357. WorkbookDesigner designer = new WorkbookDesigner();
  1358. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1359. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1360. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1361. dt.TableName = "GroupList";
  1362. designer.SetDataSource(dt);
  1363. designer.Process();
  1364. if (!Directory.Exists(savePath))
  1365. {
  1366. Directory.CreateDirectory(savePath);
  1367. }
  1368. string serverPath = $"{savePath}{fileName}";
  1369. designer.Workbook.Save(serverPath);
  1370. string rst = $"{servicePath}{ftpPath}{fileName}";
  1371. #endregion
  1372. return Ok(JsonView(true, "操作成功!", rst));
  1373. }
  1374. #endregion
  1375. #region 团组&签证
  1376. /// <summary>
  1377. /// 根据团组Id获取签证客户信息List
  1378. /// </summary>
  1379. /// <param name="dto">请求dto</param>
  1380. /// <returns></returns>
  1381. [HttpPost]
  1382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1383. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1384. {
  1385. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1386. if (groupData.Code != 0)
  1387. {
  1388. return Ok(JsonView(false, groupData.Msg));
  1389. }
  1390. return Ok(JsonView(groupData.Data));
  1391. }
  1392. /// <summary>
  1393. /// IOS获取团组签证拍照上传进度01(团组列表)
  1394. /// </summary>
  1395. /// <param name="dto">请求dto</param>
  1396. /// <returns></returns>
  1397. [HttpPost]
  1398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1399. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1400. {
  1401. if (dto == null)
  1402. {
  1403. return Ok(JsonView(false, "参数为空"));
  1404. }
  1405. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1406. return Ok(JsonView(visaList));
  1407. }
  1408. /// <summary>
  1409. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1410. /// </summary>
  1411. /// <returns></returns>
  1412. [HttpPost]
  1413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1414. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1415. {
  1416. if (dto == null)
  1417. {
  1418. return Ok(JsonView(false, "请求错误:"));
  1419. }
  1420. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1421. return Ok(JsonView(list));
  1422. }
  1423. /// <summary>
  1424. /// IOS获取团组签证拍照上传进度03(相册)
  1425. /// </summary>
  1426. /// <returns></returns>
  1427. [HttpPost]
  1428. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1429. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1430. {
  1431. if (dto == null)
  1432. {
  1433. return Ok(JsonView(false, "请求错误:"));
  1434. }
  1435. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1436. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1437. list.ForEach(s => s.url = url);
  1438. return Ok(JsonView(list));
  1439. }
  1440. /// <summary>
  1441. /// IOS获取团组签证拍照上传进度04(图片上传)
  1442. /// </summary>
  1443. /// <param name="dto"></param>
  1444. /// <returns></returns>
  1445. [HttpPost]
  1446. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1447. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1448. {
  1449. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1450. //if (!string.IsNullOrEmpty(result))
  1451. //{
  1452. //}
  1453. //else {
  1454. // return Ok(JsonView(false, "上传失败"));
  1455. //}
  1456. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1457. int sucNum = 0;
  1458. try
  1459. {
  1460. foreach (var item in dto.base64DataList)
  1461. {
  1462. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1463. string result = decodeBase64ToImage(item, imageName);
  1464. if (!string.IsNullOrEmpty(result))
  1465. {
  1466. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1467. pic.CreateUserId = dto.CreateUserId;
  1468. pic.PicName = imageName;
  1469. pic.PicPath = result;
  1470. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1471. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1472. if (insertResult > 0)
  1473. {
  1474. sucNum++;
  1475. }
  1476. }
  1477. }
  1478. }
  1479. catch (Exception ex)
  1480. {
  1481. return Ok(JsonView(false, ex.Message));
  1482. }
  1483. string msg = string.Format(@"成功上传{0}张", sucNum);
  1484. return Ok(JsonView(true, msg));
  1485. }
  1486. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1487. {
  1488. string filename = "";//声明一个string类型的相对路径
  1489. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1490. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1491. try//会有异常抛出,try,catch一下
  1492. {
  1493. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1494. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1495. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1496. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1497. //文件名称
  1498. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1499. //上传的文件的路径
  1500. string filePath = "";
  1501. if (!Directory.Exists(fileDir))
  1502. {
  1503. Directory.CreateDirectory(fileDir);
  1504. }
  1505. //上传的文件的路径
  1506. filePath = fileDir + filename;
  1507. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1508. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1509. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1510. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1511. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1512. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1513. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1514. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1515. bitmap.Dispose();
  1516. }
  1517. catch (Exception e)
  1518. {
  1519. string massage = e.Message;
  1520. Logs("IOS图片上传Error:" + massage);
  1521. //filename = e.Message;
  1522. }
  1523. return filename;//返回相对路径
  1524. }
  1525. /// <summary>
  1526. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1527. /// </summary>
  1528. /// <param name="dto"></param>
  1529. /// <returns></returns>
  1530. [HttpPost]
  1531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1532. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1533. {
  1534. if (dto == null)
  1535. {
  1536. return Ok(JsonView(false, "请求错误:"));
  1537. }
  1538. string msg = "参数错误";
  1539. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1540. {
  1541. try
  1542. {
  1543. //_delegationVisaRep.BeginTran();
  1544. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1545. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1546. .Where(s => s.Id == dto.visaProgressCustomerId)
  1547. .ExecuteCommandAsync();
  1548. if (updCount > 0 && dto.publishCode == 1)
  1549. {
  1550. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1551. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1552. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1553. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1554. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1555. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1556. if (groupData == null)
  1557. {
  1558. _delegationVisaRep.RollbackTran();
  1559. }
  1560. string title = string.Format(@"[签证进度更新]");
  1561. string content = string.Format(@"测试文本");
  1562. bool rst = await _message.AddMsg(new MessageDto()
  1563. {
  1564. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1565. IssuerId = dto.publisher,
  1566. Title = title,
  1567. Content = content,
  1568. ReleaseTime = DateTime.Now,
  1569. UIdList = new List<int> {
  1570. 234
  1571. }
  1572. });
  1573. if (rst)
  1574. {
  1575. return Ok(JsonView(true, "发送通知成功"));
  1576. }
  1577. }
  1578. //_delegationVisaRep.CommitTran();
  1579. }
  1580. catch (Exception)
  1581. {
  1582. //_delegationVisaRep.RollbackTran();
  1583. }
  1584. }
  1585. return Ok(JsonView(true, msg));
  1586. }
  1587. #endregion
  1588. #region 团组任务分配
  1589. /// <summary>
  1590. /// 团组任务分配初始化
  1591. /// </summary>
  1592. /// <param name="dto"></param>
  1593. /// <returns></returns>
  1594. [HttpPost]
  1595. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1596. public async Task<IActionResult> GetTaskAssignmen()
  1597. {
  1598. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1599. if (groupData.Code != 0)
  1600. {
  1601. return Ok(JsonView(false, groupData.Msg));
  1602. }
  1603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1604. }
  1605. /// <summary>
  1606. /// 团组任务分配查询
  1607. /// </summary>
  1608. /// <param name="dto"></param>
  1609. /// <returns></returns>
  1610. [HttpPost]
  1611. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1612. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1613. {
  1614. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1615. if (groupData.Code != 0)
  1616. {
  1617. return Ok(JsonView(false, groupData.Msg));
  1618. }
  1619. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1620. }
  1621. /// <summary>
  1622. /// 团组任务分配操作
  1623. /// </summary>
  1624. /// <param name="dto"></param>
  1625. /// <returns></returns>
  1626. [HttpPost]
  1627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1628. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1629. {
  1630. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1631. if (groupData.Code != 0)
  1632. {
  1633. return Ok(JsonView(false, groupData.Msg));
  1634. }
  1635. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1636. }
  1637. /// <summary>
  1638. /// 团组任务分配
  1639. /// 批量分配
  1640. /// 查询团组
  1641. /// </summary>
  1642. /// <param name="dto"></param>
  1643. /// <returns></returns>
  1644. [HttpPost]
  1645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1646. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1647. {
  1648. //参数验证
  1649. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1650. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1651. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1652. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1653. }
  1654. /// <summary>
  1655. /// 团组任务分配
  1656. /// 批量分配
  1657. /// </summary>
  1658. /// <param name="dto"></param>
  1659. /// <returns></returns>
  1660. [HttpPost]
  1661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1662. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1663. {
  1664. //参数验证
  1665. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1666. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1667. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1668. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1669. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1670. }
  1671. #endregion
  1672. #region 团组费用审核
  1673. /// <summary>
  1674. /// 费用审核
  1675. /// 团组列表 Page
  1676. /// </summary>
  1677. /// <param name="_dto">团组列表请求dto</param>
  1678. /// <returns></returns>
  1679. [HttpPost]
  1680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1681. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1682. {
  1683. #region 参数验证
  1684. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1685. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1686. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1687. #region 页面操作权限验证
  1688. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1689. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1690. #endregion
  1691. #endregion
  1692. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1693. {
  1694. string sqlWhere = string.Empty;
  1695. if (_dto.IsSure == 0) //未完成
  1696. {
  1697. sqlWhere += string.Format(@" And IsSure = 0");
  1698. }
  1699. else if (_dto.IsSure == 1) //已完成
  1700. {
  1701. sqlWhere += string.Format(@" And IsSure = 1");
  1702. }
  1703. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1704. {
  1705. string tj = _dto.SearchCriteria;
  1706. 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}%')",
  1707. tj, tj, tj, tj, tj);
  1708. }
  1709. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1710. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1711. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1712. From (
  1713. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1714. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1715. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1716. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1717. From Grp_DelegationInfo gdi
  1718. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1719. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1720. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1721. Where gdi.IsDel = 0 {0}
  1722. ) temp ", sqlWhere);
  1723. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1724. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1725. var _view = new
  1726. {
  1727. PageFuncAuth = pageFunAuthView,
  1728. Data = _DelegationList
  1729. };
  1730. return Ok(JsonView(true, "查询成功!", _view, total));
  1731. }
  1732. else
  1733. {
  1734. return Ok(JsonView(false, "查询失败"));
  1735. }
  1736. }
  1737. /// <summary>
  1738. /// 获取团组费用审核
  1739. /// </summary>
  1740. /// <param name="paras">参数Json字符串</param>
  1741. /// <returns></returns>
  1742. [HttpPost]
  1743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1744. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1745. {
  1746. try
  1747. {
  1748. #region 参数验证
  1749. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1750. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1751. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1752. #region 页面操作权限验证
  1753. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1754. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1755. #endregion
  1756. #endregion
  1757. var _view = new Grp_CreditCardPaymentView();
  1758. var clientNameList = getSimplClientList(_dto.DiId);
  1759. #region 费用清单
  1760. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1761. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1762. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1763. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1764. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1765. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1766. /*
  1767. * 76://酒店预订
  1768. */
  1769. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1770. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1771. /*
  1772. * 79://车/导游地接
  1773. */
  1774. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1776. /*
  1777. * 80: //签证
  1778. */
  1779. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1780. /*
  1781. *81: //邀请/公务活动
  1782. */
  1783. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1784. /*
  1785. * 82: //团组客户保险
  1786. */
  1787. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1788. /*
  1789. * Lable = 85 机票预订
  1790. */
  1791. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1792. /*
  1793. * 85 机票预定
  1794. */
  1795. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1796. /*
  1797. * 98 其他款项
  1798. */
  1799. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 285:收款退还
  1802. */
  1803. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1804. /*
  1805. * 1015: //超支费用
  1806. */
  1807. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1808. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1809. /*
  1810. * 币种信息
  1811. */
  1812. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1813. /*
  1814. * 车/导游地接 费用类型
  1815. */
  1816. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1817. /*
  1818. * 车/导游地接 费用类型
  1819. */
  1820. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1821. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1822. /*
  1823. * 用户信息
  1824. */
  1825. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1826. /*
  1827. * 费用模块
  1828. */
  1829. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1830. string priceModule = string.Empty;
  1831. if (sdPriceName != null)
  1832. {
  1833. priceModule = sdPriceName.Name;
  1834. }
  1835. /*
  1836. * 成本信息
  1837. */
  1838. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1839. decimal _groupRate = 0.0000M;
  1840. string _groupCurrencyCode = "-";
  1841. if (groupCost != null)
  1842. {
  1843. _groupRate = groupCost.Rate;
  1844. if (int.TryParse(groupCost.Currency, out int _currency))
  1845. {
  1846. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1847. }
  1848. else _groupCurrencyCode = groupCost.Currency;
  1849. }
  1850. string costContentSql = $"Select * From Grp_GroupCost";
  1851. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1852. //处理日期为空的天数
  1853. for (int i = 0; i < groupCostDetails.Count; i++)
  1854. if (i != 0)
  1855. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1856. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1857. /*
  1858. * 处理详情数据
  1859. */
  1860. foreach (var entity in entityList)
  1861. {
  1862. var _detail = new Grp_CreditCardPaymentDetailView();
  1863. _detail.Id = entity.Id;
  1864. _detail.PriceName = priceModule;
  1865. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1866. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1867. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1868. //处理金额
  1869. if (entity.CTable == 1015)
  1870. {
  1871. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1872. if (czInfo != null)
  1873. {
  1874. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1875. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1876. }
  1877. }
  1878. /*
  1879. * 应付款金额
  1880. */
  1881. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1882. string PaymentCurrency_WaitPay = "Unknown";
  1883. string hotelCurrncyCode = "Unknown";
  1884. string hotelCurrncyName = "Unknown";
  1885. if (sdPaymentCurrency_WaitPay != null)
  1886. {
  1887. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1888. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1889. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1890. if (hotelCurrncyCode.Equals("CNY"))
  1891. {
  1892. entity.DayRate = 1.0000M;
  1893. }
  1894. }
  1895. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1896. /*
  1897. * 此次付款金额
  1898. */
  1899. decimal CurrPayStr = 0.00M,
  1900. OriginalCurrPay = 0.00M;
  1901. if (entity.PayPercentage == 0)
  1902. {
  1903. if (entity.PayThenMoney != 0)
  1904. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1905. }
  1906. else
  1907. {
  1908. if (entity.PayMoney != 0)
  1909. {
  1910. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1911. }
  1912. }
  1913. //if (_dto.Label == 79)
  1914. //{
  1915. // string original = string.Empty;
  1916. // if (hotelCurrncyCode.Equals("CNY"))
  1917. // {
  1918. // OriginalCurrPay = CurrPayStr;
  1919. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1920. // }
  1921. // else
  1922. // {
  1923. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1924. // //760 EUR(7600.00 CNY)
  1925. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1926. // }
  1927. //}
  1928. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1929. string original = string.Empty;
  1930. if (hotelCurrncyCode.Equals("CNY"))
  1931. {
  1932. OriginalCurrPay = CurrPayStr;
  1933. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1934. }
  1935. else
  1936. {
  1937. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1938. //760 EUR(7600.00 CNY)
  1939. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1940. }
  1941. /*
  1942. * 剩余尾款
  1943. */
  1944. decimal BalanceStr = 0;
  1945. if (CurrPayStr != 0)
  1946. {
  1947. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1948. BalanceStr = 0;
  1949. else
  1950. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1951. }
  1952. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1953. /*
  1954. * Bus名称
  1955. */
  1956. _detail.BusName = "待增加";
  1957. /*
  1958. *费用所属
  1959. */
  1960. switch (entity.CTable)
  1961. {
  1962. case 76://酒店预订
  1963. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1964. if (hotelReservations != null)
  1965. {
  1966. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1967. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1968. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1969. string roomFeeStr = "", roomFeestr1 = "";
  1970. //是否比较房型价格
  1971. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1972. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1973. roomFeeStr += $"<br/>";
  1974. var roomTotal = 0.00M;
  1975. if (hotelReservations.SingleRoomPrice > 0)
  1976. {
  1977. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1978. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1979. __isSingle = true;
  1980. roomTotal += fee;
  1981. }
  1982. if (hotelReservations.DoubleRoomPrice > 0)
  1983. {
  1984. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1985. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1986. __isDouble = true;
  1987. roomTotal += fee;
  1988. }
  1989. if (hotelReservations.SuiteRoomPrice > 0)
  1990. {
  1991. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1992. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1993. __isSuite = true;
  1994. roomTotal += fee;
  1995. }
  1996. if (hotelReservations.OtherRoomPrice > 0)
  1997. {
  1998. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1999. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  2000. __isOther = true;
  2001. roomTotal += fee;
  2002. }
  2003. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  2004. else roomFeeStr += " 0.00 * 0";
  2005. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  2006. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  2007. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  2008. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2009. /*
  2010. * 费用类型
  2011. * 1:房费
  2012. * 2:早餐
  2013. * 3:地税
  2014. * 4:城市税
  2015. * </summary>
  2016. */
  2017. //地税
  2018. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2019. if (governmentRentData != null)
  2020. {
  2021. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2022. governmentRentFee = governmentRentData.Price;
  2023. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2024. if (governmentRentCurrData != null)
  2025. {
  2026. governmentRentCode = governmentRentCurrData.Name;
  2027. governmentRentName = $"({governmentRentCurrData.Remark})";
  2028. }
  2029. }
  2030. //城市税
  2031. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2032. if (cityTaxData != null)
  2033. {
  2034. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2035. cityTaxFee = cityTaxData.Price;
  2036. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2037. if (cityTaxCurrData != null)
  2038. {
  2039. cityTaxCode = cityTaxCurrData.Name;
  2040. cityTaxName = $"({cityTaxCurrData.Remark})";
  2041. }
  2042. }
  2043. //酒店早餐
  2044. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2045. if (breakfastData != null)
  2046. {
  2047. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2048. breakfastFee = breakfastData.Price;
  2049. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2050. if (breakfastCurrData != null)
  2051. {
  2052. breakfastCode = breakfastCurrData.Name;
  2053. breakfastName = $"({breakfastCurrData.Remark})";
  2054. }
  2055. }
  2056. //房间费用
  2057. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2058. if (roomData != null)
  2059. {
  2060. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2061. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2062. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2063. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2064. roomFee = roomData.Price;
  2065. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2066. if (roomCurrData != null)
  2067. {
  2068. roomCode = roomCurrData.Name;
  2069. roomName = $"({roomCurrData.Remark})";
  2070. }
  2071. }
  2072. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2073. string hotelCostStr = "";
  2074. decimal hotelCsotTotal = 0.00M;
  2075. if (groupCost != null)
  2076. {
  2077. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2078. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2079. }
  2080. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2081. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2082. string hotelCost_day = "";
  2083. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2084. foreach (var item in hotelCostDetails1)
  2085. {
  2086. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2087. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2088. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2089. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2090. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2091. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2092. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2093. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2094. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2095. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2096. hotelCost_day += @$"<br/>";
  2097. }
  2098. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2099. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2100. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2101. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2102. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2103. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2104. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2105. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2106. $"房间说明: {hotelReservations.Remark} <br/>" +
  2107. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2108. $"{hotelBreakfastStr}" +
  2109. $"{hotelGovernmentRentStr}" +
  2110. $"{hotelCityTaxStr}";
  2111. _detail.PriceNameContent = hotelReservations.HotelName;
  2112. }
  2113. break;
  2114. case 79://车/导游地接
  2115. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2116. if (touristGuideGroundReservations != null)
  2117. {
  2118. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2119. {
  2120. _detail.BusName = touristGuideGroundReservations.BusName;
  2121. }
  2122. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2123. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2124. //if (isInt)
  2125. //{
  2126. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2127. // if (cityInfo != null)
  2128. // {
  2129. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2130. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2131. // if (carFeeItem != null)
  2132. // {
  2133. // nameContent += $@"({carFeeItem.Name})";
  2134. // }
  2135. // _detail.PriceNameContent = nameContent;
  2136. // }
  2137. //}
  2138. //else
  2139. //{
  2140. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2141. //}
  2142. var touristGuideGroundReservationsContents =
  2143. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2144. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2145. foreach (var item in touristGuideGroundReservationsContents)
  2146. {
  2147. string typeName = "Unknown";
  2148. string carCurrencyCode = "Unknown";
  2149. string carCurrencyName = "Unknown";
  2150. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2151. if (carTypeData != null) typeName = carTypeData.Name;
  2152. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2153. if (currencyData != null)
  2154. {
  2155. carCurrencyCode = currencyData.Name;
  2156. carCurrencyName = currencyData.Remark;
  2157. }
  2158. //op、成本 币种是否一致
  2159. bool IsCurrencyAgreement = false;
  2160. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2161. string opCostStr = string.Empty;
  2162. decimal opCostTypePrice = 0.00M;
  2163. #region 处理成本各项费用
  2164. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2165. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2166. if (opCost.Count > 0)
  2167. {
  2168. switch (item.SId)
  2169. {
  2170. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2171. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2172. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2173. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2174. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2175. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2176. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2177. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2178. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2179. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2180. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2181. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2182. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2183. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2184. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2185. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2186. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2187. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2188. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2189. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2190. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2191. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2192. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2193. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2194. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2195. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2196. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2197. }
  2198. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2199. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2200. }
  2201. #endregion
  2202. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2203. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2204. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2205. $"{opTypeStr} {opCostStr}<br/>" +
  2206. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2207. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2208. }
  2209. _detail.PriceMsgContent = priceMsg;
  2210. }
  2211. break;
  2212. case 80: //签证
  2213. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2214. if (visaInfo != null)
  2215. {
  2216. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2217. _detail.PriceNameContent = visaInfo.VisaDescription;
  2218. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2219. }
  2220. break;
  2221. case 81: //邀请/公务活动
  2222. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2223. if (_ioa != null)
  2224. {
  2225. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2226. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2227. sendCurrName = "Unknown", //快递费用币种 Name
  2228. sendCurrCode = "Unknown", //快递费用币种 Code
  2229. eventsCurrName = "Unknown", //公务活动费币种 Name
  2230. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2231. translateCurrName = "Unknown", //公务翻译费 Name
  2232. translateCurrCode = "Unknown"; //公务翻译费 Code
  2233. #region 处理费用币种
  2234. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2235. if (inviteCurrData != null)
  2236. {
  2237. inviteCurrName = inviteCurrData.Remark;
  2238. inviteCurrCode = inviteCurrData.Name;
  2239. }
  2240. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2241. if (sendCurrData != null)
  2242. {
  2243. sendCurrName = sendCurrData.Remark;
  2244. sendCurrCode = sendCurrData.Name;
  2245. }
  2246. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2247. if (eventsCurrData != null)
  2248. {
  2249. eventsCurrName = eventsCurrData.Remark;
  2250. eventsCurrCode = eventsCurrData.Name;
  2251. }
  2252. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2253. if (translateCurrData != null)
  2254. {
  2255. translateCurrName = translateCurrData.Remark;
  2256. translateCurrCode = translateCurrData.Name;
  2257. }
  2258. #endregion
  2259. _detail.PriceNameContent = _ioa.InviterArea;
  2260. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2261. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2262. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2263. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2264. $@"备注:" + _ioa.Remark + "<br/>";
  2265. }
  2266. break;
  2267. case 82: //团组客户保险
  2268. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2269. if (customers != null)
  2270. {
  2271. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2272. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2273. }
  2274. break;
  2275. case 85: //机票预订
  2276. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2277. if (jpRes != null)
  2278. {
  2279. string FlightsDescription = jpRes.FlightsDescription;
  2280. string PriceDescription = jpRes.PriceDescription;
  2281. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2282. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2283. }
  2284. break;
  2285. case 98://其他款项
  2286. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2287. if (gdpRes != null)
  2288. {
  2289. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2290. _detail.PriceNameContent = gdpRes.PriceName;
  2291. }
  2292. break;
  2293. case 285://收款退还
  2294. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2295. if (refundAndOtherMoney != null)
  2296. {
  2297. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2298. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2299. }
  2300. break;
  2301. case 751://酒店早餐
  2302. break;
  2303. case 1015://超支费用
  2304. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2305. if (groupExtraCost != null)
  2306. {
  2307. _detail.PriceNameContent = groupExtraCost.PriceName;
  2308. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2309. }
  2310. break;
  2311. default:
  2312. break;
  2313. }
  2314. /*
  2315. * 申请人
  2316. */
  2317. string operatorName = " - ";
  2318. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2319. if (_opUser != null)
  2320. {
  2321. operatorName = _opUser.CnName;
  2322. }
  2323. _detail.OperatorName = operatorName;
  2324. /*
  2325. * 审核人
  2326. */
  2327. string auditOperatorName = "Unknown";
  2328. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2329. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2330. else
  2331. {
  2332. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2333. if (_adUser != null)
  2334. {
  2335. auditOperatorName = _adUser.CnName;
  2336. }
  2337. }
  2338. _detail.AuditOperatorName = auditOperatorName;
  2339. /*
  2340. * 超预算比例
  2341. */
  2342. string overBudgetStr = "";
  2343. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2344. else if (entity.ExceedBudget == 0)
  2345. {
  2346. if (entity.CTable == 76 || entity.CTable == 79)
  2347. {
  2348. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2349. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2350. }
  2351. else
  2352. {
  2353. overBudgetStr = "未超预算";
  2354. }
  2355. }
  2356. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2357. _detail.OverBudget = overBudgetStr;
  2358. decimal auditFee = 0.00M; //已审核金额 人名币
  2359. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2360. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2361. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2362. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2363. {
  2364. auditedFeeOriginal = entity.PayMoney;
  2365. auditFee = CurrPayStr;
  2366. }
  2367. else if (entity.IsAuditGM == 0)
  2368. {
  2369. unAuditFeeCNY = CurrPayStr;
  2370. unAuditFeeOriginal = OriginalCurrPay;
  2371. OriginalCurrPay = 0.00M;
  2372. }
  2373. /*
  2374. * 费用总计
  2375. */
  2376. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2377. {
  2378. CurrencyId = entity.PaymentCurrency,
  2379. CurrencyName = PaymentCurrency_WaitPay,
  2380. AmountPayable = entity.PayMoney,
  2381. ThisPayment = OriginalCurrPay,
  2382. BalancePayment = BalanceStr,
  2383. AuditedFunds = auditFee,
  2384. AuditedFundsOriginal = auditedFeeOriginal,
  2385. UnAuditFundsCNY = unAuditFeeCNY,
  2386. UnAuditFundsOriginal = unAuditFeeOriginal
  2387. });
  2388. _detail.IsAuditGM = entity.IsAuditGM;
  2389. detailList.Add(_detail);
  2390. }
  2391. #endregion
  2392. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2393. /*
  2394. * 下方描述处理
  2395. */
  2396. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2397. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2398. if (ccpCurrencyPrice != null)
  2399. {
  2400. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2401. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2402. }
  2403. else
  2404. {
  2405. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2406. }
  2407. string amountPayableStr = string.Format(@"应付款总金额: ");
  2408. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2409. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2410. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2411. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2412. foreach (var item in nonDuplicat)
  2413. {
  2414. var currencyName = item.CurrencyName;
  2415. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2416. if (strs.Count > 0)
  2417. {
  2418. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2419. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2420. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2421. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2422. //单独处理此次付款金额
  2423. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2424. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2425. //单独处理已审核费用
  2426. //if (item.CurrencyId == 836) //人民币
  2427. //{
  2428. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2429. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2430. //}
  2431. //else
  2432. //{
  2433. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2434. //}
  2435. if (currencyName.Equals("CNY"))
  2436. {
  2437. //已审核费用
  2438. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2439. //未审核费用
  2440. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2441. }
  2442. else
  2443. {
  2444. //已审核费用
  2445. 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"));
  2446. //未审核费用
  2447. 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"));
  2448. }
  2449. }
  2450. }
  2451. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2452. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2453. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2454. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2455. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2456. var _view1 = new
  2457. {
  2458. PageFuncAuth = pageFunAuthView,
  2459. Data = _view
  2460. };
  2461. return Ok(JsonView(_view1));
  2462. }
  2463. catch (Exception ex)
  2464. {
  2465. return Ok(JsonView(false, ex.Message));
  2466. }
  2467. }
  2468. /// <summary>
  2469. /// 费用审核
  2470. /// 修改团组费用审核状态
  2471. /// </summary>
  2472. /// <param name="_dto">参数Json字符串</param>
  2473. /// <returns></returns>
  2474. [HttpPost]
  2475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2476. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2477. {
  2478. #region 参数验证
  2479. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2480. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2481. #endregion
  2482. #region 页面操作权限验证
  2483. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2484. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2485. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2486. #endregion
  2487. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2488. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2489. DateTime dtNow = DateTime.Now;
  2490. _groupRepository.BeginTran();
  2491. int rst = 0;
  2492. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2493. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2494. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2495. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2496. List<dynamic> msgDatas = new List<dynamic>();
  2497. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2498. foreach (var item in idList)
  2499. {
  2500. int CreditId = int.Parse(item);
  2501. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2502. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2503. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2504. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2505. .Where(s => s.Id == CreditId)
  2506. .ExecuteCommandAsync();
  2507. if (result < 1)
  2508. {
  2509. rst = -1;
  2510. _groupRepository.RollbackTran();
  2511. return Ok(JsonView(false, "操作失败并回滚!"));
  2512. }
  2513. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2514. if (creditData != null)
  2515. {
  2516. #region 应用通知配置
  2517. try
  2518. {
  2519. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2520. }
  2521. catch (Exception ex)
  2522. {
  2523. }
  2524. #endregion
  2525. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2526. string groupNameStr = string.Empty;
  2527. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2528. if (groupData != null) groupNameStr = groupData.TeamName;
  2529. string creditTypeStr = string.Empty;
  2530. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2531. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2532. string creditCurrency = string.Empty;
  2533. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2534. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2535. if (creditCurrency.Equals("CNY"))
  2536. {
  2537. creditData.DayRate = 1.0000M;
  2538. }
  2539. if (creditData.PayPercentage == 0.00M)
  2540. {
  2541. creditData.PayPercentage = 100M;
  2542. }
  2543. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2544. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2545. string msgContent = "";
  2546. if (creditCurrency.Equals("CNY"))
  2547. {
  2548. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2549. }
  2550. else
  2551. {
  2552. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2553. }
  2554. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2555. }
  2556. }
  2557. if (rst == 0)
  2558. {
  2559. _groupRepository.CommitTran();
  2560. foreach (var item in msgDatas)
  2561. {
  2562. //发送消息
  2563. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2564. }
  2565. #region 应用推送
  2566. try
  2567. {
  2568. foreach (var ccpId in dic_ccp_user.Keys)
  2569. {
  2570. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2571. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2572. }
  2573. }
  2574. catch (Exception)
  2575. {
  2576. }
  2577. #endregion
  2578. return Ok(JsonView(true, "操作成功!"));
  2579. }
  2580. return Ok(JsonView(false, "操作失败!"));
  2581. }
  2582. #endregion
  2583. #region 机票费用录入
  2584. /// <summary>
  2585. /// 机票录入当前登录人可操作团组
  2586. /// </summary>
  2587. /// <param name="dto"></param>
  2588. /// <returns></returns>
  2589. [HttpPost]
  2590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2591. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2592. {
  2593. try
  2594. {
  2595. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2596. if (groupData.Code != 0)
  2597. {
  2598. return Ok(JsonView(false, groupData.Msg));
  2599. }
  2600. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2601. }
  2602. catch (Exception ex)
  2603. {
  2604. return Ok(JsonView(false, "程序错误!"));
  2605. throw;
  2606. }
  2607. }
  2608. /// <summary>
  2609. /// 机票费用录入列表
  2610. /// </summary>
  2611. /// <param name="dto"></param>
  2612. /// <returns></returns>
  2613. [HttpPost]
  2614. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2615. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2616. {
  2617. try
  2618. {
  2619. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2620. if (groupData.Code != 0)
  2621. {
  2622. return Ok(JsonView(false, groupData.Msg));
  2623. }
  2624. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2625. }
  2626. catch (Exception ex)
  2627. {
  2628. return Ok(JsonView(false, ex.Message));
  2629. throw;
  2630. }
  2631. }
  2632. /// <summary>
  2633. /// 根据id查询费用录入信息
  2634. /// </summary>
  2635. /// <param name="dto"></param>
  2636. /// <returns></returns>
  2637. [HttpPost]
  2638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2639. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2640. {
  2641. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2642. if (groupData.Code != 0)
  2643. {
  2644. return Ok(JsonView(false, groupData.Msg));
  2645. }
  2646. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2647. }
  2648. /// <summary>
  2649. /// 机票费用录入操作(Status:1.新增,2.修改)
  2650. /// </summary>
  2651. /// <param name="dto"></param>
  2652. /// <returns></returns>
  2653. [HttpPost]
  2654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2655. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2656. {
  2657. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2658. if (groupData.Code != 0)
  2659. {
  2660. return Ok(JsonView(false, groupData.Msg));
  2661. }
  2662. #region 应用推送
  2663. try
  2664. {
  2665. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2666. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2667. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2668. //2024-10-21 新增LZ UID
  2669. var userIds = new List<int>() { 21 };
  2670. string title = $"系统通知";
  2671. string content = "";
  2672. var diId = dto.AirTicketResOpData.DiId;
  2673. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2674. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2675. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2676. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2677. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2678. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2679. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2680. }
  2681. catch (Exception ex)
  2682. {
  2683. }
  2684. #endregion
  2685. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2686. }
  2687. /// <summary>
  2688. /// 根据舱位类型查询接团客户名单信息
  2689. /// </summary>
  2690. /// <param name="dto"></param>
  2691. /// <returns></returns>
  2692. [HttpPost]
  2693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2694. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2695. {
  2696. try
  2697. {
  2698. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2699. if (crm_Groups.Count != 0)
  2700. {
  2701. List<dynamic> Customer = new List<dynamic>();
  2702. foreach (var item in crm_Groups)
  2703. {
  2704. var data = new
  2705. {
  2706. Id = item.Id,
  2707. Pinyin = item.Pinyin,
  2708. Name = item.LastName + item.FirstName
  2709. };
  2710. Customer.Add(data);
  2711. }
  2712. return Ok(JsonView(true, "查询成功!", Customer));
  2713. }
  2714. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2715. }
  2716. catch (Exception ex)
  2717. {
  2718. return Ok(JsonView(false, "程序错误!"));
  2719. throw;
  2720. }
  2721. }
  2722. /// <summary>
  2723. /// 根据团号获取客户信息
  2724. /// </summary>
  2725. /// <param name="dto"></param>
  2726. /// <returns></returns>
  2727. [HttpPost]
  2728. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2729. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2730. {
  2731. var jw = JsonView(false);
  2732. if (dto.DIID < 1)
  2733. {
  2734. jw.Msg += "请输入正确的diid";
  2735. return Ok(jw);
  2736. }
  2737. var arr = getSimplClientList(dto.DIID);
  2738. jw = JsonView(true, "获取成功!", arr);
  2739. return Ok(jw);
  2740. }
  2741. private List<SimplClientInfo> getSimplClientList(int diId)
  2742. {
  2743. 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);
  2744. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2745. foreach (var item in arr)
  2746. {
  2747. EncryptionProcessor.DecryptProperties(item);
  2748. }
  2749. return arr;
  2750. }
  2751. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2752. {
  2753. string result = origin;
  2754. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2755. {
  2756. string[] temparr = origin.Split(',');
  2757. string fistrStr = temparr[0];
  2758. int count = temparr.Count();
  2759. int tempId;
  2760. bool success = int.TryParse(fistrStr, out tempId);
  2761. if (success)
  2762. {
  2763. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2764. if (tempInfo != null)
  2765. {
  2766. if (count > 1)
  2767. {
  2768. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2769. }
  2770. else
  2771. {
  2772. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2773. }
  2774. }
  2775. }
  2776. }
  2777. return result;
  2778. }
  2779. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2780. {
  2781. string result = origin;
  2782. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2783. {
  2784. string[] temparr = origin.Split(',');
  2785. result = "";
  2786. foreach (var item in temparr)
  2787. {
  2788. int tempId;
  2789. bool success = int.TryParse(item, out tempId);
  2790. if (success)
  2791. {
  2792. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2793. if (tempInfo != null)
  2794. {
  2795. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2796. }
  2797. }
  2798. }
  2799. }
  2800. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2801. return result;
  2802. }
  2803. /// <summary>
  2804. /// 机票费用录入,删除
  2805. /// </summary>
  2806. /// <param name="dto"></param>
  2807. /// <returns></returns>
  2808. [HttpPost]
  2809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2810. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2811. {
  2812. try
  2813. {
  2814. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2815. if (res)
  2816. {
  2817. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2818. {
  2819. IsDel = 1,
  2820. DeleteUserId = dto.DeleteUserId,
  2821. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2822. }).ExecuteCommandAsync();
  2823. return Ok(JsonView(true, "删除成功!"));
  2824. }
  2825. return Ok(JsonView(false, "删除失败!"));
  2826. }
  2827. catch (Exception ex)
  2828. {
  2829. return Ok(JsonView(false, "程序错误!"));
  2830. throw;
  2831. }
  2832. }
  2833. /// <summary>
  2834. /// 导出机票录入报表
  2835. /// </summary>
  2836. /// <param name="dto"></param>
  2837. /// <returns></returns>
  2838. [HttpPost]
  2839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2840. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2841. {
  2842. try
  2843. {
  2844. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2845. if (groupData.Code != 0)
  2846. {
  2847. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2848. }
  2849. else
  2850. {
  2851. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2852. if (AirTicketReservations.Count != 0)
  2853. {
  2854. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2855. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2856. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2857. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2858. WorkbookDesigner designer = new WorkbookDesigner();
  2859. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2860. decimal countCost = 0;
  2861. foreach (var item in AirTicketReservations)
  2862. {
  2863. #region 处理客人姓名
  2864. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2865. item.ClientName = clientNames;
  2866. #endregion
  2867. if (item.BankType == "其他")
  2868. {
  2869. item.BankNo = "--";
  2870. }
  2871. else
  2872. {
  2873. if (!string.IsNullOrEmpty(item.BankType))
  2874. {
  2875. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2876. }
  2877. }
  2878. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2879. item.Price = System.Decimal.Round(item.Price, 2);
  2880. countCost += Convert.ToDecimal(item.Price);
  2881. }
  2882. designer.SetDataSource("Export", AirTicketReservations);
  2883. designer.SetDataSource("ExportDiCode", diCode);
  2884. designer.SetDataSource("ExportDiName", diName);
  2885. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2886. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2887. designer.Process();
  2888. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2889. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2890. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2891. return Ok(JsonView(true, "成功", url = rst));
  2892. }
  2893. else
  2894. {
  2895. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2896. }
  2897. }
  2898. }
  2899. catch (Exception ex)
  2900. {
  2901. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2902. throw;
  2903. }
  2904. }
  2905. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2906. /// <summary>
  2907. /// 行程单导出
  2908. /// </summary>
  2909. /// <param name="dto"></param>
  2910. /// <returns></returns>
  2911. [HttpPost]
  2912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2913. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2914. {
  2915. try
  2916. {
  2917. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2918. if (groupData.Code != 0)
  2919. {
  2920. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2921. }
  2922. else
  2923. {
  2924. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2925. if (dto.Language == "CN")
  2926. {
  2927. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2928. DocumentBuilder builder = new DocumentBuilder(doc);
  2929. int tableIndex = 0;//表格索引
  2930. //得到文档中的第一个表格
  2931. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2932. foreach (var item in _AirTicketReservations)
  2933. {
  2934. #region 处理固定数据
  2935. string[] FlightsCode = item.FlightsCode.Split('/');
  2936. if (FlightsCode.Length != 0)
  2937. {
  2938. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2939. if (_AirCompany != null)
  2940. {
  2941. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2942. }
  2943. else
  2944. {
  2945. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2946. }
  2947. }
  2948. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2949. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2950. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2951. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2952. string name = "";
  2953. foreach (string clientName in nameArray)
  2954. {
  2955. if (!name.Contains(clientName))
  2956. {
  2957. name += clientName + ",";
  2958. }
  2959. }
  2960. if (!string.IsNullOrWhiteSpace(name))
  2961. {
  2962. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2963. }
  2964. else
  2965. {
  2966. table.Range.Bookmarks["ClientName"].Text = "--";
  2967. }
  2968. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2969. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2970. table.Range.Bookmarks["JointTicket"].Text = "--";
  2971. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2972. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2973. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2974. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2975. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2976. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2977. #endregion
  2978. #region 循环数据处理
  2979. List<AirInfo> airs = new List<AirInfo>();
  2980. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2981. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2982. for (int i = 0; i < FlightsCode.Length; i++)
  2983. {
  2984. AirInfo air = new AirInfo();
  2985. string[] tempstr = DayArray[i]
  2986. .Replace("\r\n", string.Empty)
  2987. .Replace("\\r\\n", string.Empty)
  2988. .TrimStart().TrimEnd()
  2989. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2990. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2991. string starCity = "";
  2992. if (star_Three != null)
  2993. {
  2994. starCity = star_Three.AirPort;
  2995. }
  2996. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2997. string EndCity = "";
  2998. if (End_Three != null)
  2999. {
  3000. EndCity = End_Three.AirPort;
  3001. }
  3002. air.Destination = starCity + "/" + EndCity;
  3003. air.Flight = FlightsCode[i];
  3004. air.SeatingClass = item.CTypeName;
  3005. string dateTime = tempstr[2];
  3006. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3007. air.FlightDate = DateTemp;
  3008. air.DepartureTime = tempstr[5];
  3009. air.LandingTime = tempstr[6];
  3010. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3011. air.TicketStatus = "--";
  3012. air.Luggage = "--";
  3013. air.DepartureTerminal = "--";
  3014. air.LandingTerminal = "--";
  3015. airs.Add(air);
  3016. }
  3017. int row = 13;
  3018. for (int i = 0; i < airs.Count; i++)
  3019. {
  3020. if (airs.Count > 2)
  3021. {
  3022. for (int j = 0; j < airs.Count - 2; j++)
  3023. {
  3024. var CopyRow = table.Rows[12].Clone(true);
  3025. table.Rows.Add(CopyRow);
  3026. }
  3027. }
  3028. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3029. int index = 0;
  3030. foreach (PropertyInfo property in properties)
  3031. {
  3032. string value = property.GetValue(airs[i]).ToString();
  3033. Cell ishcel0 = table.Rows[row].Cells[index];
  3034. Paragraph p = new Paragraph(doc);
  3035. string s = value;
  3036. p.AppendChild(new Run(doc, s));
  3037. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3038. ishcel0.AppendChild(p);
  3039. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3040. index++;
  3041. }
  3042. row++;
  3043. }
  3044. #endregion
  3045. Paragraph lastParagraph = new Paragraph(doc);
  3046. //第一个表格末尾加段落
  3047. table.ParentNode.InsertAfter(lastParagraph, table);
  3048. //复制第一个表格
  3049. Table cloneTable = (Table)table.Clone(true);
  3050. //在文档末尾段落后面加入复制的表格
  3051. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3052. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3053. {
  3054. int rownewsIndex = 13;
  3055. for (int i = 0; i < 2; i++)
  3056. {
  3057. var CopyRow = table.Rows[12].Clone(true);
  3058. table.Rows.RemoveAt(13);
  3059. table.Rows.Add(CopyRow);
  3060. rownewsIndex++;
  3061. }
  3062. }
  3063. else
  3064. {
  3065. table.Rows.RemoveAt(12);
  3066. }
  3067. cloneTable.Rows.RemoveAt(12);
  3068. }
  3069. if (_AirTicketReservations.Count != 0)
  3070. {
  3071. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3072. if (FlightsCode.Length != 0)
  3073. {
  3074. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3075. if (_AirCompany != null)
  3076. {
  3077. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3078. }
  3079. else
  3080. {
  3081. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3082. }
  3083. }
  3084. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3085. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3086. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3087. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3088. string name = "";
  3089. foreach (string clientName in nameArray)
  3090. {
  3091. if (!name.Contains(clientName))
  3092. {
  3093. name += clientName + ",";
  3094. }
  3095. }
  3096. if (!string.IsNullOrWhiteSpace(name))
  3097. {
  3098. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3099. }
  3100. else
  3101. {
  3102. table.Range.Bookmarks["ClientName"].Text = "--";
  3103. }
  3104. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3105. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3106. table.Range.Bookmarks["JointTicket"].Text = "--";
  3107. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3108. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3109. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3110. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3111. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3112. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3113. }
  3114. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3115. //保存合并后的文档
  3116. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3117. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3118. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3119. return Ok(JsonView(true, "成功!", rst));
  3120. }
  3121. else
  3122. {
  3123. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3124. DocumentBuilder builder = new DocumentBuilder(doc);
  3125. int tableIndex = 0;//表格索引
  3126. //得到文档中的第一个表格
  3127. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3128. List<string> texts = new List<string>();
  3129. foreach (var item in _AirTicketReservations)
  3130. {
  3131. string[] FlightsCode = item.FlightsCode.Split('/');
  3132. if (FlightsCode.Length != 0)
  3133. {
  3134. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3135. if (_AirCompany != null)
  3136. {
  3137. if (!transDic.ContainsKey(_AirCompany.CnName))
  3138. {
  3139. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3140. }
  3141. }
  3142. else
  3143. {
  3144. if (!transDic.ContainsKey("--"))
  3145. {
  3146. transDic.Add("--", "--");
  3147. }
  3148. }
  3149. }
  3150. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3151. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3152. string name = "";
  3153. foreach (string clientName in nameArray)
  3154. {
  3155. name += clientName + ",";
  3156. }
  3157. if (!texts.Contains(name))
  3158. {
  3159. texts.Add(name);
  3160. }
  3161. List<AirInfo> airs = new List<AirInfo>();
  3162. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3163. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3164. for (int i = 0; i < FlightsCode.Length; i++)
  3165. {
  3166. AirInfo air = new AirInfo();
  3167. string[] tempstr = DayArray[i]
  3168. .Replace("\r\n", string.Empty)
  3169. .Replace("\\r\\n", string.Empty)
  3170. .TrimStart().TrimEnd()
  3171. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3172. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3173. if (star_Three != null)
  3174. {
  3175. if (!transDic.ContainsKey(star_Three.AirPort))
  3176. {
  3177. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3178. }
  3179. }
  3180. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3181. if (End_Three != null)
  3182. {
  3183. if (!transDic.ContainsKey(End_Three.AirPort))
  3184. {
  3185. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3186. }
  3187. }
  3188. if (!texts.Contains(item.CTypeName))
  3189. {
  3190. texts.Add(item.CTypeName);
  3191. }
  3192. }
  3193. }
  3194. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3195. if (transData.Count > 0)
  3196. {
  3197. foreach (TranslateResult item in transData)
  3198. {
  3199. if (!transDic.ContainsKey(item.Query))
  3200. {
  3201. transDic.Add(item.Query, item.Translation);
  3202. }
  3203. }
  3204. }
  3205. foreach (var item in _AirTicketReservations)
  3206. {
  3207. #region 处理固定数据
  3208. string[] FlightsCode = item.FlightsCode.Split('/');
  3209. if (FlightsCode.Length != 0)
  3210. {
  3211. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3212. if (_AirCompany != null)
  3213. {
  3214. string str = "--";
  3215. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3216. if (!string.IsNullOrEmpty(translateResult))
  3217. {
  3218. str = translateResult;
  3219. str = _airTicketResRep.Processing(str);
  3220. }
  3221. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3222. }
  3223. else
  3224. {
  3225. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3226. }
  3227. }
  3228. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3229. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3230. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3231. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3232. string names = "";
  3233. foreach (string clientName in nameArray)
  3234. {
  3235. names += clientName + ",";
  3236. }
  3237. if (!string.IsNullOrWhiteSpace(names))
  3238. {
  3239. string str = "--";
  3240. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3241. if (!string.IsNullOrEmpty(translateResult))
  3242. {
  3243. str = translateResult;
  3244. str = _airTicketResRep.Processing(str);
  3245. }
  3246. table.Range.Bookmarks["ClientName"].Text = str;
  3247. }
  3248. else
  3249. {
  3250. table.Range.Bookmarks["ClientName"].Text = "--";
  3251. }
  3252. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3253. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3254. table.Range.Bookmarks["JointTicket"].Text = "--";
  3255. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3256. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3257. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3258. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3259. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3260. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3261. #endregion
  3262. #region 循环数据处理
  3263. List<AirInfo> airs = new List<AirInfo>();
  3264. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3265. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3266. for (int i = 0; i < FlightsCode.Length; i++)
  3267. {
  3268. AirInfo air = new AirInfo();
  3269. string[] tempstr = DayArray[i]
  3270. .Replace("\r\n", string.Empty)
  3271. .Replace("\\r\\n", string.Empty)
  3272. .TrimStart().TrimEnd()
  3273. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3274. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3275. string starCity = "";
  3276. if (star_Three != null)
  3277. {
  3278. string str2 = "--";
  3279. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3280. if (!string.IsNullOrEmpty(translateResult2))
  3281. {
  3282. str2 = translateResult2;
  3283. str2 = _airTicketResRep.Processing(str2);
  3284. }
  3285. starCity = str2;
  3286. }
  3287. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3288. string EndCity = "";
  3289. if (End_Three != null)
  3290. {
  3291. string str1 = "--";
  3292. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3293. if (!string.IsNullOrEmpty(translateResult1))
  3294. {
  3295. str1 = translateResult1;
  3296. str1 = _airTicketResRep.Processing(str1);
  3297. }
  3298. EndCity = str1;
  3299. }
  3300. air.Destination = starCity + "/" + EndCity;
  3301. air.Flight = FlightsCode[i];
  3302. string str = "--";
  3303. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3304. if (!string.IsNullOrEmpty(translateResult))
  3305. {
  3306. str = translateResult;
  3307. str = _airTicketResRep.Processing(str);
  3308. }
  3309. air.SeatingClass = str;
  3310. string dateTime = tempstr[2];
  3311. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3312. air.FlightDate = DateTemp;
  3313. air.DepartureTime = tempstr[5];
  3314. air.LandingTime = tempstr[6];
  3315. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3316. air.TicketStatus = "--";
  3317. air.Luggage = "--";
  3318. air.DepartureTerminal = "--";
  3319. air.LandingTerminal = "--";
  3320. airs.Add(air);
  3321. }
  3322. int row = 13;
  3323. for (int i = 0; i < airs.Count; i++)
  3324. {
  3325. if (airs.Count > 2)
  3326. {
  3327. for (int j = 0; j < airs.Count - 2; j++)
  3328. {
  3329. var CopyRow = table.Rows[12].Clone(true);
  3330. table.Rows.Add(CopyRow);
  3331. }
  3332. }
  3333. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3334. int index = 0;
  3335. foreach (PropertyInfo property in properties)
  3336. {
  3337. string value = property.GetValue(airs[i]).ToString();
  3338. Cell ishcel0 = table.Rows[row].Cells[index];
  3339. Paragraph p = new Paragraph(doc);
  3340. string s = value;
  3341. p.AppendChild(new Run(doc, s));
  3342. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3343. ishcel0.AppendChild(p);
  3344. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3345. //ishcel0.CellFormat.VerticalAlignment=
  3346. index++;
  3347. }
  3348. row++;
  3349. }
  3350. #endregion
  3351. Paragraph lastParagraph = new Paragraph(doc);
  3352. //第一个表格末尾加段落
  3353. table.ParentNode.InsertAfter(lastParagraph, table);
  3354. //复制第一个表格
  3355. Table cloneTable = (Table)table.Clone(true);
  3356. //在文档末尾段落后面加入复制的表格
  3357. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3358. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3359. {
  3360. int rownewsIndex = 13;
  3361. for (int i = 0; i < 2; i++)
  3362. {
  3363. var CopyRow = table.Rows[12].Clone(true);
  3364. table.Rows.RemoveAt(13);
  3365. table.Rows.Add(CopyRow);
  3366. rownewsIndex++;
  3367. }
  3368. }
  3369. else
  3370. {
  3371. table.Rows.RemoveAt(12);
  3372. }
  3373. cloneTable.Rows.RemoveAt(12);
  3374. }
  3375. if (_AirTicketReservations.Count != 0)
  3376. {
  3377. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3378. if (FlightsCode.Length != 0)
  3379. {
  3380. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3381. if (_AirCompany != null)
  3382. {
  3383. string str = "--";
  3384. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3385. if (!string.IsNullOrEmpty(translateResult))
  3386. {
  3387. str = translateResult;
  3388. str = _airTicketResRep.Processing(str);
  3389. }
  3390. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3391. }
  3392. else
  3393. {
  3394. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3395. }
  3396. }
  3397. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3398. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3399. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3400. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3401. string names = "";
  3402. foreach (string clientName in nameArray)
  3403. {
  3404. names += clientName + ",";
  3405. }
  3406. if (!string.IsNullOrWhiteSpace(names))
  3407. {
  3408. string str = "--";
  3409. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3410. if (!string.IsNullOrEmpty(translateResult))
  3411. {
  3412. str = translateResult;
  3413. str = _airTicketResRep.Processing(str);
  3414. }
  3415. table.Range.Bookmarks["ClientName"].Text = str;
  3416. }
  3417. else
  3418. {
  3419. table.Range.Bookmarks["ClientName"].Text = "--";
  3420. }
  3421. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3422. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3423. table.Range.Bookmarks["JointTicket"].Text = "--";
  3424. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3425. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3426. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3427. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3428. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3429. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3430. }
  3431. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3432. //保存合并后的文档
  3433. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3434. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3435. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3436. return Ok(JsonView(true, "成功!", rst));
  3437. }
  3438. }
  3439. }
  3440. catch (Exception ex)
  3441. {
  3442. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3443. throw;
  3444. }
  3445. }
  3446. #endregion
  3447. #region 团组增减款项 --> 其他款项
  3448. /// <summary>
  3449. /// 团组增减款项下拉框绑定
  3450. /// </summary>
  3451. /// <param name="dto"></param>
  3452. /// <returns></returns>
  3453. [HttpPost]
  3454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3455. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3456. {
  3457. #region 参数验证
  3458. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3459. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3460. #endregion
  3461. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3462. }
  3463. /// <summary>
  3464. /// 根据团组Id查询团组增减款项
  3465. /// </summary>
  3466. /// <param name="dto"></param>
  3467. /// <returns></returns>
  3468. [HttpPost]
  3469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3470. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3471. {
  3472. #region 参数验证
  3473. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3474. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3475. #endregion
  3476. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3477. }
  3478. /// <summary>
  3479. /// 团组增减款项操作(Status:1.新增,2.修改)
  3480. /// </summary>
  3481. /// <param name="dto"></param>
  3482. /// <returns></returns>
  3483. [HttpPost]
  3484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3485. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3486. {
  3487. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3488. if (groupData.Code != 200)
  3489. {
  3490. return Ok(JsonView(false, groupData.Msg));
  3491. }
  3492. #region 应用推送
  3493. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3494. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3495. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3496. //自动审核
  3497. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3498. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3499. //2024-10-21 新增LZ UID
  3500. var userIds = new List<int>() { 21 };
  3501. string title = $"系统通知";
  3502. string content = "";
  3503. var diId = dto.DiId;
  3504. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3505. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3506. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3507. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3508. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3509. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3510. #endregion
  3511. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3512. }
  3513. /// <summary>
  3514. /// 团组增减款项操作 删除
  3515. /// </summary>
  3516. /// <param name="dto"></param>
  3517. /// <returns></returns>
  3518. [HttpPost]
  3519. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3520. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3521. {
  3522. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3523. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3524. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3525. if (res.Code == 0)
  3526. {
  3527. return Ok(JsonView(true, "删除成功!"));
  3528. }
  3529. return Ok(JsonView(false, "删除失败!"));
  3530. }
  3531. /// <summary>
  3532. /// 根据团组增减款项Id查询
  3533. /// </summary>
  3534. /// <param name="dto"></param>
  3535. /// <returns></returns>
  3536. [HttpPost]
  3537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3538. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3539. {
  3540. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3541. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3542. }
  3543. /// <summary>
  3544. /// 查询供应商名称
  3545. /// </summary>
  3546. /// <param name="dto"></param>
  3547. /// <returns></returns>
  3548. [HttpPost]
  3549. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3550. {
  3551. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3552. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3553. ?? new List<Grp_DecreasePayments>();
  3554. dbResult = dbResult.Distinct(new
  3555. ProductComparer()).ToList();
  3556. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3557. {
  3558. x.Id,
  3559. x.SupplierAddress,
  3560. x.SupplierArea,
  3561. x.SupplierContact,
  3562. x.SupplierContactNumber,
  3563. x.SupplierEmail,
  3564. x.SupplierName,
  3565. x.SupplierSocialAccount,
  3566. x.SupplierTypeId,
  3567. }).ToList());
  3568. return Ok(jw);
  3569. }
  3570. /// <summary>
  3571. /// 团组增减款项 OTA匹配
  3572. /// </summary>
  3573. /// <param name="file"></param>
  3574. /// <returns></returns>
  3575. [HttpPost]
  3576. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3577. {
  3578. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3579. string fileName = file.FileName;
  3580. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3581. {
  3582. return Ok(JsonView(false, "请上传Excel文件!"));
  3583. }
  3584. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3585. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3586. if (!Directory.Exists(path))
  3587. {
  3588. Directory.CreateDirectory(path);
  3589. }
  3590. var filePath = @$"{path}/{fileName}";
  3591. //保存文件
  3592. using (FileStream fs = System.IO.File.Create(filePath))
  3593. {
  3594. file.CopyTo(fs);
  3595. fs.Flush();
  3596. }
  3597. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3598. //读取ExcelFile
  3599. DataTable dt = ConvertExcelToDataTable(filePath);
  3600. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3601. dt.TableName = "TB";
  3602. //修改table列名
  3603. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3604. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3605. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3606. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3607. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3608. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3609. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3610. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3611. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3612. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3613. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3614. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3615. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3616. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3617. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3618. var otaOrderNos = new List<string>();
  3619. foreach (DataRow item in dt.Rows)
  3620. {
  3621. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3622. }
  3623. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3624. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3625. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3626. .Select((dp, di) => new
  3627. {
  3628. dp.PriceName,
  3629. dp.OTAOrderNo,
  3630. dp.FeeTotal,
  3631. di.TeamName,
  3632. })
  3633. .ToListAsync();
  3634. foreach (DataRow item in dt.Rows)
  3635. {
  3636. var otaOrderNo = item["OTAOrderNo"].ToString();
  3637. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3638. if (oaData == null) continue;
  3639. item["GroupName"] = oaData.TeamName;
  3640. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3641. }
  3642. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3643. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3644. List<DataTable> datas = new List<DataTable>();
  3645. datas.Add(dt);
  3646. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3647. return Ok(JsonView(true, "操作成功", new { url = url }));
  3648. }
  3649. #region
  3650. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3651. {
  3652. // 创建Workbook对象
  3653. Workbook workbook = new Workbook(excelFilePath);
  3654. // 获取第一个工作表
  3655. Worksheet worksheet = workbook.Worksheets[0];
  3656. // 将工作表转换为DataTable
  3657. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3658. return dataTable;
  3659. }
  3660. #endregion
  3661. #endregion
  3662. #region 文件上传、删除
  3663. /// <summary>
  3664. /// region 文件上传 可以带参数
  3665. /// </summary>
  3666. /// <param name="file"></param>
  3667. /// <returns></returns>
  3668. [HttpPost]
  3669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3670. public async Task<IActionResult> UploadProject(IFormFile file)
  3671. {
  3672. //var TypeName = Request.Headers["TypeName"].ToString();
  3673. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3674. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3675. ////文件名称
  3676. //string projectFileName = file.FileName;
  3677. ////上传的文件的路径
  3678. //string filePath = $"{fileDir}/{projectFileName}";
  3679. //if (TypeName == "A")//A代表团组增减款项
  3680. //{
  3681. // filePath = fileDir + $@"\团组增减款项相关文件";
  3682. // if (!Directory.Exists(filePath))
  3683. // {
  3684. // Directory.CreateDirectory(filePath);
  3685. // }
  3686. // //上传的文件的路径
  3687. // filePath += $@"\{projectFileName}";
  3688. //}
  3689. //else if (TypeName == "B")//B代表商邀相关文件
  3690. //{
  3691. // //上传的文件的路径
  3692. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3693. // if (!Directory.Exists(filePath))
  3694. // {
  3695. // Directory.CreateDirectory(filePath);
  3696. // }
  3697. // //上传的文件的路径
  3698. // filePath = $@"\{projectFileName}";
  3699. //}
  3700. //try
  3701. //{
  3702. // using (FileStream fs = System.IO.File.Create(filePath))
  3703. // {
  3704. // file.CopyTo(fs);
  3705. // fs.Flush();
  3706. // }
  3707. //}
  3708. //catch (Exception ex)
  3709. //{
  3710. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3711. //}
  3712. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3713. try
  3714. {
  3715. var TypeName = Request.Headers["TypeName"].ToString();
  3716. if (file != null)
  3717. {
  3718. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3719. //文件名称
  3720. string projectFileName = file.FileName;
  3721. //上传的文件的路径
  3722. string filePath = $"{fileDir}/{projectFileName}";
  3723. if (TypeName == "A")//A代表团组增减款项
  3724. {
  3725. if (!Directory.Exists(fileDir))
  3726. {
  3727. Directory.CreateDirectory(fileDir);
  3728. }
  3729. //上传的文件的路径
  3730. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3731. }
  3732. else if (TypeName == "B")//B代表商邀相关文件
  3733. {
  3734. if (!Directory.Exists(fileDir))
  3735. {
  3736. Directory.CreateDirectory(fileDir);
  3737. }
  3738. //上传的文件的路径
  3739. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3740. }
  3741. using (FileStream fs = System.IO.File.Create(filePath))
  3742. {
  3743. file.CopyTo(fs);
  3744. fs.Flush();
  3745. }
  3746. return Ok(JsonView(true, "上传成功!", projectFileName));
  3747. }
  3748. else
  3749. {
  3750. return Ok(JsonView(false, "上传失败!"));
  3751. }
  3752. }
  3753. catch (Exception ex)
  3754. {
  3755. return Ok(JsonView(false, "程序错误!"));
  3756. }
  3757. }
  3758. /// <summary>
  3759. /// 删除指定文件
  3760. /// </summary>
  3761. /// <param name="dto"></param>
  3762. /// <returns></returns>
  3763. [HttpPost]
  3764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3765. public async Task<IActionResult> DelFile(DelFileDto dto)
  3766. {
  3767. try
  3768. {
  3769. var TypeName = Request.Headers["TypeName"].ToString();
  3770. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3771. string filePath = "";
  3772. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3773. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3774. int id = 0;
  3775. if (TypeName == "A")
  3776. {
  3777. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3778. // 删除该文件
  3779. System.IO.File.Delete(filePath);
  3780. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3781. .Where(a => a.Id == dto.Id)
  3782. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3783. .ExecuteCommandAsync();
  3784. }
  3785. else if (TypeName == "B")
  3786. {
  3787. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3788. // 删除该文件
  3789. System.IO.File.Delete(filePath);
  3790. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3791. if (info != null)
  3792. {
  3793. string[] files = new string[] { };
  3794. if (!string.IsNullOrEmpty(info.Attachment))
  3795. {
  3796. try
  3797. {
  3798. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3799. }
  3800. catch (Exception)
  3801. {
  3802. files = new List<string>() { info.Attachment }.ToArray();
  3803. }
  3804. }
  3805. if (files.Length > 0)
  3806. {
  3807. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3808. string filePath2 = string.Empty;
  3809. if (files1.Length > 0)
  3810. {
  3811. filePath2 = JsonConvert.SerializeObject(files1);
  3812. }
  3813. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3814. .Where(a => a.Id == dto.Id)
  3815. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3816. .ExecuteCommandAsync();
  3817. }
  3818. }
  3819. }
  3820. if (id != 0)
  3821. {
  3822. return Ok(JsonView(true, "成功!"));
  3823. }
  3824. else
  3825. {
  3826. return Ok(JsonView(false, "失败!"));
  3827. }
  3828. }
  3829. catch (Exception ex)
  3830. {
  3831. return Ok(JsonView(false, "程序错误!"));
  3832. throw;
  3833. }
  3834. }
  3835. /// <summary>
  3836. /// 文件上传多个文件 可以带参数
  3837. /// </summary>
  3838. /// <param name="file"></param>
  3839. /// <returns></returns>
  3840. [HttpPost]
  3841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3842. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3843. {
  3844. try
  3845. {
  3846. var TypeName = Request.Headers["TypeName"].ToString();
  3847. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3848. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3849. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3850. var filePahts = new List<string>();
  3851. foreach (var file in files)
  3852. {
  3853. //文件名称
  3854. string projectFileName = file.FileName;
  3855. //上传的文件的路径
  3856. string filePath = $"{fileDir}/{projectFileName}";
  3857. if (TypeName == "A")//A代表团组增减款项
  3858. {
  3859. if (!Directory.Exists(fileDir))
  3860. {
  3861. Directory.CreateDirectory(fileDir);
  3862. }
  3863. //上传的文件的路径
  3864. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3865. }
  3866. else if (TypeName == "B")//B代表商邀相关文件
  3867. {
  3868. if (!Directory.Exists(fileDir))
  3869. {
  3870. Directory.CreateDirectory(fileDir);
  3871. }
  3872. //上传的文件的路径
  3873. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3874. }
  3875. using (FileStream fs = System.IO.File.Create(filePath))
  3876. {
  3877. file.CopyTo(fs);
  3878. fs.Flush();
  3879. }
  3880. filePahts.Add(projectFileName);
  3881. }
  3882. return Ok(JsonView(true, "上传成功!", filePahts));
  3883. }
  3884. catch (Exception ex)
  3885. {
  3886. return Ok(JsonView(false, "程序错误!"));
  3887. }
  3888. }
  3889. #endregion
  3890. #region 商邀费用录入
  3891. /// <summary>
  3892. /// 根据团组Id查询商邀费用列表
  3893. /// </summary>
  3894. /// <param name="dto"></param>
  3895. /// <returns></returns>
  3896. [HttpPost]
  3897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3898. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3899. {
  3900. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3901. if (groupData.Code != 0)
  3902. {
  3903. return Ok(JsonView(false, groupData.Msg));
  3904. }
  3905. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3906. }
  3907. /// <summary>
  3908. /// 商邀费用列表
  3909. /// 下载文件
  3910. /// </summary>
  3911. /// <param name="dto"></param>
  3912. /// <returns></returns>
  3913. [HttpGet("{id}")]
  3914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3915. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3916. {
  3917. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3918. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3919. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3920. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3921. var filePaths = new List<string>();
  3922. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3923. try
  3924. {
  3925. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3926. }
  3927. catch (Exception ex)
  3928. {
  3929. filePaths.Add(info.Attachment);
  3930. }
  3931. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3932. for (int i = 0; i < filePaths.Count; i++)
  3933. {
  3934. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3935. }
  3936. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3937. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3938. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3939. {
  3940. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3941. {
  3942. foreach (string filePath in filePaths)
  3943. {
  3944. if (System.IO.File.Exists(filePath))
  3945. {
  3946. // 获取文件名
  3947. string fileName = Path.GetFileName(filePath);
  3948. // 将文件添加到ZIP归档中
  3949. zipArchive.CreateEntryFromFile(filePath, fileName);
  3950. }
  3951. }
  3952. }
  3953. }
  3954. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3955. }
  3956. /// <summary>
  3957. /// 商邀费用 Info Page 基础数据源
  3958. /// </summary>
  3959. /// <param name="dto"></param>
  3960. /// <returns></returns>
  3961. [HttpPost]
  3962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3963. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3964. {
  3965. try
  3966. {
  3967. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3968. if (groupData.Code != 0)
  3969. {
  3970. return Ok(JsonView(false, groupData.Msg));
  3971. }
  3972. return Ok(JsonView(true, "操作成功", groupData.Data));
  3973. }
  3974. catch (Exception ex)
  3975. {
  3976. return Ok(JsonView(false, ex.Message));
  3977. throw;
  3978. }
  3979. }
  3980. /// <summary>
  3981. /// 根据商邀费用ID查询C表和商邀费用数据
  3982. /// </summary>
  3983. /// <param name="dto"></param>
  3984. /// <returns></returns>
  3985. [HttpPost]
  3986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3987. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3988. {
  3989. try
  3990. {
  3991. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3992. if (groupData.Code != 0)
  3993. {
  3994. return Ok(JsonView(false, groupData.Msg));
  3995. }
  3996. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3997. }
  3998. catch (Exception ex)
  3999. {
  4000. return Ok(JsonView(false, ex.Message));
  4001. throw;
  4002. }
  4003. }
  4004. /// <summary>
  4005. /// 商邀费用录入操作(Status:1.新增,2.修改)
  4006. /// </summary>
  4007. /// <param name="dto"></param>
  4008. /// <returns></returns>
  4009. [HttpPost]
  4010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4011. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4012. {
  4013. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4014. if (groupData.Code != 0)
  4015. {
  4016. return Ok(JsonView(false, groupData.Msg));
  4017. }
  4018. #region 应用推送
  4019. try
  4020. {
  4021. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4022. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4023. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4024. //2024-10-21 新增LZ UID
  4025. var userIds = new List<int>() { 21 };
  4026. string title = $"系统通知";
  4027. string content = "";
  4028. var diId = dto.DiId;
  4029. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4030. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4031. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4032. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4033. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4034. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4035. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4036. }
  4037. catch (Exception ex)
  4038. {
  4039. }
  4040. #endregion
  4041. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4042. }
  4043. /// <summary>
  4044. /// 商邀删除
  4045. /// </summary>
  4046. /// <param name="dto"></param>
  4047. /// <returns></returns>
  4048. [HttpPost]
  4049. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4050. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4051. {
  4052. try
  4053. {
  4054. _sqlSugar.BeginTran();
  4055. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4056. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4057. {
  4058. IsDel = 1,
  4059. DeleteUserId = dto.DeleteUserId,
  4060. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4061. })
  4062. .Where(it => it.Id == dto.Id)
  4063. .ExecuteCommand();
  4064. if (res1 > 0)
  4065. {
  4066. int _diId = 0;
  4067. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4068. if (_ioaInfo != null)
  4069. {
  4070. _diId = _ioaInfo.DiId;
  4071. }
  4072. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4073. .SetColumns(a => new Grp_CreditCardPayment()
  4074. {
  4075. IsDel = 1,
  4076. DeleteUserId = dto.DeleteUserId,
  4077. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4078. })
  4079. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4080. .ExecuteCommand();
  4081. if (res2 > 0)
  4082. {
  4083. _sqlSugar.CommitTran();
  4084. return Ok(JsonView(true, "删除成功!"));
  4085. }
  4086. }
  4087. _sqlSugar.RollbackTran();
  4088. return Ok(JsonView(false, "删除失败"));
  4089. }
  4090. catch (Exception ex)
  4091. {
  4092. _sqlSugar.RollbackTran();
  4093. return Ok(JsonView(false, ex.Message));
  4094. }
  4095. }
  4096. /// <summary>
  4097. /// 团组模块文件上传
  4098. /// </summary>
  4099. /// <param name="dto"></param>
  4100. /// <returns></returns>
  4101. [HttpPost]
  4102. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4103. {
  4104. var jw = JsonView(false);
  4105. long M = 1024 * 1024;
  4106. if (dto.Files == null || dto.Files.Count == 0)
  4107. {
  4108. jw.Msg = "无文件信息!";
  4109. return Ok(jw);
  4110. }
  4111. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4112. {
  4113. jw.Msg = "文件大小超过20M!";
  4114. return Ok(jw);
  4115. }
  4116. //var nameSp = dto.File.FileName.Split(".");
  4117. //if (nameSp.Length < 2)
  4118. //{
  4119. // jw.Msg = "拓展名称有误!";
  4120. // return Ok(jw);
  4121. //}
  4122. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4123. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4124. //{
  4125. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4126. // return Ok(jw);
  4127. //}
  4128. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4129. if (Ctable == null)
  4130. {
  4131. jw.Msg = "Ctable指向有误!";
  4132. return Ok(jw);
  4133. }
  4134. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4135. if (groupInfo == null)
  4136. {
  4137. jw.Msg = "团组信息不存在!";
  4138. return Ok(jw);
  4139. }
  4140. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4141. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4142. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4143. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4144. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4145. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4146. try
  4147. {
  4148. if (!Directory.Exists(fileBase))
  4149. {
  4150. Directory.CreateDirectory(fileBase);
  4151. }
  4152. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4153. foreach (var fileStream in dto.Files)
  4154. {
  4155. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4156. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4157. {
  4158. Cid = dto.Cid,
  4159. CreateTime = DateTime.Now,
  4160. CreateUserId = dto.Userid,
  4161. Ctable = dto.Ctable,
  4162. Diid = dto.Diid,
  4163. IsDel = 0,
  4164. FilePath = saveFilePath,
  4165. FileName = fileStream.FileName
  4166. };
  4167. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4168. {
  4169. fileStream.CopyTo(fs);
  4170. fs.Flush();
  4171. }
  4172. saveArr.Add(file);
  4173. }
  4174. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4175. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4176. jw = JsonView(true, "保存成功!", new
  4177. {
  4178. count = addResult,
  4179. filesName = saveArr.Select(x => x.FileName)
  4180. });
  4181. }
  4182. catch (Exception ex)
  4183. {
  4184. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4185. {
  4186. count = 0,
  4187. filesName = new string[0],
  4188. });
  4189. }
  4190. return Ok(jw);
  4191. }
  4192. /// <summary>
  4193. /// 查询各模块已保存文件
  4194. /// </summary>
  4195. /// <param name="dto"></param>
  4196. /// <returns></returns>
  4197. [HttpPost]
  4198. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4199. {
  4200. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4201. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4202. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4203. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4204. {
  4205. expression = Expressionable.Create<Grp_GroupModelFile>()
  4206. .And(x => visaIds.Contains(x.CreateUserId));
  4207. }
  4208. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4209. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4210. .Where(expression.ToExpression())
  4211. .ToList();
  4212. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4213. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4214. {
  4215. x.FileName,
  4216. x.Id,
  4217. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4218. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4219. })));
  4220. }
  4221. /// <summary>
  4222. /// 下载该团组下的所有文件
  4223. /// </summary>
  4224. /// <param name="dto"></param>
  4225. /// <returns></returns>
  4226. [HttpPost]
  4227. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4228. {
  4229. var jw = JsonView(false);
  4230. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4231. if (groupInfo == null)
  4232. {
  4233. jw.Msg = "团组信息不存在!";
  4234. return Ok(jw);
  4235. }
  4236. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4237. var isModule = Convert.ToBoolean(dto.isModule);
  4238. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4239. IOOperatorHelper io = new IOOperatorHelper();
  4240. if (isModule)
  4241. {
  4242. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4243. foreach (var moduleArr in moduleGroup)
  4244. {
  4245. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4246. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4247. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4248. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4249. foreach (var item in moduleArr)
  4250. {
  4251. if (System.IO.File.Exists(item.FilePath))
  4252. {
  4253. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4254. {
  4255. byte[] bytes = new byte[fileStream.Length];
  4256. fileStream.Read(bytes, 0, bytes.Length);
  4257. fileStream.Close();
  4258. Stream stream = new MemoryStream(bytes);
  4259. chiZips.Add(item.FileName, stream);
  4260. }
  4261. }
  4262. }
  4263. if (chiZips.Count > 0)
  4264. {
  4265. var byts = io.ConvertZipStream(chiZips);
  4266. Stream stream = new MemoryStream(byts);
  4267. Zips.Add(key.Name + "_.zip", stream);
  4268. }
  4269. }
  4270. }
  4271. else
  4272. {
  4273. foreach (var item in dbQuery)
  4274. {
  4275. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4276. {
  4277. byte[] bytes = new byte[fileStream.Length];
  4278. fileStream.Read(bytes, 0, bytes.Length);
  4279. fileStream.Close();
  4280. Stream stream = new MemoryStream(bytes);
  4281. while (Zips.Keys.Contains(item.FileName))
  4282. {
  4283. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4284. }
  4285. Zips.Add(item.FileName, stream);
  4286. }
  4287. }
  4288. }
  4289. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4290. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4291. if (Zips.Count > 0)
  4292. {
  4293. var byts = io.ConvertZipStream(Zips);
  4294. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4295. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4296. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4297. }
  4298. else
  4299. {
  4300. jw.Msg = "暂无生成文件!";
  4301. }
  4302. return Ok(jw);
  4303. }
  4304. /// <summary>
  4305. /// 下载该团组下此模块的所有文件
  4306. /// </summary>
  4307. /// <param name="dto"></param>
  4308. /// <returns></returns>
  4309. [HttpPost]
  4310. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4311. {
  4312. var jw = JsonView(false);
  4313. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4314. if (groupInfo == null)
  4315. {
  4316. jw.Msg = "团组信息不存在!";
  4317. return Ok(jw);
  4318. }
  4319. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4320. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4321. && x.IsDel == 0);
  4322. if (key == null)
  4323. {
  4324. jw.Msg = "Ctable指向错误!";
  4325. return Ok(jw);
  4326. }
  4327. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4328. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4329. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4330. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4331. IOOperatorHelper io = new IOOperatorHelper();
  4332. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4333. foreach (var item in dbQuery)
  4334. {
  4335. if (System.IO.File.Exists(item.FilePath))
  4336. {
  4337. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4338. {
  4339. byte[] bytes = new byte[fileStream.Length];
  4340. fileStream.Read(bytes, 0, bytes.Length);
  4341. fileStream.Close();
  4342. Stream stream = new MemoryStream(bytes);
  4343. while (Zips.Keys.Contains(item.FileName))
  4344. {
  4345. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4346. }
  4347. Zips.Add(item.FileName, stream);
  4348. }
  4349. }
  4350. }
  4351. if (Zips.Count > 0)
  4352. {
  4353. var byts = io.ConvertZipStream(Zips);
  4354. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4355. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4356. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4357. }
  4358. else
  4359. {
  4360. jw.Msg = "暂无生成文件!";
  4361. }
  4362. return Ok(jw);
  4363. }
  4364. /// <summary>
  4365. /// 删除该团组下的指定文件
  4366. /// </summary>
  4367. /// <param name="dto"></param>
  4368. /// <returns></returns>
  4369. [HttpPost]
  4370. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4371. {
  4372. var jw = JsonView(false);
  4373. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4374. if (sing == null)
  4375. {
  4376. jw.Msg = "暂无";
  4377. return Ok(jw);
  4378. }
  4379. if (System.IO.File.Exists(sing.FilePath))
  4380. {
  4381. try
  4382. {
  4383. System.IO.File.Delete(sing.FilePath);
  4384. }
  4385. catch (Exception ex)
  4386. {
  4387. jw.Msg = "删除失败!" + ex.Message;
  4388. return Ok(jw);
  4389. }
  4390. }
  4391. sing.IsDel = 1;
  4392. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4393. sing.DeleteUserId = dto.UserId;
  4394. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4395. jw = JsonView(true, "删除成功!");
  4396. return Ok(jw);
  4397. }
  4398. #endregion
  4399. #region 团组英文资料
  4400. /// <summary>
  4401. /// 查询团组英文所有资料
  4402. /// </summary>
  4403. /// <param name="dto"></param>
  4404. /// <returns></returns>
  4405. [HttpPost]
  4406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4407. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4408. {
  4409. try
  4410. {
  4411. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4412. if (groupData.Code != 0)
  4413. {
  4414. return Ok(JsonView(false, groupData.Msg));
  4415. }
  4416. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4417. }
  4418. catch (Exception ex)
  4419. {
  4420. return Ok(JsonView(false, "程序错误!"));
  4421. throw;
  4422. }
  4423. }
  4424. /// <summary>
  4425. /// 团组英文资料操作(Status:1.新增,2.修改)
  4426. /// </summary>
  4427. /// <param name="dto"></param>
  4428. /// <returns></returns>
  4429. [HttpPost]
  4430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4431. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4432. {
  4433. try
  4434. {
  4435. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4436. if (groupData.Code != 0)
  4437. {
  4438. return Ok(JsonView(false, groupData.Msg));
  4439. }
  4440. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4441. }
  4442. catch (Exception ex)
  4443. {
  4444. return Ok(JsonView(false, "程序错误!"));
  4445. throw;
  4446. }
  4447. }
  4448. /// <summary>
  4449. /// 团组英文资料Id查询数据
  4450. /// </summary>
  4451. /// <param name="dto"></param>
  4452. /// <returns></returns>
  4453. [HttpPost]
  4454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4455. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4456. {
  4457. try
  4458. {
  4459. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4460. if (_DelegationEnData != null)
  4461. {
  4462. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4463. }
  4464. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4465. }
  4466. catch (Exception ex)
  4467. {
  4468. return Ok(JsonView(false, "程序错误!"));
  4469. throw;
  4470. }
  4471. }
  4472. /// <summary>
  4473. /// 团组英文资料删除
  4474. /// </summary>
  4475. /// <param name="dto"></param>
  4476. /// <returns></returns>
  4477. [HttpPost]
  4478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4479. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4480. {
  4481. try
  4482. {
  4483. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4484. if (!res)
  4485. {
  4486. return Ok(JsonView(false, "删除失败"));
  4487. }
  4488. return Ok(JsonView(true, "删除成功!"));
  4489. }
  4490. catch (Exception ex)
  4491. {
  4492. return Ok(JsonView(false, "程序错误!"));
  4493. throw;
  4494. }
  4495. }
  4496. #endregion
  4497. #region 导出邀请函
  4498. /// <summary>
  4499. /// 导出邀请函页面初始化
  4500. /// </summary>
  4501. /// <param name="dto"></param>
  4502. /// <returns></returns>
  4503. [HttpPost]
  4504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4505. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4506. {
  4507. try
  4508. {
  4509. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4510. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4511. if (dto.DiId == 0)
  4512. {
  4513. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4514. }
  4515. else
  4516. {
  4517. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4518. }
  4519. return Ok(JsonView(true, "查询成功!", new
  4520. {
  4521. deleClient = crm_Deles,
  4522. delegations = grp_Delegations
  4523. }));
  4524. }
  4525. catch (Exception ex)
  4526. {
  4527. return Ok(JsonView(false, "程序错误!"));
  4528. throw;
  4529. }
  4530. }
  4531. /// <summary>
  4532. /// 导出邀请函
  4533. /// </summary>
  4534. /// <param name="dto"></param>
  4535. /// <returns></returns>
  4536. [HttpPost]
  4537. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4538. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4539. {
  4540. #region 参数验证
  4541. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4542. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4543. #endregion
  4544. try
  4545. {
  4546. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4547. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4548. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4549. From Grp_TourClientList tcl
  4550. Left Join
  4551. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4552. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4553. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4554. From Crm_DeleClient dc
  4555. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4556. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4557. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4558. Where dc.IsDel = 0) temp
  4559. On temp.DcId =tcl.ClientId
  4560. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4561. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4562. List<string> texts = new List<string>();
  4563. if (datas.Count != 0)
  4564. {
  4565. foreach (TourClientListDetailsView item in datas)
  4566. {
  4567. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4568. {
  4569. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4570. }
  4571. else
  4572. {
  4573. string name = item.LastName + item.FirstName;
  4574. texts.Add(name);
  4575. }
  4576. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4577. {
  4578. if (!transDic.ContainsKey(item.Job))
  4579. {
  4580. texts.Add(item.Job);
  4581. }
  4582. }
  4583. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4584. {
  4585. texts.Add(item.CompanyFullName);
  4586. }
  4587. }
  4588. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4589. if (transData.Count > 0)
  4590. {
  4591. foreach (TranslateResult item in transData)
  4592. {
  4593. if (!transDic.ContainsKey(item.Query))
  4594. {
  4595. transDic.Add(item.Query, item.Translation);
  4596. }
  4597. }
  4598. }
  4599. List<GuestList> list = new List<GuestList>();
  4600. foreach (TourClientListDetailsView dele in datas)
  4601. {
  4602. GuestList guestList = new GuestList();
  4603. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4604. {
  4605. guestList.Name = dele.Pinyin;
  4606. }
  4607. else
  4608. {
  4609. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4610. guestList.Name = Name;
  4611. }
  4612. if (dele.Sex == 0)
  4613. {
  4614. guestList.Sex = "Male";
  4615. }
  4616. else if (dele.Sex == 1)
  4617. {
  4618. guestList.Sex = "Female";
  4619. }
  4620. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4621. if (!string.IsNullOrEmpty(dele.Job))
  4622. {
  4623. guestList.Job = dele.Job;
  4624. }
  4625. list.Add(guestList);
  4626. }
  4627. //载入模板
  4628. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4629. DocumentBuilder builder = new DocumentBuilder(doc);
  4630. //获取word里所有表格
  4631. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4632. //获取所填表格的序数
  4633. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4634. var rowStart = tableOne.Rows[0]; //获取第1行
  4635. //循环赋值
  4636. for (int i = 0; i < list.Count; i++)
  4637. {
  4638. builder.MoveToCell(0, i + 1, 0, 0);
  4639. builder.Write(list[i].Name.ToString());
  4640. builder.MoveToCell(0, i + 1, 1, 0);
  4641. builder.Write(list[i].Sex.ToString());
  4642. builder.MoveToCell(0, i + 1, 2, 0);
  4643. builder.Write(list[i].DOB.ToString());
  4644. builder.MoveToCell(0, i + 1, 3, 0);
  4645. builder.Write(list[i].Job.ToString());
  4646. }
  4647. //删除多余行
  4648. while (tableOne.Rows.Count > list.Count + 1)
  4649. {
  4650. tableOne.Rows.RemoveAt(list.Count + 1);
  4651. }
  4652. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4653. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4654. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4655. doc.Save(filePath);
  4656. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4657. return Ok(JsonView(true, "操作成功!", Url));
  4658. }
  4659. else
  4660. {
  4661. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4662. }
  4663. }
  4664. catch (Exception ex)
  4665. {
  4666. return Ok(JsonView(false, ex.Message));
  4667. throw;
  4668. }
  4669. }
  4670. #endregion
  4671. #region 团组经理模块 出入境费用
  4672. /// <summary>
  4673. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4674. /// </summary>
  4675. /// <returns></returns>
  4676. [HttpPost]
  4677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4678. public async Task<IActionResult> SetDayAndCostAreaChange()
  4679. {
  4680. try
  4681. {
  4682. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4683. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4684. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4685. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4686. foreach (var item in unite) //处理交集数据
  4687. {
  4688. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4689. }
  4690. foreach (var item in merge) //处理差集数据
  4691. {
  4692. int nationalTravelFeeId = 0;
  4693. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4694. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4695. else
  4696. {
  4697. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4698. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4699. }
  4700. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4701. }
  4702. //只更新dayAndCost 的 nationalTravelFeeId;
  4703. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4704. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4705. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4706. }
  4707. catch (Exception ex)
  4708. {
  4709. return Ok(JsonView(false, ex.Message));
  4710. throw;
  4711. }
  4712. }
  4713. /// <summary>
  4714. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4715. /// </summary>
  4716. /// <returns></returns>
  4717. [HttpPost]
  4718. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4719. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4720. {
  4721. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4722. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4723. //SetDataInfoView
  4724. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4725. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4726. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4727. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4728. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4729. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4730. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4731. //默认币种显示
  4732. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4733. {
  4734. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4735. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4736. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4737. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4738. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4739. };
  4740. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4741. if (_currencyRate.Count > 0)
  4742. {
  4743. foreach (var item in _currencyInfos)
  4744. {
  4745. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4746. if (rateInfo != null)
  4747. {
  4748. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4749. rate1 *= 1.035M;
  4750. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4751. }
  4752. }
  4753. }
  4754. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4755. return Ok(JsonView(true, "查询成功!", new
  4756. {
  4757. GroupNameData = groupNameData.Data,
  4758. CurrencyData = _CurrencyData,
  4759. WordTypeData = _WordTypeData,
  4760. ExcelTypeData = _ExcelTypeData,
  4761. CurrencyInit = _currencyInfos,
  4762. ViewPermissionData = viewPermissionData
  4763. }));
  4764. }
  4765. /// <summary>
  4766. /// 团组模块 - 出入境费用
  4767. /// 实时汇率 tips
  4768. /// 签证费用 tips
  4769. /// 机票费用 tips
  4770. /// </summary>
  4771. /// <returns></returns>
  4772. [HttpPost]
  4773. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4774. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4775. {
  4776. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4777. //默认币种显示
  4778. var _currencyInfos = _currencyInit;
  4779. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4780. List<dynamic> reteInfos = new List<dynamic>();
  4781. if (_currencyRate.Count > 0)
  4782. {
  4783. foreach (var item in _currencyInfos)
  4784. {
  4785. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4786. if (rateInfo != null)
  4787. {
  4788. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4789. decimal rate1 = item.Rate;
  4790. rate1 *= 1.03M;
  4791. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4792. reteInfos.Add(new
  4793. {
  4794. currCode = item.CurrencyCode,
  4795. currName = item.CurrencyName,
  4796. rate = rate2,
  4797. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4798. });
  4799. }
  4800. }
  4801. }
  4802. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4803. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4804. return Ok(JsonView(true, "查询成功!", new
  4805. {
  4806. //GroupNameData = groupNameData.Data,
  4807. visaData = visaData.Data,
  4808. airData = airData.Data,
  4809. reteInfos = reteInfos
  4810. }));
  4811. }
  4812. /// <summary>
  4813. /// 团组模块 - 出入境费用 - Info
  4814. /// </summary>
  4815. /// <returns></returns>
  4816. [HttpPost]
  4817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4818. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4819. {
  4820. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4821. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4822. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4823. }
  4824. /// <summary>
  4825. /// 团组模块 - 出入境费用 - 设置view权限
  4826. /// </summary>
  4827. /// <returns></returns>
  4828. [HttpPost]
  4829. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4830. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4831. {
  4832. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4833. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4834. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4835. var permissions = new List<Grp_EnterExitCostPermission>();
  4836. foreach (var userId in dto.UserIds)
  4837. {
  4838. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4839. }
  4840. if (permissions.Any())
  4841. {
  4842. _sqlSugar.BeginTran();
  4843. try
  4844. {
  4845. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4846. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4847. if (result < 1)
  4848. {
  4849. _sqlSugar.RollbackTran();
  4850. return Ok(JsonView(false));
  4851. }
  4852. }
  4853. catch (Exception ex)
  4854. {
  4855. _sqlSugar.RollbackTran();
  4856. return Ok(JsonView(false, ex.Message));
  4857. }
  4858. _sqlSugar.CommitTran();
  4859. return Ok(JsonView(true));
  4860. }
  4861. return Ok(JsonView(false));
  4862. }
  4863. /// <summary>
  4864. /// 团组模块 - 出入境费用 - Add And Update
  4865. /// </summary>
  4866. /// <returns></returns>
  4867. [HttpPost]
  4868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4869. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4870. {
  4871. try
  4872. {
  4873. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4874. if (dto.DayOtherPriceData.Any())
  4875. {
  4876. var inserList = dto.DayOtherPriceData
  4877. .Where(x => x.Id == 0)
  4878. .Select(x => new Grp_DayOtherPrice
  4879. {
  4880. Cost = x.Cost,
  4881. Id = x.Id,
  4882. CreateTime = DateTime.Now,
  4883. CreateUserId = dto.UserId,
  4884. Currency = x.Currency,
  4885. Diid = x.DiId,
  4886. Index = x.Index,
  4887. IsDel = 0,
  4888. SetDataId = x.SetDataId,
  4889. SubTotal = x.SubTotal,
  4890. Remark = x.Remark
  4891. })
  4892. .ToList();
  4893. var updateList = dto.DayOtherPriceData
  4894. .Where(x => x.Id != 0)
  4895. .Select(x => new Grp_DayOtherPrice
  4896. {
  4897. Cost = x.Cost,
  4898. Id = x.Id,
  4899. CreateTime = DateTime.Now,
  4900. CreateUserId = dto.UserId,
  4901. Currency = x.Currency,
  4902. Diid = x.DiId,
  4903. Index = x.Index,
  4904. IsDel = 0,
  4905. SetDataId = x.SetDataId,
  4906. SubTotal = x.SubTotal,
  4907. Remark = x.Remark
  4908. })
  4909. .ToList();
  4910. //添加
  4911. _sqlSugar.BeginTran();
  4912. if (inserList.Any())
  4913. {
  4914. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4915. }
  4916. if (updateList.Any())
  4917. {
  4918. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4919. }
  4920. _sqlSugar.CommitTran();
  4921. }
  4922. if (data.Code != 0)
  4923. {
  4924. return Ok(JsonView(false, data.Msg));
  4925. }
  4926. //生成默认文件pdf并且通知人员
  4927. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4928. {
  4929. DiId = dto.DiId,
  4930. ExportType = 1,
  4931. SubTypeId = 1005
  4932. }, "pdf");
  4933. //发送通知
  4934. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4935. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4936. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4937. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4938. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4939. //汇率信息记录
  4940. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4941. return Ok(JsonView(true, data.Msg, data.Data));
  4942. }
  4943. catch (Exception ex)
  4944. {
  4945. return Ok(JsonView(false, ex.Message));
  4946. }
  4947. }
  4948. /// <summary>
  4949. /// 团组模块 - 出入境费用 - Confirm 费用
  4950. /// </summary>
  4951. /// <returns></returns>
  4952. [HttpPost]
  4953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4954. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4955. {
  4956. //TODO:测试完毕需把对应的用户ID更改
  4957. //1、数据表添加字段
  4958. //2、更改字段接口()
  4959. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4960. //3、确认成功 给财务发送消息
  4961. if (_view.Code == 200)
  4962. {
  4963. if (dto.Type == 1)
  4964. {
  4965. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4966. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4967. }
  4968. }
  4969. return Ok(_view);
  4970. }
  4971. /// <summary>
  4972. /// 团组模块 - 出入境费用 - File download
  4973. /// </summary>
  4974. /// <param name="dto"></param>
  4975. /// <returns></returns>
  4976. [HttpPost]
  4977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4978. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4979. {
  4980. try
  4981. {
  4982. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4983. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4984. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4985. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4986. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4987. 3 团组成员名单 1 团组成员名单", ""));
  4988. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4989. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4990. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4991. //数据源
  4992. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4993. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4994. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4995. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4996. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4997. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4998. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4999. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  5000. .Select((x, a, b) => new
  5001. {
  5002. x.Index,
  5003. itemName = a.Name,
  5004. CurrencyStr = b.Name,
  5005. x.Cost,
  5006. x.SubTotal,
  5007. x.Remark
  5008. })
  5009. .OrderBy((x) => x.Index)
  5010. .ToList(); //其他款项费用
  5011. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5012. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5013. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5014. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5015. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5016. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5017. .Select((tcl, dc, cc) => new ClientInfo
  5018. {
  5019. LastName = dc.LastName,
  5020. FirstName = dc.FirstName,
  5021. Sex = dc.Sex,
  5022. Birthday = dc.BirthDay,
  5023. Company = cc.CompanyFullName,
  5024. Job = dc.Job
  5025. })
  5026. .ToList();
  5027. foreach (var item in DeleClientList)
  5028. {
  5029. EncryptionProcessor.DecryptProperties(item);
  5030. }
  5031. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5032. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5033. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5034. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5035. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5036. if (dto.ExportType == 1) //明细表
  5037. {
  5038. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5039. {
  5040. //获取模板
  5041. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5042. //载入模板
  5043. Document doc = new Document(tempPath);
  5044. DocumentBuilder builder = new DocumentBuilder(doc);
  5045. //利用键值对存放数据
  5046. Dictionary<string, string> dic = new Dictionary<string, string>();
  5047. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5048. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5049. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5050. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5051. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5052. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5053. //境内费用(其他费用)
  5054. if (_EnterExitCosts.ChoiceOne == 1)
  5055. {
  5056. string row1_1 = "";
  5057. if (_EnterExitCosts.Visa > 0)
  5058. {
  5059. //insidePayTotal += _EnterExitCosts.Visa;
  5060. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5061. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5062. {
  5063. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5064. }
  5065. }
  5066. string row1_2 = "";
  5067. if (_EnterExitCosts.YiMiao > 0)
  5068. {
  5069. //insidePayTotal += _EnterExitCosts.YiMiao;
  5070. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5071. }
  5072. if (_EnterExitCosts.HeSuan > 0)
  5073. {
  5074. //insidePayTotal += _EnterExitCosts.HeSuan;
  5075. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5076. }
  5077. if (_EnterExitCosts.Service > 0)
  5078. {
  5079. //insidePayTotal += _EnterExitCosts.Service;
  5080. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5081. }
  5082. string row1_3 = "";
  5083. if (_EnterExitCosts.Safe > 0)
  5084. {
  5085. //insidePayTotal += _EnterExitCosts.Safe;
  5086. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5087. }
  5088. if (_EnterExitCosts.Ticket > 0)
  5089. {
  5090. //insidePayTotal += _EnterExitCosts.Ticket;
  5091. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5092. }
  5093. string row1 = "";
  5094. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5095. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5096. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5097. row1 += $"备注:{_EnterExitCosts.Remark}";
  5098. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5099. dic.Add("Row1Str", row1);
  5100. }
  5101. string airTotalStr = string.Empty,
  5102. airPriceStr = string.Empty;
  5103. //经济舱
  5104. if (_EnterExitCosts.SumJJC == 1)
  5105. {
  5106. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5107. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5108. }
  5109. //公务舱
  5110. if (_EnterExitCosts.SumGWC == 1)
  5111. {
  5112. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5113. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5114. }
  5115. //头等舱
  5116. if (_EnterExitCosts.SumTDC == 1)
  5117. {
  5118. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5119. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5120. }
  5121. string twoItemRemark = "备注:";
  5122. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5123. {
  5124. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5125. }
  5126. dic.Add("AirTotalStr", airTotalStr);
  5127. dic.Add("AirPriceStr", airPriceStr);
  5128. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5129. dic.Add("TwoItemRemark", twoItemRemark);
  5130. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5131. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5132. int table1Row = 0,
  5133. table2Row = 0,
  5134. table3Row = 0,
  5135. table4Row = 0,
  5136. table5Row = 0;
  5137. //住宿费
  5138. if (_EnterExitCosts.ChoiceThree == 1)
  5139. {
  5140. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5141. table1Row = dac1.Count;
  5142. #region 填充word表格内容
  5143. for (int i = 0; i < dac1.Count; i++)
  5144. {
  5145. Grp_DayAndCost dac = dac1[i];
  5146. if (dac == null) continue;
  5147. builder.MoveToCell(0, i, 0, 0);
  5148. builder.Write("第" + dac.Days.ToString() + "晚:");
  5149. builder.MoveToCell(0, i, 1, 0);
  5150. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5151. //builder.Write(dac.Place == null ? "" : dac.Place);
  5152. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5153. builder.MoveToCell(0, i, 2, 0);
  5154. builder.Write("费用标准:");
  5155. string curr = "";
  5156. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5157. if (currData != null)
  5158. {
  5159. curr = currData.Name;
  5160. }
  5161. builder.MoveToCell(0, i, 3, 0);
  5162. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5163. builder.MoveToCell(0, i, 4, 0);
  5164. builder.Write("费用小计:");
  5165. builder.MoveToCell(0, i, 5, 0);
  5166. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5167. }
  5168. #endregion
  5169. }
  5170. else dic.Add("SubZS", "0.00");
  5171. //删除多余行
  5172. while (table1.Rows.Count > table1Row)
  5173. {
  5174. table1.Rows.RemoveAt(table1Row);
  5175. }
  5176. //伙食费
  5177. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5178. if (_EnterExitCosts.ChoiceFour == 1)
  5179. {
  5180. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5181. table2Row = dac2.Count;
  5182. #region 填充word表格内容
  5183. for (int i = 0; i < dac2.Count; i++)
  5184. {
  5185. Grp_DayAndCost dac = dac2[i];
  5186. if (dac == null) continue;
  5187. builder.MoveToCell(1, i, 0, 0);
  5188. builder.Write("第" + dac.Days.ToString() + "天:");
  5189. builder.MoveToCell(1, i, 1, 0);
  5190. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5191. builder.MoveToCell(1, i, 2, 0);
  5192. builder.Write("费用标准:");
  5193. string curr = "";
  5194. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5195. if (currData != null)
  5196. {
  5197. curr = currData.Name;
  5198. }
  5199. builder.MoveToCell(1, i, 3, 0);
  5200. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5201. builder.MoveToCell(1, i, 4, 0);
  5202. builder.Write("费用小计:");
  5203. builder.MoveToCell(1, i, 5, 0);
  5204. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5205. }
  5206. #endregion
  5207. }
  5208. else dic.Add("SubHS", "0.00");
  5209. //删除多余行
  5210. while (table2.Rows.Count > table2Row)
  5211. {
  5212. table2.Rows.RemoveAt(table2Row);
  5213. }
  5214. //公杂费
  5215. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5216. if (_EnterExitCosts.ChoiceFive == 1)
  5217. {
  5218. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5219. table3Row = dac3.Count;
  5220. #region 填充word表格内容
  5221. for (int i = 0; i < dac3.Count; i++)
  5222. {
  5223. Grp_DayAndCost dac = dac3[i];
  5224. if (dac == null) continue;
  5225. builder.MoveToCell(2, i, 0, 0);
  5226. builder.Write("第" + dac.Days.ToString() + "天:");
  5227. builder.MoveToCell(2, i, 1, 0);
  5228. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5229. builder.MoveToCell(2, i, 2, 0);
  5230. builder.Write("费用标准:");
  5231. string curr = "";
  5232. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5233. if (currData != null)
  5234. {
  5235. curr = currData.Name;
  5236. }
  5237. builder.MoveToCell(2, i, 3, 0);
  5238. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5239. builder.MoveToCell(2, i, 4, 0);
  5240. builder.Write("费用小计:");
  5241. builder.MoveToCell(2, i, 5, 0);
  5242. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5243. }
  5244. //删除多余行
  5245. while (table3.Rows.Count > table3Row)
  5246. {
  5247. table3.Rows.RemoveAt(table3Row);
  5248. }
  5249. #endregion
  5250. }
  5251. else dic.Add("SubGZF", "0.00");
  5252. //删除多余行
  5253. while (table3.Rows.Count > table3Row)
  5254. {
  5255. table3.Rows.RemoveAt(table3Row);
  5256. }
  5257. //培训费
  5258. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5259. if (_EnterExitCosts.ChoiceSix == 1)
  5260. {
  5261. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5262. dic.Add("SubPX", pxStr);
  5263. table4Row = dac4.Count;
  5264. #region 填充word表格内容
  5265. for (int i = 0; i < dac4.Count; i++)
  5266. {
  5267. Grp_DayAndCost dac = dac4[i];
  5268. if (dac == null) continue;
  5269. builder.MoveToCell(3, i, 0, 0);
  5270. builder.Write("第" + dac.Days.ToString() + "天:");
  5271. builder.MoveToCell(3, i, 1, 0);
  5272. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5273. builder.MoveToCell(3, i, 2, 0);
  5274. builder.Write("费用标准:");
  5275. string curr = "";
  5276. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5277. if (currData != null)
  5278. {
  5279. curr = currData.Name;
  5280. }
  5281. builder.MoveToCell(3, i, 3, 0);
  5282. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5283. builder.MoveToCell(3, i, 4, 0);
  5284. builder.Write("费用小计:");
  5285. builder.MoveToCell(3, i, 5, 0);
  5286. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5287. }
  5288. #endregion
  5289. }
  5290. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5291. //删除多余行
  5292. while (table4.Rows.Count > table4Row)
  5293. {
  5294. table4.Rows.RemoveAt(table4Row);
  5295. }
  5296. //其他费用
  5297. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5298. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5299. {
  5300. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5301. dic.Add("titleQi", qtStr);
  5302. table5Row = dac5.Count;
  5303. #region 填充word表格内容
  5304. for (int i = 0; i < dac5.Count; i++)
  5305. {
  5306. var dac = dac5[i];
  5307. if (dac == null) continue;
  5308. builder.MoveToCell(4, i, 0, 0);
  5309. builder.Write("第" + dac.Index.ToString() + "项:");
  5310. builder.MoveToCell(4, i, 1, 0);
  5311. builder.Write(dac.itemName);
  5312. builder.MoveToCell(4, i, 2, 0);
  5313. builder.Write("费用标准:");
  5314. builder.MoveToCell(4, i, 3, 0);
  5315. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5316. builder.MoveToCell(4, i, 4, 0);
  5317. builder.Write("费用小计:");
  5318. builder.MoveToCell(4, i, 5, 0);
  5319. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5320. builder.MoveToCell(4, i, 6, 0);
  5321. builder.Write("备注:");
  5322. builder.MoveToCell(4, i, 7, 0);
  5323. builder.Write(dac.Remark);
  5324. }
  5325. #endregion
  5326. }
  5327. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5328. //删除多余行
  5329. while (table5.Rows.Count > table5Row)
  5330. {
  5331. table5.Rows.RemoveAt(table5Row);
  5332. }
  5333. //加上其他费用
  5334. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5335. decimal subJJC = 0.00M,
  5336. subGWC = 0.00M,
  5337. subTDC = 0.00M;
  5338. //经济舱
  5339. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5340. //公务舱
  5341. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5342. //头等舱
  5343. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5344. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5345. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5346. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5347. #region 填充word模板书签内容
  5348. foreach (var key in dic.Keys)
  5349. {
  5350. Bookmark bookmark = doc.Range.Bookmarks[key];
  5351. if (bookmark != null)
  5352. {
  5353. builder.MoveToBookmark(key);
  5354. builder.Write(dic[key]);
  5355. }
  5356. }
  5357. #endregion
  5358. #region 设置页眉
  5359. string userLabel = string.Empty;
  5360. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5361. if (currUserInfo != null)
  5362. {
  5363. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5364. if (userInfo != null)
  5365. {
  5366. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5367. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5368. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5369. }
  5370. }
  5371. //设置页脚
  5372. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5373. #endregion
  5374. //文件名
  5375. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5376. AsposeHelper.removewatermark_v2180();
  5377. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5378. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5379. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5380. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5381. }
  5382. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5383. {
  5384. //获取模板
  5385. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5386. //载入模板
  5387. Document doc = new Document(tempPath);
  5388. DocumentBuilder builder = new DocumentBuilder(doc);
  5389. Dictionary<string, string> dic = new Dictionary<string, string>();
  5390. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5391. {
  5392. List<string> list = new List<string>();
  5393. try
  5394. {
  5395. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5396. foreach (var item in spilitArr)
  5397. {
  5398. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5399. var depCode = spDotandEmpty[2].Substring(0, 3);
  5400. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5401. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5402. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5403. list.Add(depName);
  5404. list.Add(arrName);
  5405. }
  5406. list = list.Distinct().ToList();
  5407. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5408. }
  5409. catch (Exception)
  5410. {
  5411. dic.Add("ReturnCode", "行程录入不正确!");
  5412. }
  5413. }
  5414. else
  5415. {
  5416. dic.Add("ReturnCode", "未录入行程!");
  5417. }
  5418. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5419. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5420. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5421. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5422. {
  5423. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5424. dic.Add("Day", sp.Days.ToString());
  5425. }
  5426. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5427. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5428. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5429. //dic.Add("Names", Names);
  5430. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5431. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5432. decimal dac1totalPrice = 0.00M;
  5433. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5434. foreach (var dac in dac1)
  5435. {
  5436. if (dac.SubTotal == 0.00M)
  5437. {
  5438. continue;
  5439. }
  5440. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5441. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5442. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5443. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5444. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5445. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5446. builder.Write(currency);//币种
  5447. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5448. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5449. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5450. builder.Write("");//人数
  5451. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5452. builder.Write("");//天数
  5453. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5454. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5455. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5456. decimal rate = 0.00M;
  5457. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5458. builder.Write(rate.ToString("#0.0000"));//汇率
  5459. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5460. decimal rbmPrice = dac.SubTotal;
  5461. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5462. accommodationStartIndex++;
  5463. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5464. }
  5465. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5466. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5467. {
  5468. table1.Rows.RemoveAt(i - 1);
  5469. foodandotherStartIndex--;
  5470. }
  5471. if (dac2.Count == dac3.Count)//国家 币种 金额
  5472. {
  5473. for (int i = 0; i < dac2.Count; i++)
  5474. {
  5475. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5476. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5477. }
  5478. }
  5479. decimal dac2totalPrice = 0.00M;
  5480. foreach (var dac in dac2)
  5481. {
  5482. if (dac.SubTotal == 0)
  5483. {
  5484. continue;
  5485. }
  5486. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5487. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5488. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5489. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5490. builder.Write(currency);//币种
  5491. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5492. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5493. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5494. builder.Write("");//人数
  5495. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5496. builder.Write("");//天数
  5497. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5498. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5499. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5500. decimal rate = 0.00M;
  5501. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5502. builder.Write(rate.ToString("#0.0000"));//汇率
  5503. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5504. decimal rbmPrice = dac.SubTotal;
  5505. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5506. foodandotherStartIndex++;
  5507. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5508. }
  5509. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5510. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5511. {
  5512. table1.Rows.RemoveAt(i - 1);
  5513. }
  5514. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5515. string otherFeeStr = "";
  5516. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5517. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5518. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5519. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5520. foreach (var otherInfo in dac5)
  5521. {
  5522. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5523. }
  5524. #endregion
  5525. if (otherFeeStr.Length > 0)
  5526. {
  5527. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5528. otherFeeStr = $"({otherFeeStr})";
  5529. dic.Add("OtherFeeStr", otherFeeStr);
  5530. }
  5531. //总计
  5532. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5533. //国际旅费
  5534. string outsideAir = string.Empty;
  5535. string allPriceAir = string.Empty;
  5536. if (_EnterExitCosts.SumJJC == 1)
  5537. {
  5538. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5539. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5540. }
  5541. if (_EnterExitCosts.SumGWC == 1)
  5542. {
  5543. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5544. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5545. }
  5546. if (_EnterExitCosts.SumTDC == 1)
  5547. {
  5548. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5549. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5550. }
  5551. dic.Add("InTravelPrice", $"({outsideAir})");
  5552. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5553. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5554. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5555. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5556. foreach (var key in dic.Keys)
  5557. {
  5558. builder.MoveToBookmark(key);
  5559. builder.Write(dic[key]);
  5560. }
  5561. //模板文件名
  5562. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5563. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5564. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5565. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5566. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5567. }
  5568. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5569. {
  5570. //获取模板
  5571. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5572. //载入模板
  5573. WorkbookDesigner designer = new WorkbookDesigner();
  5574. designer.Workbook = new Workbook(tempPath);
  5575. Dictionary<string, string> dic = new Dictionary<string, string>();
  5576. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5577. {
  5578. List<string> list = new List<string>();
  5579. try
  5580. {
  5581. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5582. foreach (var item in spilitArr)
  5583. {
  5584. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5585. var depCode = spDotandEmpty[2].Substring(0, 3);
  5586. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5587. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5588. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5589. list.Add(depName);
  5590. list.Add(arrName);
  5591. }
  5592. list = list.Distinct().ToList();
  5593. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5594. }
  5595. catch (Exception)
  5596. {
  5597. dic.Add("ReturnCode", "行程录入不正确!");
  5598. }
  5599. }
  5600. else
  5601. {
  5602. dic.Add("ReturnCode", "未录入行程!");
  5603. }
  5604. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5605. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5606. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5607. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5608. {
  5609. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5610. dic.Add("Day", sp.Days.ToString());
  5611. }
  5612. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5613. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5614. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5615. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5616. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5617. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5618. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5619. designer.SetDataSource("Name", Names);
  5620. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5621. designer.SetDataSource("Day", dic["Day"] + "天");
  5622. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5623. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5624. int startIndex = 10;
  5625. const int startIndexcopy = 10;
  5626. if (dac2.Count == dac3.Count)//国家 币种 金额
  5627. {
  5628. for (int i = 0; i < dac2.Count; i++)
  5629. {
  5630. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5631. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5632. }
  5633. }
  5634. DataTable dtdac1 = new DataTable();
  5635. List<string> place = new List<string>();
  5636. dtdac1.Columns.AddRange(new DataColumn[] {
  5637. new DataColumn(){ ColumnName = "city"},
  5638. new DataColumn(){ ColumnName = "curr"},
  5639. new DataColumn(){ ColumnName = "criterion"},
  5640. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5641. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5642. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5643. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5644. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5645. });
  5646. DataTable dtdac2 = new DataTable();
  5647. dtdac2.Columns.AddRange(new DataColumn[] {
  5648. new DataColumn(){ ColumnName = "city"},
  5649. new DataColumn(){ ColumnName = "curr"},
  5650. new DataColumn(){ ColumnName = "criterion"},
  5651. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5652. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5653. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5654. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5655. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5656. });
  5657. dtdac1.TableName = "tb1";
  5658. dtdac2.TableName = "tb2";
  5659. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5660. foreach (var item in dac1)
  5661. {
  5662. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5663. if (place.Contains(item.Place))
  5664. {
  5665. continue;
  5666. }
  5667. DataRow row = dtdac1.NewRow();
  5668. row["city"] = item.Place;
  5669. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5670. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5671. row["curr"] = currency;
  5672. row["rate"] = rate.ToString("#0.0000");
  5673. row["criterion"] = item.Cost.ToString("#0.00");
  5674. row["number"] = 1;
  5675. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5676. //row["costRMB"] = rbmPrice;
  5677. dtdac1.Rows.Add(row);
  5678. place.Add(item.Place);
  5679. }
  5680. place = new List<string>();
  5681. foreach (var item in dac2)
  5682. {
  5683. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5684. if (place.Contains(item.Place))
  5685. {
  5686. continue;
  5687. }
  5688. DataRow row = dtdac2.NewRow();
  5689. row["city"] = item.Place;
  5690. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5691. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5692. row["curr"] = currency;
  5693. row["rate"] = rate.ToString("#0.0000");
  5694. row["criterion"] = item.Cost.ToString("#0.00");
  5695. row["number"] = 1;
  5696. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5697. //row["cost"] = item.SubTotal;
  5698. //row["costRMB"] = rbmPrice;
  5699. dtdac2.Rows.Add(row);
  5700. place.Add(item.Place);
  5701. //dac2totalPrice += rbmPrice;
  5702. }
  5703. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5704. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5705. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5706. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5707. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5708. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5709. string cell4Str1 = string.Empty;
  5710. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5711. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5712. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5713. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5714. string cellStr = $" 5.其他费用(";
  5715. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5716. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5717. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5718. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5719. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5720. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5721. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5722. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5723. foreach (var otherInfo in dac5)
  5724. {
  5725. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5726. }
  5727. #endregion
  5728. if (cellStr.Length > 8)
  5729. {
  5730. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5731. }
  5732. cellStr += ")";
  5733. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5734. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5735. decimal pxFee = dac4.Sum(it => it.Cost);
  5736. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5737. string celllastStr1 = "";
  5738. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5739. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5740. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5741. celllastStr1 += $",国际旅费 元";
  5742. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5743. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5744. designer.SetDataSource("cell4Str", cell4Str);
  5745. designer.SetDataSource("cellStr", cellStr);
  5746. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5747. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5748. designer.SetDataSource("celllastStr", celllastStr);
  5749. Workbook wb = designer.Workbook;
  5750. var sheet = wb.Worksheets[0];
  5751. //绑定datatable数据集
  5752. designer.SetDataSource(dtdac1);
  5753. designer.SetDataSource(dtdac2);
  5754. designer.Process();
  5755. var rowStart = dtdac1.Rows.Count;
  5756. while (rowStart > 0)
  5757. {
  5758. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5759. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5760. startIndex++;
  5761. rowStart--;
  5762. }
  5763. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5764. startIndex += 1; //总计行
  5765. rowStart = dtdac2.Rows.Count;
  5766. while (rowStart > 0)
  5767. {
  5768. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5769. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5770. startIndex++;
  5771. rowStart--;
  5772. }
  5773. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5774. wb.CalculateFormula(true);
  5775. //模板文件名
  5776. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5777. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5778. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5779. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5780. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5781. }
  5782. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5783. {
  5784. //获取模板
  5785. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5786. //载入模板
  5787. Document doc = new Document(tempPath);
  5788. DocumentBuilder builder = new DocumentBuilder(doc);
  5789. Dictionary<string, string> dic = new Dictionary<string, string>();
  5790. dic.Add("GroupName", _DelegationInfo.TeamName);
  5791. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5792. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5793. string missionLeaderJob = "";//负责人job
  5794. int groupNumber = 0; //团人数
  5795. if (DeleClientList.Count > 0)
  5796. {
  5797. missionLeader = DeleClientList[0]?.Name ?? "";
  5798. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5799. }
  5800. dic.Add("MissionLeader", missionLeader); //团负责人
  5801. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5802. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5803. #region MyRegion
  5804. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5805. //{
  5806. // List<string> list = new List<string>();
  5807. // try
  5808. // {
  5809. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5810. // foreach (var item in spilitArr)
  5811. // {
  5812. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5813. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5814. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5815. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5816. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5817. // list.Add(depName);
  5818. // list.Add(arrName);
  5819. // }
  5820. // list = list.Distinct().ToList();
  5821. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5822. // }
  5823. // catch (Exception)
  5824. // {
  5825. // dic.Add("ReturnCode", "行程录入不正确!");
  5826. // }
  5827. //}
  5828. //else
  5829. //{
  5830. // dic.Add("ReturnCode", "未录入行程!");
  5831. //}
  5832. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5833. dic.Add("ReturnCode", string.Join("、", countrys));
  5834. #endregion
  5835. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5836. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5837. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5838. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5839. //{
  5840. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5841. // dic.Add("Day", sp.Days.ToString());
  5842. //}
  5843. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5844. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5845. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5846. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5847. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5848. //培训人员名单
  5849. int cultivateRowIndex = 7;
  5850. foreach (var item in DeleClientList)
  5851. {
  5852. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5853. builder.Write(item.Name);
  5854. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5855. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5856. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5857. string birthDay = "";
  5858. if (item.Birthday != null)
  5859. {
  5860. DateTime dt = Convert.ToDateTime(item.Birthday);
  5861. birthDay = $"{dt.Year}.{dt.Month}";
  5862. }
  5863. builder.Write(birthDay);
  5864. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5865. builder.Write(item.Company);
  5866. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5867. builder.Write(item.Job);
  5868. cultivateRowIndex++;
  5869. }
  5870. //删除多余行
  5871. //cultivateRowIndex -= 2;
  5872. int delRows = 10 + 7 - cultivateRowIndex;
  5873. if (delRows > 0)
  5874. {
  5875. for (int i = 0; i < delRows; i++)
  5876. {
  5877. table1.Rows.RemoveAt(cultivateRowIndex);
  5878. //cultivateRowIndex++;
  5879. }
  5880. }
  5881. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5882. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5883. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5884. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5885. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5886. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5887. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5888. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5889. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5890. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5891. //其他费用
  5892. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5893. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5894. //其他费用合计
  5895. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5896. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5897. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5898. //公务舱合计
  5899. //国际旅费
  5900. string outsideJJ = "";
  5901. string allPriceJJ = "";
  5902. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5903. {
  5904. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5905. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5906. }
  5907. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5908. {
  5909. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5910. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5911. }
  5912. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5913. {
  5914. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5915. dic.Add("AirFeeTotal", airFeeTotalStr);
  5916. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5917. dic.Add("FeeTotal", feeTotalStr);
  5918. }
  5919. foreach (var key in dic.Keys)
  5920. {
  5921. builder.MoveToBookmark(key);
  5922. builder.Write(dic[key]);
  5923. }
  5924. //模板文件名
  5925. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5926. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5927. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5928. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5929. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5930. }
  5931. }
  5932. else if (dto.ExportType == 2) //表格
  5933. {
  5934. //利用键值对存放数据
  5935. Dictionary<string, string> dic = new Dictionary<string, string>();
  5936. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5937. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5938. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5939. dic.Add("Day", sp.Days.ToString());
  5940. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5941. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5942. {
  5943. //获取模板
  5944. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5945. //载入模板
  5946. Document doc = new Document(tempPath);
  5947. DocumentBuilder builder = new DocumentBuilder(doc);
  5948. dic.Add("TeamName", _DelegationInfo.TeamName);
  5949. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5950. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5951. string missionLeaderName = "",
  5952. missionLeaderJob = "";
  5953. if (DeleClientList.Count > 0)
  5954. {
  5955. missionLeaderName = DeleClientList[0].Name;
  5956. missionLeaderJob = DeleClientList[0].Job;
  5957. }
  5958. dic.Add("MissionLeaderName", missionLeaderName);
  5959. dic.Add("MissionLeaderJob", missionLeaderJob);
  5960. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5961. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5962. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5963. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5964. int rowCount = 10;//总人数行
  5965. int startRowIndex = 7; //起始行
  5966. for (int i = 0; i < DeleClientList.Count; i++)
  5967. {
  5968. builder.MoveToCell(0, startRowIndex, 0, 0);
  5969. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5970. builder.MoveToCell(0, startRowIndex, 1, 0);
  5971. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5972. builder.Write(sex);//性别
  5973. builder.MoveToCell(0, startRowIndex, 2, 0);
  5974. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5975. builder.MoveToCell(0, startRowIndex, 3, 0);
  5976. builder.Write(DeleClientList[i].Company);//工作单位
  5977. builder.MoveToCell(0, startRowIndex, 4, 0);
  5978. builder.Write(DeleClientList[i].Job);//职务及级别
  5979. builder.MoveToCell(0, startRowIndex, 5, 0);
  5980. builder.Write("");//人员属性
  5981. builder.MoveToCell(0, startRowIndex, 6, 0);
  5982. builder.Write("");//上次出国时间
  5983. startRowIndex++;
  5984. }
  5985. int nullRow = rowCount - DeleClientList.Count;//空行
  5986. for (int i = 0; i < nullRow; i++)
  5987. {
  5988. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5989. }
  5990. foreach (var key in dic.Keys)
  5991. {
  5992. builder.MoveToBookmark(key);
  5993. builder.Write(dic[key]);
  5994. }
  5995. //模板文件名
  5996. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5997. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5998. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5999. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  6000. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  6001. }
  6002. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  6003. {
  6004. //获取模板
  6005. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  6006. //载入模板
  6007. Document doc = new Document(tempPath);
  6008. DocumentBuilder builder = new DocumentBuilder(doc);
  6009. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6010. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6011. dic.Add("Names", Names);
  6012. int accommodationRows = 12, foodandotherRows = 12;
  6013. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6014. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6015. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6016. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6017. int accommodationStartIndex = 6;
  6018. decimal dac1totalPrice = 0.00M;
  6019. foreach (var dac in dac1)
  6020. {
  6021. if (dac.SubTotal == 0)
  6022. {
  6023. continue;
  6024. }
  6025. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6026. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6027. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6028. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6029. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6030. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6031. builder.Write(currency);//币种
  6032. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6033. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6034. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6035. builder.Write("");//人数
  6036. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6037. builder.Write("");//天数
  6038. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6039. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6040. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6041. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6042. builder.Write(rate.ToString("#0.0000"));//汇率
  6043. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6044. decimal rbmPrice = rate * dac.SubTotal;
  6045. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6046. accommodationStartIndex++;
  6047. dac1totalPrice += rbmPrice;
  6048. }
  6049. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6050. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6051. builder.Write("小计");
  6052. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6053. builder.Write(dac1totalPrice.ToString("#0.00"));
  6054. accommodationStartIndex++;
  6055. int nullRow = accommodationRows - dac1.Count;
  6056. //删除空行
  6057. //if (nullRow > 0)
  6058. //{
  6059. // int rowIndex = accommodationStartIndex;
  6060. // for (int i = 0; i < nullRow; i++)
  6061. // {
  6062. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6063. // row.Remove();
  6064. // rowIndex++;
  6065. // }
  6066. //}
  6067. if (dac2.Count == dac3.Count)//国家 币种 金额
  6068. {
  6069. for (int i = 0; i < dac2.Count; i++)
  6070. {
  6071. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6072. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6073. }
  6074. }
  6075. int foodandotherStartIndex = 19;//
  6076. decimal dac2totalPrice = 0.00M;
  6077. foreach (var dac in dac2)
  6078. {
  6079. if (dac.SubTotal == 0)
  6080. {
  6081. continue;
  6082. }
  6083. //foodandotherStartIndex = 12;
  6084. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6085. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6086. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6087. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6088. builder.Write(currency);//币种
  6089. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6090. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6091. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6092. builder.Write("");//人数
  6093. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6094. builder.Write("");//天数
  6095. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6096. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6097. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6098. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6099. builder.Write(rate.ToString("#0.0000"));//汇率
  6100. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6101. decimal rbmPrice = rate * dac.SubTotal;
  6102. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6103. foodandotherStartIndex++;
  6104. dac2totalPrice += rbmPrice;
  6105. }
  6106. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6107. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6108. //删除空行
  6109. //if (dac2.Count < foodandotherRows)
  6110. //{
  6111. // while (table2.Rows.Count > dac2.Count)
  6112. // {
  6113. // table2.Rows.RemoveAt(dac2.Count);
  6114. // }
  6115. //}
  6116. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6117. string otherFeeStr = "";
  6118. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6119. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6120. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6121. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6122. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6123. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6124. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6125. foreach (var otherInfo in dac5)
  6126. {
  6127. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6128. }
  6129. #endregion
  6130. if (otherFeeStr.Length > 0)
  6131. {
  6132. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6133. otherFeeStr = $"({otherFeeStr})";
  6134. dic.Add("OtherFeeStr", otherFeeStr);
  6135. }
  6136. foreach (var key in dic.Keys)
  6137. {
  6138. builder.MoveToBookmark(key);
  6139. builder.Write(dic[key]);
  6140. }
  6141. //模板文件名
  6142. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6143. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6144. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6145. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6146. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6147. }
  6148. }
  6149. else if (dto.ExportType == 3)
  6150. {
  6151. if (dto.SubTypeId == 1) //团组成员名单
  6152. {
  6153. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6154. //获取模板
  6155. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6156. //载入模板
  6157. Document doc = new Document(tempPath);
  6158. DocumentBuilder builder = new DocumentBuilder(doc);
  6159. //获取word里所有表格
  6160. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6161. //获取所填表格的序数
  6162. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6163. var rowStart = tableOne.Rows[0]; //获取第1行
  6164. //循环赋值
  6165. for (int i = 0; i < DeleClientList.Count; i++)
  6166. {
  6167. builder.MoveToCell(0, i + 1, 0, 0);
  6168. builder.Write(DeleClientList[i].Name);
  6169. builder.MoveToCell(0, i + 1, 1, 0);
  6170. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6171. builder.Write(sex);
  6172. builder.MoveToCell(0, i + 1, 2, 0);
  6173. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6174. builder.MoveToCell(0, i + 1, 3, 0);
  6175. builder.Write(DeleClientList[i].Company);
  6176. builder.MoveToCell(0, i + 1, 4, 0);
  6177. builder.Write(DeleClientList[i].Job);
  6178. }
  6179. //删除多余行
  6180. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6181. {
  6182. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6183. }
  6184. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6185. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6186. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6187. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6188. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6189. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6190. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6191. }
  6192. }
  6193. return Ok(JsonView(400, "操作失败!", ""));
  6194. }
  6195. catch (Exception ex)
  6196. {
  6197. return Ok(JsonView(400, ex.Message, ""));
  6198. }
  6199. }
  6200. /// <summary>
  6201. /// 获取三公费用标准city
  6202. /// </summary>
  6203. /// <param name="placeData"></param>
  6204. /// <param name="nationalTravelFeeId"></param>
  6205. /// <returns></returns>
  6206. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6207. {
  6208. string _city = string.Empty;
  6209. if (placeData.Count < 1) return _city;
  6210. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6211. if (data == null) return _city;
  6212. string country = data.Country;
  6213. string city = data.City;
  6214. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6215. else _city = city;
  6216. return _city;
  6217. }
  6218. /// <summary>
  6219. /// 团组模块 - 出入境费用 - 明细表导出
  6220. /// </summary>
  6221. /// <returns></returns>
  6222. [HttpPost]
  6223. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6224. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6225. {
  6226. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6227. if (data.Code != 0)
  6228. {
  6229. return Ok(JsonView(false, data.Msg));
  6230. }
  6231. return Ok(JsonView(true, data.Msg, data.Data));
  6232. }
  6233. /// <summary>
  6234. /// 团组模块 - 出入境费用 - 一键清空
  6235. /// </summary>
  6236. /// <returns></returns>
  6237. [HttpPost]
  6238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6239. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6240. {
  6241. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6242. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6243. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6244. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6245. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6246. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6247. .SetColumns(x => new Grp_DayOtherPrice
  6248. {
  6249. IsDel = 1,
  6250. DeleteUserId = dto.UserId,
  6251. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6252. })
  6253. .ExecuteCommandAsync();
  6254. if (_view.Code == 0)
  6255. {
  6256. return Ok(JsonView(true, "操作成功"));
  6257. }
  6258. return Ok(JsonView(false, "操作失败"));
  6259. }
  6260. /// <summary>
  6261. /// 团组模块 - 出入境费用 - 子项删除
  6262. /// </summary>
  6263. /// <returns></returns>
  6264. [HttpPost]
  6265. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6266. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6267. {
  6268. try
  6269. {
  6270. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6271. if (data.Code != 0)
  6272. {
  6273. return Ok(JsonView(false, data.Msg));
  6274. }
  6275. return Ok(JsonView(true, "操作成功!", data.Data));
  6276. }
  6277. catch (Exception ex)
  6278. {
  6279. return Ok(JsonView(false, ex.Message));
  6280. }
  6281. }
  6282. /// <summary>
  6283. /// 删除三公其他费用
  6284. /// </summary>
  6285. /// <param name="dto"></param>
  6286. /// <returns></returns>
  6287. [HttpPost]
  6288. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6289. {
  6290. var jw = JsonView(false,"删除失败!");
  6291. var data = new Grp_DayOtherPrice()
  6292. {
  6293. Id = dto.Id,
  6294. IsDel = 1,
  6295. DeleteUserId = dto.DeleteUserId,
  6296. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6297. };
  6298. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6299. if (del > 0)
  6300. {
  6301. jw.Code = 200;
  6302. jw.Msg = "删除成功!";
  6303. }
  6304. return Ok(jw);
  6305. }
  6306. /// <summary>
  6307. /// 团组模块 - 出入境国家费用标准 List
  6308. /// </summary>
  6309. /// <returns></returns>
  6310. [HttpPost]
  6311. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6312. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6313. {
  6314. try
  6315. {
  6316. Stopwatch sw = new Stopwatch();
  6317. sw.Start();
  6318. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6319. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6320. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6321. Where gntf.Isdel = 0");
  6322. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6323. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6324. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6325. //foreach (var item in nationalTravel)
  6326. //{
  6327. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6328. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6329. // if (otherData != null)
  6330. // {
  6331. // cityData.Remove(otherData);
  6332. // cityData.Add(otherData);
  6333. // }
  6334. // nationalTravelFeeData1.Add(new
  6335. // {
  6336. // Country = item.Country,
  6337. // CityData = cityData
  6338. // });
  6339. //}
  6340. sw.Stop();
  6341. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6342. }
  6343. catch (Exception ex)
  6344. {
  6345. return Ok(JsonView(false, ex.Message));
  6346. throw;
  6347. }
  6348. }
  6349. /// <summary>
  6350. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6351. /// </summary>
  6352. /// <returns></returns>
  6353. [HttpPost]
  6354. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6355. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6356. {
  6357. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6358. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6359. List<string> countryData = new List<string>();
  6360. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6361. countryData = countryData.Distinct().ToList();
  6362. List<dynamic> dataSource = new List<dynamic>();
  6363. foreach (var item in countryData)
  6364. {
  6365. List<string> cityData1 = new List<string>();
  6366. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6367. var countryData2 = new
  6368. {
  6369. CountryName = item,
  6370. CityData = cityData1
  6371. };
  6372. dataSource.Add(countryData2);
  6373. }
  6374. return Ok(JsonView(true, "查询成功!", dataSource));
  6375. }
  6376. /// <summary>
  6377. /// 团组模块 - 出入境国家费用标准 Page List
  6378. /// </summary>
  6379. /// <returns></returns>
  6380. [HttpPost]
  6381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6382. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6383. {
  6384. int portId = dto.PortType;
  6385. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6386. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6387. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6388. string whereSql = string.Empty;
  6389. if (!string.IsNullOrEmpty(dto.Country))
  6390. {
  6391. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6392. }
  6393. if (!string.IsNullOrEmpty(dto.City))
  6394. {
  6395. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6396. }
  6397. string pageSql = string.Format(@"Select * From (
  6398. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6399. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6400. From Grp_NationalTravelFee gntf
  6401. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6402. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6403. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6404. RefAsync<int> total = 0;
  6405. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6406. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6407. }
  6408. /// <summary>
  6409. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6410. /// </summary>
  6411. /// <returns></returns>
  6412. [HttpPost]
  6413. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6414. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6415. {
  6416. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6417. int portId = dto.PortType;
  6418. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6419. string whereSql = string.Empty;
  6420. if (!string.IsNullOrEmpty(dto.Country))
  6421. {
  6422. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6423. }
  6424. if (!string.IsNullOrEmpty(dto.City))
  6425. {
  6426. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6427. }
  6428. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6429. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6430. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6431. From Grp_NationalTravelFee gntf
  6432. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6433. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6434. Where gntf.Isdel = 0 {0} ", whereSql);
  6435. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6436. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6437. }
  6438. /// <summary>
  6439. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6440. /// </summary>
  6441. /// <returns></returns>
  6442. [HttpPost]
  6443. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6444. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6445. {
  6446. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6447. if (data.Code != 0)
  6448. {
  6449. return Ok(JsonView(false, data.Msg));
  6450. }
  6451. return Ok(JsonView(true, "操作成功!", data.Data));
  6452. }
  6453. /// <summary>
  6454. /// 团组模块 - 出入境国家费用标准 - Del
  6455. /// </summary>
  6456. /// <returns></returns>
  6457. [HttpPost]
  6458. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6459. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6460. {
  6461. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6462. {
  6463. Id = dto.Id,
  6464. DeleteUserId = dto.DeleteUserId,
  6465. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6466. IsDel = 1
  6467. };
  6468. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6469. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6470. .WhereColumns(it => new { it.Id })
  6471. .ExecuteCommandAsync();
  6472. if (delStatus <= 0)
  6473. {
  6474. return Ok(JsonView(false, "删除失败!"));
  6475. }
  6476. return Ok(JsonView(true, "操作成功!"));
  6477. }
  6478. /// <summary>
  6479. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6480. /// 注:Get 请求Headers 加 Token
  6481. /// </summary>
  6482. /// <param name="groupId"></param>
  6483. /// <returns></returns>
  6484. [HttpGet("{groupId}")]
  6485. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6486. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6487. {
  6488. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6489. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6490. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6491. data.ForEach(x =>
  6492. {
  6493. x.CreateUserId = _currUserInfo.UserId;
  6494. });
  6495. if (data.Any())
  6496. {
  6497. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6498. if (add > 0)
  6499. {
  6500. return Ok(JsonView(true, "操作成功!"));
  6501. }
  6502. }
  6503. return Ok(JsonView(false, "未操作!"));
  6504. }
  6505. #endregion
  6506. #region 团组经理模块 出入境费用-草稿
  6507. /// <summary>
  6508. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6509. /// </summary>
  6510. /// <returns></returns>
  6511. [HttpPost]
  6512. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6513. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6514. {
  6515. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6516. .Where(x => x.IsDel == 0)
  6517. .OrderByDescending(x => x.CreateTime)
  6518. .Select(x => new { x.Id, x.DraftName })
  6519. .ToListAsync();
  6520. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6521. //SetDataInfoView
  6522. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6523. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6524. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6525. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6526. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6527. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6528. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6529. //默认币种显示
  6530. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6531. {
  6532. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6533. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6534. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6535. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6536. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6537. };
  6538. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6539. if (_currencyRate.Count > 0)
  6540. {
  6541. foreach (var item in _currencyInfos)
  6542. {
  6543. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6544. if (rateInfo != null)
  6545. {
  6546. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6547. rate1 *= 1.035M;
  6548. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6549. }
  6550. }
  6551. }
  6552. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6553. return Ok(JsonView(true, "查询成功!", new
  6554. {
  6555. DraftNameDatas = draftNameDatas,
  6556. CurrencyData = _CurrencyData,
  6557. WordTypeData = _WordTypeData,
  6558. ExcelTypeData = _ExcelTypeData,
  6559. CurrencyInit = _currencyInfos,
  6560. ViewPermissionData = viewPermissionData
  6561. }));
  6562. }
  6563. /// <summary>
  6564. /// 团组模块 - 出入境费用-草稿
  6565. /// 实时汇率 tips
  6566. /// 签证费用 tips
  6567. /// 机票费用 tips
  6568. /// </summary>
  6569. /// <returns></returns>
  6570. [HttpPost]
  6571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6572. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6573. {
  6574. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6575. //默认币种显示
  6576. var _currencyInfos = _currencyInit;
  6577. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6578. List<dynamic> reteInfos = new List<dynamic>();
  6579. if (_currencyRate.Count > 0)
  6580. {
  6581. foreach (var item in _currencyInfos)
  6582. {
  6583. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6584. if (rateInfo != null)
  6585. {
  6586. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6587. decimal rate1 = item.Rate;
  6588. rate1 *= 1.03M;
  6589. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6590. reteInfos.Add(new
  6591. {
  6592. currCode = item.CurrencyCode,
  6593. currName = item.CurrencyName,
  6594. rate = rate2,
  6595. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6596. });
  6597. }
  6598. }
  6599. }
  6600. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6601. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6602. return Ok(JsonView(true, "查询成功!", new
  6603. {
  6604. //GroupNameData = groupNameData.Data,
  6605. //visaData = visaData.Data,
  6606. //airData = airData.Data,
  6607. reteInfos = reteInfos
  6608. }));
  6609. }
  6610. /// <summary>
  6611. /// 团组模块 - 出入境费用-草稿 - Info
  6612. /// </summary>
  6613. /// <returns></returns>
  6614. [HttpPost]
  6615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6616. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6617. {
  6618. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6619. }
  6620. /// <summary>
  6621. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6622. /// </summary>
  6623. /// <returns></returns>
  6624. [HttpPost]
  6625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6626. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6627. {
  6628. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6629. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6630. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6631. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6632. foreach (var userId in dto.UserIds)
  6633. {
  6634. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6635. }
  6636. if (permissions.Any())
  6637. {
  6638. _sqlSugar.BeginTran();
  6639. try
  6640. {
  6641. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6642. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6643. if (result < 1)
  6644. {
  6645. _sqlSugar.RollbackTran();
  6646. return Ok(JsonView(false));
  6647. }
  6648. }
  6649. catch (Exception ex)
  6650. {
  6651. _sqlSugar.RollbackTran();
  6652. return Ok(JsonView(false, ex.Message));
  6653. }
  6654. _sqlSugar.CommitTran();
  6655. return Ok(JsonView(true));
  6656. }
  6657. return Ok(JsonView(false));
  6658. }
  6659. /// <summary>
  6660. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6661. /// </summary>
  6662. /// <returns></returns>
  6663. [HttpPost]
  6664. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6665. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6666. {
  6667. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6668. if (data.Code != 0)
  6669. {
  6670. return Ok(JsonView(false, data.Msg));
  6671. }
  6672. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6673. //汇率信息记录
  6674. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6675. return Ok(JsonView(true, data.Msg, data.Data));
  6676. }
  6677. /// <summary>
  6678. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6679. /// </summary>
  6680. /// <param name="dto"></param>
  6681. /// <returns></returns>
  6682. [HttpPost]
  6683. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6684. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6685. {
  6686. try
  6687. {
  6688. var id = dto.Id;
  6689. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6690. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6691. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6692. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6693. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6694. 3 团组成员名单 1 团组成员名单", ""));
  6695. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6696. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6697. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6698. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6699. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6700. //数据源
  6701. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6702. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6703. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6704. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6705. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6706. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6707. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6708. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6709. .Select((x, a, b) => new
  6710. {
  6711. x.Index,
  6712. itemName = a.Name,
  6713. CurrencyStr = b.Name,
  6714. x.Cost,
  6715. x.SubTotal,
  6716. x.Remark
  6717. })
  6718. .OrderBy((x) => x.Index)
  6719. .ToList(); //其他款项费用
  6720. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6721. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6722. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6723. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6724. if (dto.ExportType == 1) //明细表
  6725. {
  6726. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6727. {
  6728. //获取模板
  6729. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6730. //载入模板
  6731. Document doc = new Document(tempPath);
  6732. DocumentBuilder builder = new DocumentBuilder(doc);
  6733. //利用键值对存放数据
  6734. Dictionary<string, string> dic = new Dictionary<string, string>();
  6735. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6736. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6737. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6738. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6739. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6740. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6741. //境内费用(其他费用)
  6742. if (_EnterExitCosts.ChoiceOne == 1)
  6743. {
  6744. string row1_1 = "";
  6745. if (_EnterExitCosts.Visa > 0)
  6746. {
  6747. //insidePayTotal += _EnterExitCosts.Visa;
  6748. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6749. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6750. {
  6751. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6752. }
  6753. }
  6754. string row1_2 = "";
  6755. if (_EnterExitCosts.YiMiao > 0)
  6756. {
  6757. //insidePayTotal += _EnterExitCosts.YiMiao;
  6758. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6759. }
  6760. if (_EnterExitCosts.HeSuan > 0)
  6761. {
  6762. //insidePayTotal += _EnterExitCosts.HeSuan;
  6763. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6764. }
  6765. if (_EnterExitCosts.Service > 0)
  6766. {
  6767. //insidePayTotal += _EnterExitCosts.Service;
  6768. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6769. }
  6770. string row1_3 = "";
  6771. if (_EnterExitCosts.Safe > 0)
  6772. {
  6773. //insidePayTotal += _EnterExitCosts.Safe;
  6774. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6775. }
  6776. if (_EnterExitCosts.Ticket > 0)
  6777. {
  6778. //insidePayTotal += _EnterExitCosts.Ticket;
  6779. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6780. }
  6781. string row1 = "";
  6782. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6783. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6784. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6785. row1 += $"备注:{_EnterExitCosts.Remark}";
  6786. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6787. dic.Add("Row1Str", row1);
  6788. }
  6789. string airTotalStr = string.Empty,
  6790. airPriceStr = string.Empty;
  6791. //经济舱
  6792. if (_EnterExitCosts.SumJJC == 1)
  6793. {
  6794. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6795. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6796. }
  6797. //公务舱
  6798. if (_EnterExitCosts.SumGWC == 1)
  6799. {
  6800. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6801. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6802. }
  6803. //头等舱
  6804. if (_EnterExitCosts.SumTDC == 1)
  6805. {
  6806. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6807. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6808. }
  6809. string twoItemRemark = "备注:";
  6810. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6811. {
  6812. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6813. }
  6814. dic.Add("AirTotalStr", airTotalStr);
  6815. dic.Add("AirPriceStr", airPriceStr);
  6816. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6817. dic.Add("TwoItemRemark", twoItemRemark);
  6818. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6819. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6820. int table1Row = 0,
  6821. table2Row = 0,
  6822. table3Row = 0,
  6823. table4Row = 0,
  6824. table5Row = 0;
  6825. //住宿费
  6826. if (_EnterExitCosts.ChoiceThree == 1)
  6827. {
  6828. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6829. table1Row = dac1.Count;
  6830. #region 填充word表格内容
  6831. for (int i = 0; i < dac1.Count; i++)
  6832. {
  6833. var dac = dac1[i];
  6834. if (dac == null) continue;
  6835. builder.MoveToCell(0, i, 0, 0);
  6836. builder.Write("第" + dac.Days.ToString() + "晚:");
  6837. builder.MoveToCell(0, i, 1, 0);
  6838. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6839. //builder.Write(dac.Place == null ? "" : dac.Place);
  6840. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6841. builder.MoveToCell(0, i, 2, 0);
  6842. builder.Write("费用标准:");
  6843. string curr = "";
  6844. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6845. if (currData != null)
  6846. {
  6847. curr = currData.Name;
  6848. }
  6849. builder.MoveToCell(0, i, 3, 0);
  6850. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6851. builder.MoveToCell(0, i, 4, 0);
  6852. builder.Write("费用小计:");
  6853. builder.MoveToCell(0, i, 5, 0);
  6854. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6855. }
  6856. #endregion
  6857. }
  6858. else dic.Add("SubZS", "0.00");
  6859. //删除多余行
  6860. while (table1.Rows.Count > table1Row)
  6861. {
  6862. table1.Rows.RemoveAt(table1Row);
  6863. }
  6864. //伙食费
  6865. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6866. if (_EnterExitCosts.ChoiceFour == 1)
  6867. {
  6868. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6869. table2Row = dac2.Count;
  6870. #region 填充word表格内容
  6871. for (int i = 0; i < dac2.Count; i++)
  6872. {
  6873. var dac = dac2[i];
  6874. if (dac == null) continue;
  6875. builder.MoveToCell(1, i, 0, 0);
  6876. builder.Write("第" + dac.Days.ToString() + "天:");
  6877. builder.MoveToCell(1, i, 1, 0);
  6878. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6879. builder.MoveToCell(1, i, 2, 0);
  6880. builder.Write("费用标准:");
  6881. string curr = "";
  6882. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6883. if (currData != null)
  6884. {
  6885. curr = currData.Name;
  6886. }
  6887. builder.MoveToCell(1, i, 3, 0);
  6888. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6889. builder.MoveToCell(1, i, 4, 0);
  6890. builder.Write("费用小计:");
  6891. builder.MoveToCell(1, i, 5, 0);
  6892. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6893. }
  6894. #endregion
  6895. }
  6896. else dic.Add("SubHS", "0.00");
  6897. //删除多余行
  6898. while (table2.Rows.Count > table2Row)
  6899. {
  6900. table2.Rows.RemoveAt(table2Row);
  6901. }
  6902. //公杂费
  6903. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6904. if (_EnterExitCosts.ChoiceFive == 1)
  6905. {
  6906. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6907. table3Row = dac3.Count;
  6908. #region 填充word表格内容
  6909. for (int i = 0; i < dac3.Count; i++)
  6910. {
  6911. var dac = dac3[i];
  6912. if (dac == null) continue;
  6913. builder.MoveToCell(2, i, 0, 0);
  6914. builder.Write("第" + dac.Days.ToString() + "天:");
  6915. builder.MoveToCell(2, i, 1, 0);
  6916. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6917. builder.MoveToCell(2, i, 2, 0);
  6918. builder.Write("费用标准:");
  6919. string curr = "";
  6920. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6921. if (currData != null)
  6922. {
  6923. curr = currData.Name;
  6924. }
  6925. builder.MoveToCell(2, i, 3, 0);
  6926. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6927. builder.MoveToCell(2, i, 4, 0);
  6928. builder.Write("费用小计:");
  6929. builder.MoveToCell(2, i, 5, 0);
  6930. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6931. }
  6932. //删除多余行
  6933. while (table3.Rows.Count > table3Row)
  6934. {
  6935. table3.Rows.RemoveAt(table3Row);
  6936. }
  6937. #endregion
  6938. }
  6939. else dic.Add("SubGZF", "0.00");
  6940. //删除多余行
  6941. while (table3.Rows.Count > table3Row)
  6942. {
  6943. table3.Rows.RemoveAt(table3Row);
  6944. }
  6945. //培训费
  6946. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6947. if (_EnterExitCosts.ChoiceSix == 1)
  6948. {
  6949. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6950. dic.Add("SubPX", pxStr);
  6951. table4Row = dac4.Count;
  6952. #region 填充word表格内容
  6953. for (int i = 0; i < dac4.Count; i++)
  6954. {
  6955. var dac = dac4[i];
  6956. if (dac == null) continue;
  6957. builder.MoveToCell(3, i, 0, 0);
  6958. builder.Write("第" + dac.Days.ToString() + "天:");
  6959. builder.MoveToCell(3, i, 1, 0);
  6960. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6961. builder.MoveToCell(3, i, 2, 0);
  6962. builder.Write("费用标准:");
  6963. string curr = "";
  6964. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6965. if (currData != null)
  6966. {
  6967. curr = currData.Name;
  6968. }
  6969. builder.MoveToCell(3, i, 3, 0);
  6970. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6971. builder.MoveToCell(3, i, 4, 0);
  6972. builder.Write("费用小计:");
  6973. builder.MoveToCell(3, i, 5, 0);
  6974. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6975. }
  6976. #endregion
  6977. }
  6978. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6979. //删除多余行
  6980. while (table4.Rows.Count > table4Row)
  6981. {
  6982. table4.Rows.RemoveAt(table4Row);
  6983. }
  6984. //其他费用
  6985. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6986. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6987. {
  6988. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6989. dic.Add("titleQi", qtStr);
  6990. table5Row = dac5.Count;
  6991. #region 填充word表格内容
  6992. for (int i = 0; i < dac5.Count; i++)
  6993. {
  6994. var dac = dac5[i];
  6995. if (dac == null) continue;
  6996. builder.MoveToCell(4, i, 0, 0);
  6997. builder.Write("第" + dac.Index.ToString() + "项:");
  6998. builder.MoveToCell(4, i, 1, 0);
  6999. builder.Write(dac.itemName);
  7000. builder.MoveToCell(4, i, 2, 0);
  7001. builder.Write("费用标准:");
  7002. builder.MoveToCell(4, i, 3, 0);
  7003. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  7004. builder.MoveToCell(4, i, 4, 0);
  7005. builder.Write("费用小计:");
  7006. builder.MoveToCell(4, i, 5, 0);
  7007. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7008. builder.MoveToCell(4, i, 6, 0);
  7009. builder.Write("备注:");
  7010. builder.MoveToCell(4, i, 7, 0);
  7011. builder.Write(dac.Remark);
  7012. }
  7013. #endregion
  7014. }
  7015. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7016. //删除多余行
  7017. while (table5.Rows.Count > table5Row)
  7018. {
  7019. table5.Rows.RemoveAt(table5Row);
  7020. }
  7021. //加上其他费用
  7022. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7023. decimal subJJC = 0.00M,
  7024. subGWC = 0.00M,
  7025. subTDC = 0.00M;
  7026. //经济舱
  7027. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7028. //公务舱
  7029. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7030. //头等舱
  7031. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7032. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7033. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7034. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7035. #region 填充word模板书签内容
  7036. foreach (var key in dic.Keys)
  7037. {
  7038. Bookmark bookmark = doc.Range.Bookmarks[key];
  7039. if (bookmark != null)
  7040. {
  7041. builder.MoveToBookmark(key);
  7042. builder.Write(dic[key]);
  7043. }
  7044. }
  7045. #endregion
  7046. //文件名
  7047. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7048. strFileName = CommonFun.ValidFileName(strFileName);
  7049. AsposeHelper.removewatermark_v2180();
  7050. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7051. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7052. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7053. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7054. }
  7055. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7056. {
  7057. //获取模板
  7058. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7059. //载入模板
  7060. Document doc = new Document(tempPath);
  7061. DocumentBuilder builder = new DocumentBuilder(doc);
  7062. Dictionary<string, string> dic = new Dictionary<string, string>();
  7063. string returnCodeLabel = string.Empty;
  7064. if (nationalTravelFeeData.Any())
  7065. {
  7066. List<string> list = new List<string>();
  7067. foreach (var item in nationalTravelFeeData)
  7068. {
  7069. list.Add($"{item.Country}({item.City})");
  7070. }
  7071. list = list.Distinct().ToList();
  7072. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7073. }
  7074. var countryLabel = string.Empty;
  7075. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7076. if (countryData.Any())
  7077. {
  7078. countryLabel = string.Join("、", countryData);
  7079. }
  7080. dic.Add("ReturnCodeAir", returnCodeLabel);
  7081. dic.Add("VisitStartDate", "-");
  7082. dic.Add("VisitEndDate", "-");
  7083. dic.Add("Day", "-");
  7084. dic.Add("VisitCountry", countryLabel);
  7085. dic.Add("ClientUnit", "-");
  7086. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7087. //dic.Add("Names", Names);
  7088. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7089. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7090. decimal dac1totalPrice = 0.00M;
  7091. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7092. foreach (var dac in dac1)
  7093. {
  7094. if (dac.SubTotal == 0.00M)
  7095. {
  7096. continue;
  7097. }
  7098. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7099. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7100. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7101. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7102. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7103. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7104. builder.Write(currency);//币种
  7105. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7106. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7107. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7108. builder.Write("");//人数
  7109. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7110. builder.Write("");//天数
  7111. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7112. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7113. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7114. decimal rate = 0.00M;
  7115. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7116. builder.Write(rate.ToString("#0.0000"));//汇率
  7117. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7118. decimal rbmPrice = dac.SubTotal;
  7119. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7120. accommodationStartIndex++;
  7121. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7122. }
  7123. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7124. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7125. {
  7126. table1.Rows.RemoveAt(i - 1);
  7127. foodandotherStartIndex--;
  7128. }
  7129. if (dac2.Count == dac3.Count)//国家 币种 金额
  7130. {
  7131. for (int i = 0; i < dac2.Count; i++)
  7132. {
  7133. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7134. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7135. }
  7136. }
  7137. decimal dac2totalPrice = 0.00M;
  7138. foreach (var dac in dac2)
  7139. {
  7140. if (dac.SubTotal == 0)
  7141. {
  7142. continue;
  7143. }
  7144. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7145. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7146. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7147. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7148. builder.Write(currency);//币种
  7149. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7150. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7151. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7152. builder.Write("");//人数
  7153. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7154. builder.Write("");//天数
  7155. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7156. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7157. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7158. decimal rate = 0.00M;
  7159. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7160. builder.Write(rate.ToString("#0.0000"));//汇率
  7161. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7162. decimal rbmPrice = dac.SubTotal;
  7163. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7164. foodandotherStartIndex++;
  7165. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7166. }
  7167. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7168. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7169. {
  7170. table1.Rows.RemoveAt(i - 1);
  7171. }
  7172. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7173. string otherFeeStr = "";
  7174. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7175. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7176. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7177. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7178. foreach (var otherInfo in dac5)
  7179. {
  7180. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7181. }
  7182. #endregion
  7183. if (otherFeeStr.Length > 0)
  7184. {
  7185. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7186. otherFeeStr = $"({otherFeeStr})";
  7187. dic.Add("OtherFeeStr", otherFeeStr);
  7188. }
  7189. //总计
  7190. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7191. //国际旅费
  7192. string outsideAir = string.Empty;
  7193. string allPriceAir = string.Empty;
  7194. if (_EnterExitCosts.SumJJC == 1)
  7195. {
  7196. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7197. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7198. }
  7199. if (_EnterExitCosts.SumGWC == 1)
  7200. {
  7201. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7202. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7203. }
  7204. if (_EnterExitCosts.SumTDC == 1)
  7205. {
  7206. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7207. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7208. }
  7209. dic.Add("InTravelPrice", $"({outsideAir})");
  7210. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7211. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7212. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7213. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7214. foreach (var key in dic.Keys)
  7215. {
  7216. builder.MoveToBookmark(key);
  7217. builder.Write(dic[key]);
  7218. }
  7219. //模板文件名
  7220. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7221. strFileName = CommonFun.ValidFileName(strFileName);
  7222. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7223. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7224. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7225. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7226. }
  7227. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7228. {
  7229. //获取模板
  7230. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7231. //载入模板
  7232. WorkbookDesigner designer = new WorkbookDesigner();
  7233. designer.Workbook = new Workbook(tempPath);
  7234. Dictionary<string, string> dic = new Dictionary<string, string>();
  7235. string returnCodeLabel = string.Empty;
  7236. if (nationalTravelFeeData.Any())
  7237. {
  7238. List<string> list = new List<string>();
  7239. foreach (var item in nationalTravelFeeData)
  7240. {
  7241. list.Add($"{item.Country}({item.City})");
  7242. }
  7243. list = list.Distinct().ToList();
  7244. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7245. }
  7246. var countryLabel = string.Empty;
  7247. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7248. if (countryData.Any())
  7249. {
  7250. countryLabel = string.Join("、", countryData);
  7251. }
  7252. dic.Add("ReturnCodeAir", returnCodeLabel);
  7253. dic.Add("VisitStartDate", "-");
  7254. dic.Add("VisitEndDate", "-");
  7255. dic.Add("Day", "0");
  7256. dic.Add("VisitCountry", countryLabel);
  7257. dic.Add("ClientUnit", "-");
  7258. designer.SetDataSource("ClientUnit", "-");
  7259. designer.SetDataSource("VisitCountry", countryLabel);
  7260. designer.SetDataSource("Group", "-");
  7261. designer.SetDataSource("ClientUnitTitle", "-");
  7262. designer.SetDataSource("Name", "-");
  7263. designer.SetDataSource("VisitStartDate", "-" );
  7264. designer.SetDataSource("Day", "0");
  7265. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7266. designer.SetDataSource("ReturnCodeAir", "-");
  7267. int startIndex = 10;
  7268. const int startIndexcopy = 10;
  7269. if (dac2.Count == dac3.Count)//国家 币种 金额
  7270. {
  7271. for (int i = 0; i < dac2.Count; i++)
  7272. {
  7273. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7274. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7275. }
  7276. }
  7277. DataTable dtdac1 = new DataTable();
  7278. List<string> place = new List<string>();
  7279. dtdac1.Columns.AddRange(new DataColumn[] {
  7280. new DataColumn(){ ColumnName = "city"},
  7281. new DataColumn(){ ColumnName = "curr"},
  7282. new DataColumn(){ ColumnName = "criterion"},
  7283. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7284. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7285. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7286. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7287. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7288. });
  7289. DataTable dtdac2 = new DataTable();
  7290. dtdac2.Columns.AddRange(new DataColumn[] {
  7291. new DataColumn(){ ColumnName = "city"},
  7292. new DataColumn(){ ColumnName = "curr"},
  7293. new DataColumn(){ ColumnName = "criterion"},
  7294. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7295. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7296. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7297. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7298. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7299. });
  7300. dtdac1.TableName = "tb1";
  7301. dtdac2.TableName = "tb2";
  7302. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7303. foreach (var item in dac1)
  7304. {
  7305. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7306. if (place.Contains(item.Place))
  7307. {
  7308. continue;
  7309. }
  7310. DataRow row = dtdac1.NewRow();
  7311. row["city"] = item.Place;
  7312. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7313. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7314. row["curr"] = currency;
  7315. row["rate"] = rate.ToString("#0.0000");
  7316. row["criterion"] = item.Cost.ToString("#0.00");
  7317. row["number"] = 1;
  7318. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7319. //row["costRMB"] = rbmPrice;
  7320. dtdac1.Rows.Add(row);
  7321. place.Add(item.Place);
  7322. }
  7323. place = new List<string>();
  7324. foreach (var item in dac2)
  7325. {
  7326. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7327. if (place.Contains(item.Place))
  7328. {
  7329. continue;
  7330. }
  7331. DataRow row = dtdac2.NewRow();
  7332. row["city"] = item.Place;
  7333. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7334. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7335. row["curr"] = currency;
  7336. row["rate"] = rate.ToString("#0.0000");
  7337. row["criterion"] = item.Cost.ToString("#0.00");
  7338. row["number"] = 1;
  7339. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7340. //row["cost"] = item.SubTotal;
  7341. //row["costRMB"] = rbmPrice;
  7342. dtdac2.Rows.Add(row);
  7343. place.Add(item.Place);
  7344. //dac2totalPrice += rbmPrice;
  7345. }
  7346. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7347. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7348. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7349. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7350. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7351. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7352. string cell4Str1 = string.Empty;
  7353. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7354. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7355. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7356. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7357. string cellStr = $" 5.其他费用(";
  7358. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7359. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7360. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7361. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7362. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7363. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7364. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7365. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7366. foreach (var otherInfo in dac5)
  7367. {
  7368. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7369. }
  7370. #endregion
  7371. if (cellStr.Length > 8)
  7372. {
  7373. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7374. }
  7375. cellStr += ")";
  7376. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7377. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7378. decimal pxFee = dac4.Sum(it => it.Cost);
  7379. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7380. string celllastStr1 = "";
  7381. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7382. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7383. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7384. celllastStr1 += $",国际旅费 元";
  7385. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7386. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7387. designer.SetDataSource("cell4Str", cell4Str);
  7388. designer.SetDataSource("cellStr", cellStr);
  7389. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7390. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7391. designer.SetDataSource("celllastStr", celllastStr);
  7392. Workbook wb = designer.Workbook;
  7393. var sheet = wb.Worksheets[0];
  7394. //绑定datatable数据集
  7395. designer.SetDataSource(dtdac1);
  7396. designer.SetDataSource(dtdac2);
  7397. designer.Process();
  7398. var rowStart = dtdac1.Rows.Count;
  7399. while (rowStart > 0)
  7400. {
  7401. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7402. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7403. startIndex++;
  7404. rowStart--;
  7405. }
  7406. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7407. startIndex += 1; //总计行
  7408. rowStart = dtdac2.Rows.Count;
  7409. while (rowStart > 0)
  7410. {
  7411. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7412. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7413. startIndex++;
  7414. rowStart--;
  7415. }
  7416. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7417. wb.CalculateFormula(true);
  7418. //模板文件名
  7419. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7420. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7421. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7422. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7423. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7424. }
  7425. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7426. {
  7427. //获取模板
  7428. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7429. //载入模板
  7430. Document doc = new Document(tempPath);
  7431. DocumentBuilder builder = new DocumentBuilder(doc);
  7432. Dictionary<string, string> dic = new Dictionary<string, string>();
  7433. dic.Add("GroupName", "-");
  7434. dic.Add("ClientUnit", "-");
  7435. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7436. string missionLeaderJob = "";//负责人job
  7437. int groupNumber = 0; //团人数
  7438. dic.Add("MissionLeader", "-"); //团负责人
  7439. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7440. dic.Add("GroupNumber", "0"); //团人数
  7441. dic.Add("Day", "0");
  7442. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7443. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7444. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7445. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7446. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7447. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7448. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7449. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7450. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7451. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7452. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7453. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7454. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7455. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7456. //其他费用
  7457. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7458. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7459. //其他费用合计
  7460. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7461. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7462. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7463. //公务舱合计
  7464. //国际旅费
  7465. string outsideJJ = "";
  7466. string allPriceJJ = "";
  7467. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7468. {
  7469. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7470. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7471. }
  7472. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7473. {
  7474. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7475. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7476. }
  7477. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7478. {
  7479. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7480. dic.Add("AirFeeTotal", airFeeTotalStr);
  7481. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7482. dic.Add("FeeTotal", feeTotalStr);
  7483. }
  7484. foreach (var key in dic.Keys)
  7485. {
  7486. builder.MoveToBookmark(key);
  7487. builder.Write(dic[key]);
  7488. }
  7489. //模板文件名
  7490. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7491. strFileName = CommonFun.ValidFileName(strFileName);
  7492. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7493. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7494. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7495. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7496. }
  7497. }
  7498. else if (dto.ExportType == 2) //表格
  7499. {
  7500. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7501. }
  7502. else if (dto.ExportType == 3)
  7503. {
  7504. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7505. }
  7506. return Ok(JsonView(400, "只可导出明细表!", ""));
  7507. }
  7508. catch (Exception ex)
  7509. {
  7510. return Ok(JsonView(400, ex.Message, ""));
  7511. }
  7512. }
  7513. /// <summary>
  7514. /// 获取三公费用标准city
  7515. /// </summary>
  7516. /// <param name="placeData"></param>
  7517. /// <param name="nationalTravelFeeId"></param>
  7518. /// <returns></returns>
  7519. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7520. {
  7521. string _city = string.Empty;
  7522. if (!placeData.Any()) return _city;
  7523. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7524. if (data == null) return _city;
  7525. string country = data.Country;
  7526. string city = data.City;
  7527. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7528. else _city = city;
  7529. return _city;
  7530. }
  7531. /// <summary>
  7532. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7533. /// </summary>
  7534. /// <returns></returns>
  7535. [HttpPost]
  7536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7537. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7538. {
  7539. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7540. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7541. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7542. if (_view.Code == 0)
  7543. {
  7544. return Ok(JsonView(true, "操作成功"));
  7545. }
  7546. return Ok(JsonView(false, "操作失败"));
  7547. }
  7548. /// <summary>
  7549. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7550. /// </summary>
  7551. /// <returns></returns>
  7552. [HttpPost]
  7553. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7554. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7555. {
  7556. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7557. if (data.Code != 0)
  7558. {
  7559. return Ok(JsonView(false, data.Msg));
  7560. }
  7561. return Ok(JsonView(true, "操作成功!", data.Data));
  7562. }
  7563. /// <summary>
  7564. /// 三公其他费用草稿 删除
  7565. /// </summary>
  7566. /// <param name="dto"></param>
  7567. /// <returns></returns>
  7568. [HttpPost]
  7569. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7570. {
  7571. var jw = JsonView(false, "删除失败!");
  7572. var data = new Grp_DayOtherPriceDraft()
  7573. {
  7574. Id = dto.Id,
  7575. IsDel = 1,
  7576. DeleteUserId = dto.DeleteUserId,
  7577. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7578. };
  7579. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7580. if (del > 0)
  7581. {
  7582. jw.Code = 200;
  7583. jw.Msg = "删除成功!";
  7584. }
  7585. return Ok(jw);
  7586. }
  7587. /// <summary>
  7588. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7589. /// </summary>
  7590. /// <param name="dto"></param>
  7591. /// <returns></returns>
  7592. [HttpPost]
  7593. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7594. {
  7595. var jw = JsonView(false);
  7596. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7597. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7598. jw.Code = StatusCodes.Status200OK;
  7599. jw.Msg = "操作成功!";
  7600. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7601. return Ok(jw);
  7602. }
  7603. /// <summary>
  7604. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7605. /// </summary>
  7606. /// <param name="dto"></param>
  7607. /// <returns></returns>
  7608. [HttpPost]
  7609. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7610. {
  7611. int userId = dto.UserId,
  7612. portId = dto.PortType,
  7613. groupId = dto.GroupId,
  7614. draftId = dto.DraftId;
  7615. _portTypeData.Add(1);
  7616. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7617. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7618. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7619. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7620. _sqlSugar.BeginTran();
  7621. try
  7622. {
  7623. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7624. if (draftDatas == null)
  7625. {
  7626. _sqlSugar.RollbackTran();
  7627. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7628. }
  7629. //验证可覆盖已有数据 两边创建人需为同一人;
  7630. int draftCreateUserId = draftDatas.CreateUserId,
  7631. formalCreateUserId = 0;
  7632. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7633. if (formalData != null)
  7634. {
  7635. formalCreateUserId = formalData.CreateUserId;
  7636. if (draftCreateUserId != formalCreateUserId)
  7637. {
  7638. _sqlSugar.RollbackTran();
  7639. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7640. }
  7641. }
  7642. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7643. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7644. var permissions = new List<Grp_EnterExitCostPermission>();
  7645. if (userIds.Any())
  7646. {
  7647. foreach (var userId1 in userIds)
  7648. {
  7649. permissions.Add(new Grp_EnterExitCostPermission() {
  7650. GroupId = groupId,
  7651. UserId = userId1,
  7652. CreateUserId = dto.UserId
  7653. });
  7654. }
  7655. }
  7656. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7657. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7658. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7659. newExterData.DiId = groupId;
  7660. newExterData.CreateUserId = userId;
  7661. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7662. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7663. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7664. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7665. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7666. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7667. //数据如果存在执行删除
  7668. if (enterExitCostInfo != null)
  7669. {
  7670. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7671. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7672. .Where(x => x.Id == enterExitCostInfo.Id)
  7673. .ExecuteCommand();
  7674. _sqlSugar.Updateable<Grp_DayAndCost>()
  7675. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7676. .Where(x => x.DiId == groupId)
  7677. .ExecuteCommand();
  7678. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7679. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7680. .Where(x => x.Diid == groupId)
  7681. .ExecuteCommand();
  7682. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7683. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7684. .Where(x => x.GroupId == groupId)
  7685. .ExecuteCommand();
  7686. }
  7687. //执行insert
  7688. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7689. if (insertId < 1)
  7690. {
  7691. _sqlSugar.RollbackTran();
  7692. return Ok(JsonView(false, "草稿数据导入失败!"));
  7693. }
  7694. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7695. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7696. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7697. _sqlSugar.CommitTran();
  7698. //执行操作之后
  7699. //生成默认文件pdf并且通知人员
  7700. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7701. {
  7702. DiId = groupId,
  7703. ExportType = 1,
  7704. SubTypeId = 1005
  7705. }, "pdf");
  7706. //发送通知
  7707. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7708. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7709. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7710. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7711. //汇率信息记录
  7712. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7713. return Ok(JsonView(true));
  7714. }
  7715. catch (Exception ex)
  7716. {
  7717. _sqlSugar.RollbackTran();
  7718. return Ok(JsonView(false,ex.Message));
  7719. }
  7720. }
  7721. #endregion
  7722. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7723. /// <summary>
  7724. /// 获取币种基础数据(含逻辑处理)
  7725. /// </summary>
  7726. /// <returns></returns>
  7727. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7728. {
  7729. //默认币种显示
  7730. var _currencyInfos = _currencyInit;
  7731. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7732. if (_currencyRate.Count > 0)
  7733. {
  7734. foreach (var item in _currencyInfos)
  7735. {
  7736. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7737. if (rateInfo != null)
  7738. {
  7739. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7740. rate1 *= 1.035M;
  7741. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7742. }
  7743. }
  7744. }
  7745. return _currencyInfos;
  7746. }
  7747. /// <summary>
  7748. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7749. /// </summary>
  7750. /// <returns></returns>
  7751. [HttpPost]
  7752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7753. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7754. {
  7755. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7756. //SetDataInfoView
  7757. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7758. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7759. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7760. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7761. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7762. //默认币种显示
  7763. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7764. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7765. return Ok(JsonView(true, "查询成功!", new
  7766. {
  7767. WordTypeData = _WordTypeData,
  7768. ExcelTypeData = _ExcelTypeData,
  7769. CurrencyInit = _currencyInfos,
  7770. viewPermissionData = viewPermissionData
  7771. }));
  7772. }
  7773. /// <summary>
  7774. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7775. /// </summary>
  7776. /// <returns></returns>
  7777. [HttpPost]
  7778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7779. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7780. {
  7781. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7782. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7783. RefAsync<int> total = 0;
  7784. int diId = 0;
  7785. var status = int.TryParse(dto.GroupName, out diId);
  7786. string sql = string.Format(@"SELECT
  7787. Id,
  7788. TeamName GroupName,
  7789. CASE WHEN EXISTS (
  7790. SELECT
  7791. 1
  7792. FROM
  7793. Grp_EnterExitCost
  7794. WHERE
  7795. IsDel = 0
  7796. AND DiId = di.Id
  7797. ) THEN 1 ELSE 0 END AS [IsNull],
  7798. CASE WHEN EXISTS(
  7799. SELECT
  7800. TOP 1 *
  7801. FROM
  7802. Grp_EnterExitCost
  7803. WHERE
  7804. IsDel = 0
  7805. AND DiId = di.Id
  7806. AND CreateUserId = {0}
  7807. ORDER BY
  7808. CreateTime DESC
  7809. ) THEN 1 ELSE 0 END AS [IsEdit],
  7810. CASE WHEN EXISTS(
  7811. SELECT
  7812. TOP 1 *
  7813. FROM
  7814. Grp_EnterExitCost
  7815. WHERE
  7816. IsDel = 0
  7817. AND DiId = di.Id
  7818. AND CreateUserId = {0}
  7819. ORDER BY
  7820. CreateTime DESC
  7821. ) THEN 1 WHEN EXISTS(
  7822. SELECT
  7823. TOP 1 *
  7824. FROM
  7825. Grp_EnterExitCostPermission
  7826. WHERE
  7827. IsDel = 0
  7828. AND GroupId = di.Id
  7829. AND Permission = 1
  7830. AND UserId = {0}
  7831. ORDER BY
  7832. CreateTime DESC
  7833. ) THEN 1 ELSE 0 END AS [IsView]
  7834. FROM
  7835. Grp_DelegationInfo di
  7836. WHERE
  7837. di.Isdel = 0 ",dto.CurrUserId);
  7838. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7839. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7840. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7841. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7842. .OrderByDescending(x => x.Id)
  7843. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7844. return Ok(JsonView(true, "查询成功!", data, total));
  7845. }
  7846. /// <summary>
  7847. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7848. /// </summary>
  7849. /// <returns></returns>
  7850. [HttpPost]
  7851. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7852. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7853. {
  7854. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7855. RefAsync<int> total = 0;
  7856. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7857. .Where(x => x.IsDel == 0 && x.STid == 66)
  7858. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7859. .Select(x => new
  7860. {
  7861. id = x.Id,
  7862. name = x.Name,
  7863. remark = x.Remark,
  7864. })
  7865. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7866. return Ok(JsonView(true, "查询成功!", data, total));
  7867. }
  7868. /// <summary>
  7869. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7870. /// </summary>
  7871. /// <returns></returns>
  7872. [HttpPost]
  7873. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7874. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7875. {
  7876. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7877. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7878. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7879. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7880. var groupOtherRateData = groupRateData.TeamRates;
  7881. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7882. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7883. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7884. groupOtherRateData = groupOtherRateData
  7885. .Select(x => new TeamRateDescAddCurrencyIdView {
  7886. CurrencyId = x.CurrencyId,
  7887. CurrencyName = x.CurrencyName,
  7888. CurrencyCode = x.CurrencyCode,
  7889. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7890. }).ToList();
  7891. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7892. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7893. }
  7894. /// <summary>
  7895. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7896. /// </summary>
  7897. /// <returns></returns>
  7898. [HttpPost]
  7899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7900. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7901. {
  7902. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7903. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7904. var tipsData = new List<int>() {1,2,3 };
  7905. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7906. if (dto.TipsType == 1)
  7907. {
  7908. //默认币种显示
  7909. var _currencyInfos = _currencyInit;
  7910. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7911. List<dynamic> reteInfos = new List<dynamic>();
  7912. if (_currencyRate.Count > 0)
  7913. {
  7914. foreach (var item in _currencyInfos)
  7915. {
  7916. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7917. if (rateInfo != null)
  7918. {
  7919. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7920. decimal rate1 = item.Rate;
  7921. rate1 *= 1.03M;
  7922. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7923. reteInfos.Add(new
  7924. {
  7925. currCode = item.CurrencyCode,
  7926. currName = item.CurrencyName,
  7927. rate = rate2,
  7928. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7929. });
  7930. }
  7931. }
  7932. }
  7933. return Ok(JsonView(true, "查询成功!", reteInfos));
  7934. }
  7935. else if (dto.TipsType == 2)
  7936. {
  7937. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7938. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7939. }
  7940. else if (dto.TipsType == 3)
  7941. {
  7942. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7943. return Ok(JsonView(true, "查询成功!", airData.Data));
  7944. }
  7945. return Ok(JsonView(false));
  7946. }
  7947. /// <summary>
  7948. /// 团组模块 - 出入境国家费用标准-移动端 List
  7949. /// </summary>
  7950. /// <returns></returns>
  7951. [HttpPost]
  7952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7953. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7954. {
  7955. Stopwatch sw = new Stopwatch();
  7956. sw.Start();
  7957. RefAsync<int> total = 0;
  7958. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7959. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7960. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7961. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7962. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7963. .Select((ntf, sd, u) => new
  7964. {
  7965. Id = ntf.Id,
  7966. Area = $"{ntf.Country}-{ntf.City}",
  7967. Currency = ntf.Currency,
  7968. CurrencyCode = sd.Name,
  7969. CurrencyName = sd.Remark,
  7970. RoomCost = ntf.RoomCost,
  7971. FoodCost = ntf.FoodCost,
  7972. PublicCost = ntf.PublicCost,
  7973. LastUpdateUserId = ntf.LastUpdateUserId,
  7974. LastUpdateUserName = u.CnName,
  7975. LastUpdateTime = ntf.LastUpdateTime,
  7976. })
  7977. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7978. sw.Stop();
  7979. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7980. }
  7981. /// <summary>
  7982. /// 团组模块 - 出入境费用-移动端 - Info
  7983. /// </summary>
  7984. /// <returns></returns>
  7985. [HttpPost]
  7986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7987. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7988. {
  7989. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7990. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7991. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7992. return Ok(data);
  7993. }
  7994. /// <summary>
  7995. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7996. /// </summary>
  7997. /// <returns></returns>
  7998. [HttpPost]
  7999. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8000. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  8001. {
  8002. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8003. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8004. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8005. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8006. var mobileInfo = new EnterExitCostMobileParentInfoView();
  8007. mobileInfo.DiId = dto.DiId;
  8008. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8009. if (eecInfo == null) return Ok(mobileInfo);
  8010. //验证查看权限
  8011. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8012. if (!isView) return Ok(JsonView(false, msg));
  8013. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8014. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8015. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8016. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8017. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8018. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8019. {
  8020. SubId = dac.Id,
  8021. DiId = dac.DiId,
  8022. Type = dac.Type,
  8023. Days = dac.Days,
  8024. NationalTravelFeeId = dac.NationalTravelFeeId,
  8025. Arae = $"{ntf.Country}-{ntf.City}",
  8026. Cost = dac.Cost,
  8027. Currency = dac.Currency,
  8028. CurrencyName = sd.Name,
  8029. SubTotal = dac.SubTotal,
  8030. })
  8031. .ToList();
  8032. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8033. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8034. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8035. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8036. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8037. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8038. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8039. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8040. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8041. //其他款项
  8042. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8043. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8044. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8045. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8046. .OrderBy((dop, sd1, sd2) => dop.Index)
  8047. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8048. {
  8049. SubId = dop.Id,
  8050. DiId = dop.Diid,
  8051. Index = dop.Index,
  8052. SetDataId = dop.SetDataId,
  8053. SetDataName = sd1.Name,
  8054. Cost = dop.Cost,
  8055. Currency = dop.Currency,
  8056. CurrencyName = sd2.Remark,
  8057. SubTotal = dop.SubTotal,
  8058. Remark = dop.Remark,
  8059. })
  8060. .ToArray();
  8061. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8062. return Ok(mobileInfo);
  8063. }
  8064. /// <summary>
  8065. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8066. /// </summary>
  8067. /// <returns></returns>
  8068. [HttpPost]
  8069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8070. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8071. {
  8072. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8073. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8074. //验证查看权限
  8075. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8076. if (!isView) return Ok(JsonView(false, msg));
  8077. var userIds = Array.Empty<int>();
  8078. userIds = await _sqlSugar
  8079. .Queryable<Grp_EnterExitCostPermission>()
  8080. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8081. .Select(x => x.UserId)
  8082. .ToArrayAsync();
  8083. return Ok(userIds);
  8084. }
  8085. /// <summary>
  8086. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8087. /// </summary>
  8088. /// <returns></returns>
  8089. [HttpPost]
  8090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8091. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8092. {
  8093. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8094. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8095. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8096. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8097. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8098. //验证查看权限
  8099. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8100. if (!isView) return Ok(JsonView(false, msg));
  8101. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8102. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8103. var subType = dto.SubType;
  8104. if (subType == 1) //1:境内费用
  8105. {
  8106. var oneData = new ChoiceOneMobileSubInfoView()
  8107. {
  8108. Id = eecInfo.Id,
  8109. ChoiceOne = eecInfo.ChoiceOne,
  8110. ChoiceOneTotalCost = eecInfo.InsidePay,
  8111. Visa = eecInfo.Visa,
  8112. VisaRemark = eecInfo.VisaRemark,
  8113. YiMiao = eecInfo.YiMiao,
  8114. HeSuan = eecInfo.HeSuan,
  8115. Service = eecInfo.Service,
  8116. Ticket = eecInfo.Ticket,
  8117. Safe = eecInfo.Safe,
  8118. FirstItemRemark = eecInfo.FirstItemRemark
  8119. };
  8120. return Ok(JsonView(oneData));
  8121. }
  8122. else if (subType == 2) //2:国际旅费
  8123. {
  8124. var twoData = new ChoiceTwoMobileSubInfoView() {
  8125. Id = eecInfo.Id,
  8126. ChoiceTwoJJ = eecInfo.SumJJC,
  8127. OutsideJJPay = eecInfo.OutsideJJPay,
  8128. ChoiceTwoGW = eecInfo.SumGWC,
  8129. OutsideGWPay = eecInfo.OutsideGWPay,
  8130. ChoiceTwoTD = eecInfo.SumTDC,
  8131. OutsideTDPay = eecInfo.OutsideTDPay,
  8132. AirJJ = eecInfo.AirJJ,
  8133. AirGW = eecInfo.AirGW,
  8134. AirTD = eecInfo.AirTD,
  8135. CityTranffic = eecInfo.CityTranffic,
  8136. TwoItemRemark = eecInfo.TwoItemRemark
  8137. };
  8138. return Ok(JsonView(twoData));
  8139. }
  8140. else if (subType == 3) //3:住宿费
  8141. {
  8142. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8143. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8144. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8145. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8146. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8147. {
  8148. SubId = dac.Id,
  8149. DiId = dac.DiId,
  8150. Type = dac.Type,
  8151. Days = dac.Days,
  8152. NationalTravelFeeId = dac.NationalTravelFeeId,
  8153. Arae = $"{ntf.Country}-{ntf.City}",
  8154. Cost = dac.Cost,
  8155. Currency = dac.Currency,
  8156. CurrencyName = sd.Name,
  8157. SubTotal = dac.SubTotal,
  8158. })
  8159. .ToArray();
  8160. var data = new ChoiceMobileSubInfo3To6View() {
  8161. ParentId = eecInfo.Id,
  8162. Choice = eecInfo.ChoiceThree,
  8163. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8164. Details = dayAndCostDatas
  8165. };
  8166. return Ok(JsonView(data));
  8167. }
  8168. else if (subType == 4) //4:伙食费
  8169. {
  8170. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8171. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8172. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8173. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8174. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8175. {
  8176. SubId = dac.Id,
  8177. DiId = dac.DiId,
  8178. Type = dac.Type,
  8179. Days = dac.Days,
  8180. NationalTravelFeeId = dac.NationalTravelFeeId,
  8181. Arae = $"{ntf.Country}-{ntf.City}",
  8182. Cost = dac.Cost,
  8183. Currency = dac.Currency,
  8184. CurrencyName = sd.Name,
  8185. SubTotal = dac.SubTotal,
  8186. })
  8187. .ToArray();
  8188. var data = new ChoiceMobileSubInfo3To6View()
  8189. {
  8190. ParentId = eecInfo.Id,
  8191. Choice = eecInfo.ChoiceFour,
  8192. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8193. Details = dayAndCostDatas
  8194. };
  8195. return Ok(JsonView(data));
  8196. }
  8197. else if (subType == 5) //5:公杂费
  8198. {
  8199. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8200. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8201. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8202. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8203. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8204. {
  8205. SubId = dac.Id,
  8206. DiId = dac.DiId,
  8207. Type = dac.Type,
  8208. Days = dac.Days,
  8209. NationalTravelFeeId = dac.NationalTravelFeeId,
  8210. Arae = $"{ntf.Country}-{ntf.City}",
  8211. Cost = dac.Cost,
  8212. Currency = dac.Currency,
  8213. CurrencyName = sd.Name,
  8214. SubTotal = dac.SubTotal,
  8215. })
  8216. .ToArray();
  8217. var data = new ChoiceMobileSubInfo3To6View()
  8218. {
  8219. ParentId = eecInfo.Id,
  8220. Choice = eecInfo.ChoiceFive,
  8221. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8222. Details = dayAndCostDatas
  8223. };
  8224. return Ok(JsonView(data));
  8225. }
  8226. else if (subType == 6) //6:培训费
  8227. {
  8228. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8229. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8230. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8231. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8232. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8233. {
  8234. SubId = dac.Id,
  8235. DiId = dac.DiId,
  8236. Type = dac.Type,
  8237. Days = dac.Days,
  8238. NationalTravelFeeId = dac.NationalTravelFeeId,
  8239. Arae = $"{ntf.Country}-{ntf.City}",
  8240. Cost = dac.Cost,
  8241. Currency = dac.Currency,
  8242. CurrencyName = sd.Name,
  8243. SubTotal = dac.SubTotal,
  8244. })
  8245. .ToArray();
  8246. var data = new ChoiceMobileSubInfo3To6View()
  8247. {
  8248. ParentId = eecInfo.Id,
  8249. Choice = eecInfo.ChoiceSix,
  8250. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8251. Details = dayAndCostDatas
  8252. };
  8253. return Ok(JsonView(data));
  8254. }
  8255. else if (subType == 7) //7:其他
  8256. {
  8257. //其他款项
  8258. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8259. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8260. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8261. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8262. .OrderBy((dop, sd1, sd2) => dop.Index)
  8263. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8264. {
  8265. SubId = dop.Id,
  8266. DiId = dop.Diid,
  8267. Index = dop.Index,
  8268. SetDataId = dop.SetDataId,
  8269. SetDataName = sd1.Name,
  8270. Cost = dop.Cost,
  8271. Currency = dop.Currency,
  8272. CurrencyName = sd2.Name,
  8273. SubTotal = dop.SubTotal,
  8274. Remark = dop.Remark,
  8275. })
  8276. .ToArray();
  8277. var data = new ChoiceSevenMobileSubInfoView()
  8278. {
  8279. ParentId = eecInfo.Id,
  8280. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8281. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8282. Details = otherData
  8283. };
  8284. return Ok(JsonView(data));
  8285. }
  8286. return Ok(JsonView(false));
  8287. }
  8288. #region op
  8289. /// <summary>
  8290. /// 移动端更新费用消息通知
  8291. /// </summary>
  8292. /// <param name="diid"></param>
  8293. /// <param name="id"></param>
  8294. /// <param name="currUserId"></param>
  8295. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8296. {
  8297. try
  8298. {
  8299. ////生成默认文件pdf并且通知人员
  8300. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8301. //{
  8302. // DiId = diid,
  8303. // ExportType = 1,
  8304. // SubTypeId = 1005
  8305. //}, "pdf");
  8306. ////发送通知
  8307. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8308. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8309. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8310. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8311. ////汇率信息记录
  8312. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8313. }
  8314. catch (Exception ex)
  8315. {
  8316. //记录日志
  8317. throw;
  8318. }
  8319. }
  8320. /// <summary>
  8321. /// 验证出入境费用数据是否存在
  8322. /// 不存在添加
  8323. /// </summary>
  8324. /// <param name="diId"></param>
  8325. /// <param name="currUserId"></param>
  8326. /// <returns></returns>
  8327. /// <exception cref="CustomException"></exception>
  8328. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8329. {
  8330. var parentId = 0;
  8331. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8332. if (info != null) {
  8333. parentId = info.Id;
  8334. }
  8335. else
  8336. {
  8337. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8338. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8339. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8340. parentId = addId;
  8341. }
  8342. return parentId;
  8343. }
  8344. /// <summary>
  8345. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8346. /// </summary>
  8347. /// <returns></returns>
  8348. [HttpPost]
  8349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8350. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8351. {
  8352. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8353. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8354. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8355. //验证编辑权限
  8356. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8357. if (!isEdit) return Ok(JsonView(false, msg));
  8358. var permissions = new List<Grp_EnterExitCostPermission>();
  8359. foreach (var userId in dto.UserIds)
  8360. {
  8361. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8362. }
  8363. if (permissions.Any())
  8364. {
  8365. _sqlSugar.BeginTran();
  8366. try
  8367. {
  8368. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8369. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8370. if (result < 1)
  8371. {
  8372. _sqlSugar.RollbackTran();
  8373. return Ok(JsonView(false));
  8374. }
  8375. }
  8376. catch (Exception ex)
  8377. {
  8378. _sqlSugar.RollbackTran();
  8379. return Ok(JsonView(false, ex.Message));
  8380. }
  8381. _sqlSugar.CommitTran();
  8382. return Ok(JsonView(true));
  8383. }
  8384. return Ok(JsonView(false));
  8385. }
  8386. /// <summary>
  8387. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8388. /// </summary>
  8389. /// <returns></returns>
  8390. [HttpPost]
  8391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8392. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8393. {
  8394. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8395. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8396. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8397. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8398. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8399. int id = dto.Id;
  8400. if (id <= 0) //add
  8401. {
  8402. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8403. if (add < 1) return Ok(JsonView(false));
  8404. id = add;
  8405. }
  8406. else //update
  8407. {
  8408. //验证编辑权限
  8409. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8410. if (!isEdit) return Ok(JsonView(false, msg));
  8411. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8412. if (upd < 1) return Ok(JsonView(false));
  8413. }
  8414. #region 汇率变更时更改币种相关费用
  8415. var opDayCosts = new List<Grp_DayAndCost>();
  8416. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8417. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8418. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8419. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8420. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8421. .Select((dac, sd) => new {
  8422. dac.Id,
  8423. dac.DiId,
  8424. CurrencyCode = sd.Name,
  8425. dac.Cost
  8426. })
  8427. .ToList();
  8428. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8429. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8430. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8431. .Select((dop, sd) => new {
  8432. dop.Id,
  8433. dop.Diid,
  8434. CurrencyCode = sd.Name,
  8435. dop.Cost
  8436. })
  8437. .ToList();
  8438. if (dayCosts.Count > 0)
  8439. {
  8440. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8441. foreach (var dc in new_dayCosts)
  8442. {
  8443. var thisCurrency = dc.Key.ToUpper();
  8444. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8445. if (thisRate == 0.00M) continue;
  8446. foreach (var dcSub in dc)
  8447. {
  8448. opDayCosts.Add(new Grp_DayAndCost() {
  8449. Id = dcSub.Id,
  8450. DiId = dcSub.DiId,
  8451. Cost = dcSub.Cost,
  8452. SubTotal = dcSub.Cost * thisRate,
  8453. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8454. });
  8455. }
  8456. }
  8457. if (opDayCosts.Count > 0)
  8458. {
  8459. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8460. }
  8461. }
  8462. if (dayOtherCosts.Count > 0)
  8463. {
  8464. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8465. foreach (var dc in new_dayOtherCosts)
  8466. {
  8467. var thisCurrency = dc.Key.ToUpper();
  8468. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8469. if (thisRate == 0.00M) continue;
  8470. foreach (var dcSub in dc)
  8471. {
  8472. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8473. {
  8474. Id = dcSub.Id,
  8475. Diid = dcSub.Diid,
  8476. Cost = dcSub.Cost,
  8477. SubTotal = dcSub.Cost * thisRate,
  8478. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8479. });
  8480. }
  8481. }
  8482. if (opDayOtherCosts.Count > 0)
  8483. {
  8484. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8485. }
  8486. }
  8487. #endregion
  8488. //消息通知
  8489. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8490. //汇率信息记录
  8491. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8492. return Ok(JsonView(new { parentId = id }));
  8493. }
  8494. /// <summary>
  8495. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8496. /// </summary>
  8497. /// <returns></returns>
  8498. [HttpPost]
  8499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8500. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8501. {
  8502. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8503. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8504. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8505. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8506. int id = dto.Id;
  8507. if (id <= 0) //add
  8508. {
  8509. checkboxInfo.CreateUserId = dto.CurrUserId;
  8510. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8511. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8512. if (add < 1) return Ok(JsonView(false));
  8513. }
  8514. else //update
  8515. {
  8516. //验证编辑权限
  8517. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8518. if (!isEdit) return Ok(JsonView(false, msg));
  8519. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8520. .UpdateColumns(x => new {
  8521. x.ChoiceOne,
  8522. x.ChoiceTwo,
  8523. x.SumJJC,
  8524. x.SumGWC,
  8525. x.SumTDC,
  8526. x.ChoiceThree,
  8527. x.ChoiceFour,
  8528. x.ChoiceFive,
  8529. x.ChoiceSix,
  8530. x.OtherExpenses_Checked
  8531. })
  8532. .Where(x => x.Id == id)
  8533. .ExecuteCommandAsync();
  8534. if (upd < 1) return Ok(JsonView(false));
  8535. }
  8536. return Ok(JsonView(new { parentId = id }));
  8537. }
  8538. /// <summary>
  8539. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8540. /// </summary>
  8541. /// <returns></returns>
  8542. [HttpPost]
  8543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8544. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8545. {
  8546. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8547. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8548. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8549. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8550. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8551. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8552. var checkboxInfo = new Grp_EnterExitCost() {
  8553. Id = id,
  8554. DiId = diId,
  8555. CreateUserId = currUserId
  8556. };
  8557. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8558. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8559. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8560. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8561. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8562. if (id <= 0) //add
  8563. {
  8564. checkboxInfo.CreateUserId = dto.CurrUserId;
  8565. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8566. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8567. if (add < 1) return Ok(JsonView(false));
  8568. }
  8569. else //update
  8570. {
  8571. //验证编辑权限
  8572. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8573. if (!isEdit) return Ok(JsonView(false, msg));
  8574. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8575. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8576. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8577. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8578. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8579. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8580. .Where(x => x.Id == id)
  8581. .ExecuteCommandAsync();
  8582. if (upd < 1) return Ok(JsonView(false));
  8583. }
  8584. return Ok(JsonView(new { parentId = id }));
  8585. }
  8586. /// <summary>
  8587. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8588. /// </summary>
  8589. /// <returns></returns>
  8590. [HttpPost]
  8591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8592. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8593. {
  8594. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8595. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8596. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8597. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8598. info.FirstItemRemark = dto.FirstItemRemark;
  8599. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8600. int id = dto.Id;
  8601. if (id <= 0) //add
  8602. {
  8603. info.CreateUserId = dto.CurrUserId;
  8604. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8605. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8606. if (add < 1) return Ok(JsonView(false));
  8607. id = add;
  8608. }
  8609. else //update
  8610. {
  8611. //验证编辑权限
  8612. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8613. if (!isEdit) return Ok(JsonView(false, msg));
  8614. var upd = await _sqlSugar.Updateable(info)
  8615. .UpdateColumns(x => new {
  8616. x.ChoiceOne,
  8617. x.InsidePay,
  8618. x.VisaRemark,
  8619. x.Visa,
  8620. x.Service,
  8621. x.Safe,
  8622. x.Ticket,
  8623. x.HeSuan,
  8624. x.YiMiao,
  8625. x.FirstItemRemark
  8626. })
  8627. .Where(x => x.Id == id)
  8628. .ExecuteCommandAsync();
  8629. if (upd < 1) return Ok(JsonView(false));
  8630. }
  8631. //消息通知
  8632. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8633. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8634. }
  8635. /// <summary>
  8636. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8637. /// </summary>
  8638. /// <returns></returns>
  8639. [HttpPost]
  8640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8641. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8642. {
  8643. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8644. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8645. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8646. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8647. info.OutsideJJPay = dto.OutsideJJPay;
  8648. info.OutsideGWPay = dto.OutsideGWPay;
  8649. info.OutsideTDPay = dto.OutsideTDPay;
  8650. info.AirJJ = dto.AirJJ;
  8651. info.AirGW = dto.AirGW;
  8652. info.AirTD = dto.AirTD;
  8653. info.CityTranffic = dto.CityTranffic;
  8654. info.TwoItemRemark = dto.TwoItemRemark;
  8655. info.SumJJC = dto.ChoiceTwoJJ;
  8656. info.SumGWC = dto.ChoiceTwoGW;
  8657. info.SumTDC = dto.ChoiceTwoTD;
  8658. int id = dto.Id;
  8659. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8660. if (id <= 0) //add
  8661. {
  8662. info.CreateUserId = dto.CurrUserId;
  8663. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8664. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8665. if (addId <= 0) return Ok(JsonView(false));
  8666. id = addId;
  8667. }
  8668. else //update
  8669. {
  8670. //验证编辑权限
  8671. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8672. if (!isEdit) return Ok(JsonView(false, msg));
  8673. var upd = await _sqlSugar.Updateable(info)
  8674. .UpdateColumns(x => new {
  8675. x.SumJJC,
  8676. x.OutsideJJPay,
  8677. x.SumGWC,
  8678. x.OutsideGWPay,
  8679. x.SumTDC,
  8680. x.OutsideTDPay,
  8681. x.AirJJ,
  8682. x.AirGW,
  8683. x.AirTD,
  8684. x.CityTranffic,
  8685. x.TwoItemRemark
  8686. })
  8687. .Where(x => x.Id == id)
  8688. .ExecuteCommandAsync();
  8689. if (upd <1) return Ok(JsonView(false));
  8690. }
  8691. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8692. gwcItemTotal = info.AirGW + info.CityTranffic;
  8693. tdcItemTotal = info.AirTD + info.CityTranffic;
  8694. //消息通知
  8695. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8696. return Ok(JsonView(new
  8697. {
  8698. parentId = id,
  8699. choiceTwoJJ = dto.ChoiceTwoJJ,
  8700. jjcItemTotal = jjcItemTotal,
  8701. choiceTwoGW = dto.ChoiceTwoGW,
  8702. gwcItemTotal = gwcItemTotal,
  8703. choiceTwoTD = dto.ChoiceTwoTD,
  8704. tdcItemTotal = tdcItemTotal
  8705. }));
  8706. }
  8707. /// <summary>
  8708. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8709. /// </summary>
  8710. /// <returns></returns>
  8711. [HttpPost]
  8712. [ApiExplorerSettings(IgnoreApi = true)]
  8713. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8714. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8715. {
  8716. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8717. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8718. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8719. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8720. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8721. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8722. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8723. var infos = infos1.Select(x => new Grp_DayAndCost
  8724. {
  8725. Id = x.Id,
  8726. DiId = dto.DiId,
  8727. Type = dto.FeeType,
  8728. Days = x.Days,
  8729. NationalTravelFeeId = x.NationalTravelFeeId,
  8730. Cost = x.Cost,
  8731. Currency = x.Currency,
  8732. SubTotal = x.SubTotal,
  8733. CreateUserId = dto.CurrUserId
  8734. })
  8735. .ToList();
  8736. var adds = infos.Where(x => x.Id <= 0).ToList();
  8737. var upds = infos.Where(x => x.Id > 0).ToList();
  8738. if (adds.Count > 0)
  8739. {
  8740. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8741. if (add < 1) return Ok(JsonView(false));
  8742. }
  8743. if (upds.Count > 0)
  8744. {
  8745. var upd = await _sqlSugar.Updateable(adds)
  8746. .UpdateColumns(x => new
  8747. {
  8748. x.Days,
  8749. x.NationalTravelFeeId,
  8750. x.Cost,
  8751. x.Currency,
  8752. x.SubTotal
  8753. })
  8754. .WhereColumns(x => new { x.Id })
  8755. .ExecuteCommandAsync();
  8756. if (upd < 1) return Ok(JsonView(false));
  8757. }
  8758. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8759. //消息通知
  8760. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8761. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8762. return Ok(JsonView(new { itemTotal = itemTotal }));
  8763. }
  8764. /// <summary>
  8765. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8766. /// </summary>
  8767. /// <returns></returns>
  8768. [HttpPost]
  8769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8770. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8771. {
  8772. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8773. int subId = dto.SubId, feeType = dto.FeeType;
  8774. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8775. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8776. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8777. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8778. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8779. subInfo.Id = subId;
  8780. subInfo.DiId = dto.DiId;
  8781. if (feeType == 3) subInfo.Type = 1;
  8782. else if (feeType == 4) subInfo.Type = 2;
  8783. else if (feeType == 5) subInfo.Type = 3;
  8784. else if (feeType == 6) subInfo.Type = 4;
  8785. subInfo.CreateUserId = dto.CurrUserId;
  8786. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8787. if (parentId < 1) return Ok(JsonView(false));
  8788. //子表op
  8789. if (subId < 1)
  8790. {
  8791. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8792. if (subAdd < 1) return Ok(JsonView(false));
  8793. }
  8794. else
  8795. {
  8796. //验证编辑权限
  8797. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8798. if (!isEdit) return Ok(JsonView(false, msg));
  8799. var subUpd = await _sqlSugar.Updateable(subInfo)
  8800. .UpdateColumns(x => new
  8801. {
  8802. x.Days,
  8803. x.NationalTravelFeeId,
  8804. x.Cost,
  8805. x.Currency,
  8806. x.SubTotal
  8807. })
  8808. .WhereColumns(x => new { x.Id })
  8809. .ExecuteCommandAsync();
  8810. if (subUpd < 1) return Ok(JsonView(false));
  8811. }
  8812. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8813. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8814. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8815. }
  8816. /// <summary>
  8817. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8818. /// </summary>
  8819. /// <returns></returns>
  8820. [HttpPost]
  8821. [ApiExplorerSettings(IgnoreApi = true)]
  8822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8823. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8824. {
  8825. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8826. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8827. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8828. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8829. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8830. {
  8831. Id = x.Id,
  8832. Diid = dto.DiId,
  8833. SetDataId = x.SetDataId,
  8834. Index = x.Index,
  8835. Cost = x.Cost,
  8836. Currency = x.Currency,
  8837. SubTotal = x.SubTotal,
  8838. CreateUserId = dto.CurrUserId,
  8839. Remark = x.Remark
  8840. }).ToList();
  8841. var adds = infos.Where(x => x.Id <= 0).ToList();
  8842. var upds = infos.Where(x => x.Id > 0).ToList();
  8843. if (adds.Count > 0)
  8844. {
  8845. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8846. if (add < 1) return Ok(JsonView(false));
  8847. }
  8848. if (upds.Count > 0)
  8849. {
  8850. var upd = await _sqlSugar.Updateable(adds)
  8851. .UpdateColumns(x => new
  8852. {
  8853. x.Index,
  8854. x.SetDataId,
  8855. x.Cost,
  8856. x.Currency,
  8857. x.SubTotal,
  8858. x.Remark
  8859. })
  8860. .WhereColumns(x => new { x.Id })
  8861. .ExecuteCommandAsync();
  8862. if (upd < 1) return Ok(JsonView(false));
  8863. }
  8864. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8865. //消息通知
  8866. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8867. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8868. return Ok(JsonView(new { itemTotal = itemTotal }));
  8869. }
  8870. /// <summary>
  8871. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8872. /// </summary>
  8873. /// <returns></returns>
  8874. [HttpPost]
  8875. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8876. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8877. {
  8878. int subId = dto.SubId;
  8879. int diId = dto.Diid;
  8880. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8881. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8882. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8883. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8884. subInfo.Id = subId;
  8885. subInfo.Diid = dto.Diid;
  8886. subInfo.CreateUserId = dto.CurrUserId;
  8887. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8888. if (parentId < 1) return Ok(JsonView(false));
  8889. #region 子表op
  8890. if (subId < 1)//add
  8891. {
  8892. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8893. if (subAdd < 1) return Ok(JsonView(false));
  8894. }
  8895. else //upd
  8896. {
  8897. //验证编辑权限
  8898. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8899. if (!isEdit) return Ok(JsonView(false, msg));
  8900. var subUpd = await _sqlSugar.Updateable(subInfo)
  8901. .UpdateColumns(x => new
  8902. {
  8903. x.Index,
  8904. x.SetDataId,
  8905. x.Cost,
  8906. x.Currency,
  8907. x.SubTotal,
  8908. x.Remark
  8909. })
  8910. .WhereColumns(x => new { x.Id })
  8911. .ExecuteCommandAsync();
  8912. if (subUpd < 1) return Ok(JsonView(false));
  8913. }
  8914. #endregion
  8915. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8916. //消息通知
  8917. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8918. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8919. }
  8920. /// <summary>
  8921. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8922. /// </summary>
  8923. /// <returns></returns>
  8924. [HttpPost]
  8925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8926. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8927. {
  8928. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8929. if (data.Code != 0)
  8930. {
  8931. return Ok(JsonView(false, data.Msg));
  8932. }
  8933. return Ok(JsonView(true, "操作成功!", data.Data));
  8934. }
  8935. /// <summary>
  8936. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8937. /// </summary>
  8938. /// <param name="dto"></param>
  8939. /// <returns></returns>
  8940. [HttpPost]
  8941. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8942. {
  8943. var data = new Grp_DayOtherPrice()
  8944. {
  8945. Id = dto.Id,
  8946. IsDel = 1,
  8947. DeleteUserId = dto.DeleteUserId,
  8948. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8949. };
  8950. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8951. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8952. return Ok(JsonView(false,"删除失败!"));
  8953. }
  8954. #endregion
  8955. #endregion
  8956. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8957. /// <summary>
  8958. /// 出入境费用-草稿 移动端
  8959. /// 获取币种基础数据(含逻辑处理)
  8960. /// </summary>
  8961. /// <returns></returns>
  8962. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  8963. {
  8964. //默认币种显示
  8965. var _currencyInfos = _currencyInit;
  8966. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  8967. if (_currencyRate.Count > 0)
  8968. {
  8969. foreach (var item in _currencyInfos)
  8970. {
  8971. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  8972. if (rateInfo != null)
  8973. {
  8974. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  8975. rate1 *= 1.035M;
  8976. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  8977. }
  8978. }
  8979. }
  8980. return _currencyInfos;
  8981. }
  8982. /// <summary>
  8983. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8984. /// </summary>
  8985. /// <returns></returns>
  8986. [HttpPost]
  8987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8988. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  8989. {
  8990. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8991. //SetDataInfoView
  8992. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  8993. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  8994. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  8995. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  8996. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  8997. //默认币种显示
  8998. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8999. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9000. return Ok(JsonView(true, "查询成功!", new
  9001. {
  9002. WordTypeData = _WordTypeData,
  9003. ExcelTypeData = _ExcelTypeData,
  9004. CurrencyInit = _currencyInfos,
  9005. viewPermissionData= viewPermissionData
  9006. }));
  9007. }
  9008. /// <summary>
  9009. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  9010. /// </summary>
  9011. /// <returns></returns>
  9012. [HttpPost]
  9013. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9014. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9015. {
  9016. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9017. RefAsync<int> total = 0;
  9018. int diId = 0;
  9019. var status = int.TryParse(dto.GroupName, out diId);
  9020. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9021. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9022. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9023. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9024. .Select(x => new
  9025. {
  9026. Id = x.Id,
  9027. GroupName = x.TeamName
  9028. })
  9029. .OrderByDescending(x => x.Id)
  9030. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9031. return Ok(JsonView(true, "查询成功!", data, total));
  9032. }
  9033. /// <summary>
  9034. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9035. /// </summary>
  9036. /// <returns></returns>
  9037. [HttpPost]
  9038. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9039. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9040. {
  9041. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9042. RefAsync<int> total = 0;
  9043. var data = await _sqlSugar.Queryable<Sys_SetData>()
  9044. .Where(x => x.IsDel == 0 && x.STid == 66)
  9045. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9046. .Select(x => new
  9047. {
  9048. id = x.Id,
  9049. name = x.Name,
  9050. remark = x.Remark,
  9051. })
  9052. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9053. return Ok(JsonView(true, "查询成功!", data, total));
  9054. }
  9055. /// <summary>
  9056. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9057. /// </summary>
  9058. /// <returns></returns>
  9059. [HttpPost]
  9060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9061. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9062. {
  9063. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9064. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9065. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, 2274, 98);
  9066. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9067. var groupOtherRateData = groupRateData.TeamRates;
  9068. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9069. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9070. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9071. groupOtherRateData = groupOtherRateData
  9072. .Select(x => new TeamRateDescAddCurrencyIdView
  9073. {
  9074. CurrencyId = x.CurrencyId,
  9075. CurrencyName = x.CurrencyName,
  9076. CurrencyCode = x.CurrencyCode,
  9077. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9078. }).ToList();
  9079. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9080. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9081. }
  9082. /// <summary>
  9083. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  9084. /// </summary>
  9085. /// <returns></returns>
  9086. [HttpPost]
  9087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9088. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9089. {
  9090. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9091. var tipsData = new List<int>() { 1, 2, 3 };
  9092. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9093. if (dto.TipsType == 1)
  9094. {
  9095. //默认币种显示
  9096. var _currencyInfos = _currencyInit;
  9097. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  9098. List<dynamic> reteInfos = new List<dynamic>();
  9099. if (_currencyRate.Count > 0)
  9100. {
  9101. foreach (var item in _currencyInfos)
  9102. {
  9103. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9104. if (rateInfo != null)
  9105. {
  9106. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9107. decimal rate1 = item.Rate;
  9108. rate1 *= 1.03M;
  9109. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9110. reteInfos.Add(new
  9111. {
  9112. currCode = item.CurrencyCode,
  9113. currName = item.CurrencyName,
  9114. rate = rate2,
  9115. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9116. });
  9117. }
  9118. }
  9119. }
  9120. return Ok(JsonView(true, "查询成功!", reteInfos));
  9121. }
  9122. else if (dto.TipsType == 2)
  9123. {
  9124. }
  9125. else if (dto.TipsType == 3)
  9126. {
  9127. }
  9128. return Ok(JsonView(false));
  9129. }
  9130. /// <summary>
  9131. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  9132. /// </summary>
  9133. /// <returns></returns>
  9134. [HttpPost]
  9135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9136. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9137. {
  9138. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9139. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9140. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9141. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9142. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9143. if (eecInfo == null) return Ok(mobileInfo);
  9144. //验证查看权限
  9145. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9146. if (!isView) return Ok(JsonView(false, msg));
  9147. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  9148. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9149. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9150. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9151. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9152. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9153. {
  9154. ParentId = dac.ParentId,
  9155. SubId = dac.Id,
  9156. Type = dac.Type,
  9157. Days = dac.Days,
  9158. NationalTravelFeeId = dac.NationalTravelFeeId,
  9159. Arae = $"{ntf.Country}-{ntf.City}",
  9160. Cost = dac.Cost,
  9161. Currency = dac.Currency,
  9162. CurrencyName = sd.Name,
  9163. SubTotal = dac.SubTotal,
  9164. })
  9165. .ToList();
  9166. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9167. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9168. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9169. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9170. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9171. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9172. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9173. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9174. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9175. //其他款项
  9176. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9177. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9178. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9179. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9180. .OrderBy((dop, sd1, sd2) => dop.Index)
  9181. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9182. {
  9183. ParentId = dop.ParentId,
  9184. SubId = dop.Id,
  9185. Index = dop.Index,
  9186. SetDataId = dop.SetDataId,
  9187. SetDataName = sd1.Name,
  9188. Cost = dop.Cost,
  9189. Currency = dop.Currency,
  9190. CurrencyName = sd2.Remark,
  9191. SubTotal = dop.SubTotal,
  9192. Remark = dop.Remark,
  9193. })
  9194. .ToArray();
  9195. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9196. return Ok(mobileInfo);
  9197. }
  9198. /// <summary>
  9199. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  9200. /// </summary>
  9201. /// <returns></returns>
  9202. [HttpPost]
  9203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9204. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  9205. {
  9206. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9207. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9208. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9209. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9210. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9211. //验证查看权限
  9212. (bool isView, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId);
  9213. if (!isView) return Ok(JsonView(false, msg));
  9214. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9215. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9216. var subType = dto.SubType;
  9217. if (subType == 1) //1:境内费用
  9218. {
  9219. var oneData = new ChoiceOneMobileSubInfoView()
  9220. {
  9221. Id = eecInfo.Id,
  9222. ChoiceOne = eecInfo.ChoiceOne,
  9223. ChoiceOneTotalCost = eecInfo.InsidePay,
  9224. Visa = eecInfo.Visa,
  9225. VisaRemark = eecInfo.VisaRemark,
  9226. YiMiao = eecInfo.YiMiao,
  9227. HeSuan = eecInfo.HeSuan,
  9228. Service = eecInfo.Service,
  9229. Ticket = eecInfo.Ticket,
  9230. Safe = eecInfo.Safe,
  9231. FirstItemRemark = eecInfo.FirstItemRemark
  9232. };
  9233. return Ok(JsonView(oneData));
  9234. }
  9235. else if (subType == 2) //2:国际旅费
  9236. {
  9237. var twoData = new ChoiceTwoMobileSubInfoView()
  9238. {
  9239. Id = eecInfo.Id,
  9240. ChoiceTwoJJ = eecInfo.SumJJC,
  9241. OutsideJJPay = eecInfo.OutsideJJPay,
  9242. ChoiceTwoGW = eecInfo.SumGWC,
  9243. OutsideGWPay = eecInfo.OutsideGWPay,
  9244. ChoiceTwoTD = eecInfo.SumTDC,
  9245. OutsideTDPay = eecInfo.OutsideTDPay,
  9246. AirJJ = eecInfo.AirJJ,
  9247. AirGW = eecInfo.AirGW,
  9248. AirTD = eecInfo.AirTD,
  9249. CityTranffic = eecInfo.CityTranffic,
  9250. TwoItemRemark = eecInfo.TwoItemRemark
  9251. };
  9252. return Ok(JsonView(twoData));
  9253. }
  9254. else if (subType == 3) //3:住宿费
  9255. {
  9256. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9257. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9258. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9259. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  9260. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9261. {
  9262. ParentId = dac.ParentId,
  9263. SubId = dac.Id,
  9264. Type = dac.Type,
  9265. Days = dac.Days,
  9266. NationalTravelFeeId = dac.NationalTravelFeeId,
  9267. Arae = $"{ntf.Country}-{ntf.City}",
  9268. Cost = dac.Cost,
  9269. Currency = dac.Currency,
  9270. CurrencyName = sd.Name,
  9271. SubTotal = dac.SubTotal,
  9272. })
  9273. .ToArray();
  9274. var data = new ChoiceDraftMobileSubInfo3To6View()
  9275. {
  9276. ParentId = eecInfo.Id,
  9277. Choice = eecInfo.ChoiceThree,
  9278. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9279. Details = dayAndCostDatas
  9280. };
  9281. return Ok(JsonView(data));
  9282. }
  9283. else if (subType == 4) //4:伙食费
  9284. {
  9285. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9286. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9287. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9288. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  9289. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9290. {
  9291. ParentId = dac.ParentId,
  9292. SubId = dac.Id,
  9293. Type = dac.Type,
  9294. Days = dac.Days,
  9295. NationalTravelFeeId = dac.NationalTravelFeeId,
  9296. Arae = $"{ntf.Country}-{ntf.City}",
  9297. Cost = dac.Cost,
  9298. Currency = dac.Currency,
  9299. CurrencyName = sd.Name,
  9300. SubTotal = dac.SubTotal,
  9301. })
  9302. .ToArray();
  9303. var data = new ChoiceDraftMobileSubInfo3To6View()
  9304. {
  9305. ParentId = eecInfo.Id,
  9306. Choice = eecInfo.ChoiceFour,
  9307. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9308. Details = dayAndCostDatas
  9309. };
  9310. return Ok(JsonView(data));
  9311. }
  9312. else if (subType == 5) //5:公杂费
  9313. {
  9314. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9315. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9316. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9317. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  9318. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9319. {
  9320. ParentId = dac.ParentId,
  9321. SubId = dac.Id,
  9322. Type = dac.Type,
  9323. Days = dac.Days,
  9324. NationalTravelFeeId = dac.NationalTravelFeeId,
  9325. Arae = $"{ntf.Country}-{ntf.City}",
  9326. Cost = dac.Cost,
  9327. Currency = dac.Currency,
  9328. CurrencyName = sd.Name,
  9329. SubTotal = dac.SubTotal,
  9330. })
  9331. .ToArray();
  9332. var data = new ChoiceDraftMobileSubInfo3To6View()
  9333. {
  9334. ParentId = eecInfo.Id,
  9335. Choice = eecInfo.ChoiceFive,
  9336. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9337. Details = dayAndCostDatas
  9338. };
  9339. return Ok(JsonView(data));
  9340. }
  9341. else if (subType == 6) //6:培训费
  9342. {
  9343. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9344. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9345. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9346. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  9347. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  9348. {
  9349. ParentId = dac.ParentId,
  9350. SubId = dac.Id,
  9351. Type = dac.Type,
  9352. Days = dac.Days,
  9353. NationalTravelFeeId = dac.NationalTravelFeeId,
  9354. Arae = $"{ntf.Country}-{ntf.City}",
  9355. Cost = dac.Cost,
  9356. Currency = dac.Currency,
  9357. CurrencyName = sd.Name,
  9358. SubTotal = dac.SubTotal,
  9359. })
  9360. .ToArray();
  9361. var data = new ChoiceDraftMobileSubInfo3To6View()
  9362. {
  9363. ParentId = eecInfo.Id,
  9364. Choice = eecInfo.ChoiceSix,
  9365. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9366. Details = dayAndCostDatas
  9367. };
  9368. return Ok(JsonView(data));
  9369. }
  9370. else if (subType == 7) //7:其他
  9371. {
  9372. //其他款项
  9373. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9374. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9375. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9376. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9377. .OrderBy((dop, sd1, sd2) => dop.Index)
  9378. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  9379. {
  9380. ParentId = dop.ParentId,
  9381. SubId = dop.Id,
  9382. Index = dop.Index,
  9383. SetDataId = dop.SetDataId,
  9384. SetDataName = sd1.Name,
  9385. Cost = dop.Cost,
  9386. Currency = dop.Currency,
  9387. CurrencyName = sd2.Name,
  9388. SubTotal = dop.SubTotal,
  9389. Remark = dop.Remark,
  9390. })
  9391. .ToArray();
  9392. var data = new ChoiceSevenDraftMobileSubInfoView()
  9393. {
  9394. ParentId = eecInfo.Id,
  9395. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9396. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9397. Details = otherData
  9398. };
  9399. return Ok(JsonView(data));
  9400. }
  9401. return Ok(JsonView(false));
  9402. }
  9403. #region op
  9404. /// <summary>
  9405. /// 移动端更新费用消息通知
  9406. /// </summary>
  9407. /// <param name="diid"></param>
  9408. /// <param name="id"></param>
  9409. /// <param name="currUserId"></param>
  9410. private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  9411. {
  9412. try
  9413. {
  9414. ////生成默认文件pdf并且通知人员
  9415. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9416. //{
  9417. // DiId = draftId,
  9418. // ExportType = 1,
  9419. // SubTypeId = 1005
  9420. //}, "pdf");
  9421. ////发送通知
  9422. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9423. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9424. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9425. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  9426. ////汇率信息记录
  9427. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9428. }
  9429. catch (Exception ex)
  9430. {
  9431. //记录日志
  9432. throw;
  9433. }
  9434. }
  9435. /// <summary>
  9436. /// 验证出入境费用数据是否存在
  9437. /// 不存在添加
  9438. /// </summary>
  9439. /// <param name="draftId"></param>
  9440. /// <param name="currUserId"></param>
  9441. /// <returns></returns>
  9442. /// <exception cref="CustomException"></exception>
  9443. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  9444. {
  9445. var parentId = 0;
  9446. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9447. if (info != null) parentId = info.Id;
  9448. else
  9449. {
  9450. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  9451. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9452. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9453. parentId = addId;
  9454. }
  9455. return parentId;
  9456. }
  9457. /// <summary>
  9458. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  9459. /// </summary>
  9460. /// <returns></returns>
  9461. [HttpPost]
  9462. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9463. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  9464. {
  9465. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9466. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9467. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9468. //验证编辑权限
  9469. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9470. if (!isEdit) return Ok(JsonView(false, msg));
  9471. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9472. foreach (var userId in dto.UserIds)
  9473. {
  9474. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9475. }
  9476. if (permissions.Any())
  9477. {
  9478. _sqlSugar.BeginTran();
  9479. try
  9480. {
  9481. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9482. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9483. if (result < 1)
  9484. {
  9485. _sqlSugar.RollbackTran();
  9486. return Ok(JsonView(false));
  9487. }
  9488. }
  9489. catch (Exception ex)
  9490. {
  9491. _sqlSugar.RollbackTran();
  9492. return Ok(JsonView(false, ex.Message));
  9493. }
  9494. _sqlSugar.CommitTran();
  9495. return Ok(JsonView(true));
  9496. }
  9497. return Ok(JsonView(false));
  9498. }
  9499. /// <summary>
  9500. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  9501. /// </summary>
  9502. /// <returns></returns>
  9503. [HttpPost]
  9504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9505. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  9506. {
  9507. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9508. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9509. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9510. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9511. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9512. int id = dto.DraftId;
  9513. if (id <= 0) //add
  9514. {
  9515. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9516. if (add < 1) return Ok(JsonView(false));
  9517. id = add;
  9518. }
  9519. else //update
  9520. {
  9521. //验证编辑权限
  9522. (bool isEdit, string msg) = await _enterExitCostDraftRep.MobilePermissionsValidationAsync(dto.DraftId, dto.CurrUserId, 2);
  9523. if (!isEdit) return Ok(JsonView(false, msg));
  9524. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  9525. if (upd < 1) return Ok(JsonView(false));
  9526. }
  9527. #region 汇率变更时更改币种相关费用
  9528. var opDayCosts = new List<Grp_DayAndCostDraft>();
  9529. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  9530. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9531. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9532. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9533. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  9534. .Select((dac, sd) => new
  9535. {
  9536. dac.Id,
  9537. dac.ParentId,
  9538. CurrencyCode = sd.Name,
  9539. dac.Cost
  9540. })
  9541. .ToList();
  9542. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9543. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9544. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  9545. .Select((dop, sd) => new
  9546. {
  9547. dop.Id,
  9548. dop.ParentId,
  9549. CurrencyCode = sd.Name,
  9550. dop.Cost
  9551. })
  9552. .ToList();
  9553. if (dayCosts.Count > 0)
  9554. {
  9555. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9556. foreach (var dc in new_dayCosts)
  9557. {
  9558. var thisCurrency = dc.Key.ToUpper();
  9559. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9560. if (thisRate == 0.00M) continue;
  9561. foreach (var dcSub in dc)
  9562. {
  9563. opDayCosts.Add(new Grp_DayAndCostDraft()
  9564. {
  9565. Id = dcSub.Id,
  9566. ParentId = dcSub.ParentId,
  9567. Cost = dcSub.Cost,
  9568. SubTotal = dcSub.Cost * thisRate,
  9569. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9570. });
  9571. }
  9572. }
  9573. if (opDayCosts.Count > 0)
  9574. {
  9575. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9576. }
  9577. }
  9578. if (dayOtherCosts.Count > 0)
  9579. {
  9580. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9581. foreach (var dc in new_dayOtherCosts)
  9582. {
  9583. var thisCurrency = dc.Key.ToUpper();
  9584. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9585. if (thisRate == 0.00M) continue;
  9586. foreach (var dcSub in dc)
  9587. {
  9588. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  9589. {
  9590. Id = dcSub.Id,
  9591. ParentId = dcSub.ParentId,
  9592. Cost = dcSub.Cost,
  9593. SubTotal = dcSub.Cost * thisRate,
  9594. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9595. });
  9596. }
  9597. }
  9598. if (opDayOtherCosts.Count > 0)
  9599. {
  9600. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9601. }
  9602. }
  9603. #endregion
  9604. ////消息通知
  9605. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9606. ////汇率信息记录
  9607. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9608. return Ok(JsonView(new { parentId = id }));
  9609. }
  9610. /// <summary>
  9611. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  9612. /// </summary>
  9613. /// <returns></returns>
  9614. [HttpPost]
  9615. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9616. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  9617. {
  9618. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9619. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9620. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9621. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9622. int id = dto.DraftId;
  9623. if (id <= 0) //add
  9624. {
  9625. checkboxInfo.CreateUserId = dto.CurrUserId;
  9626. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  9627. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9628. if (add < 1) return Ok(JsonView(false));
  9629. }
  9630. else //update
  9631. {
  9632. var upd = await _sqlSugar.Updateable(checkboxInfo)
  9633. .UpdateColumns(x => new
  9634. {
  9635. x.ChoiceOne,
  9636. x.ChoiceTwo,
  9637. x.SumJJC,
  9638. x.SumGWC,
  9639. x.SumTDC,
  9640. x.ChoiceThree,
  9641. x.ChoiceFour,
  9642. x.ChoiceFive,
  9643. x.ChoiceSix,
  9644. x.OtherExpenses_Checked
  9645. })
  9646. .Where(x => x.Id == id)
  9647. .ExecuteCommandAsync();
  9648. if (upd < 1) return Ok(JsonView(false));
  9649. }
  9650. return Ok(JsonView(new { parentId = id }));
  9651. }
  9652. /// <summary>
  9653. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框更改
  9654. /// </summary>
  9655. /// <returns></returns>
  9656. [HttpPost]
  9657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9658. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  9659. {
  9660. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  9661. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9662. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9663. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9664. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9665. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9666. var checkboxInfo = new Grp_EnterExitCostDraft()
  9667. {
  9668. Id = draftId,
  9669. CreateUserId = currUserId
  9670. };
  9671. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9672. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9673. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9674. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9675. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9676. if (draftId <= 0) //add
  9677. {
  9678. checkboxInfo.CreateUserId = dto.CurrUserId;
  9679. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9680. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9681. if (add < 1) return Ok(JsonView(false));
  9682. }
  9683. else //update
  9684. {
  9685. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  9686. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9687. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9688. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9689. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9690. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9691. .Where(x => x.Id == draftId)
  9692. .ExecuteCommandAsync();
  9693. if (upd < 1) return Ok(JsonView(false));
  9694. }
  9695. return Ok(JsonView(new { parentId = draftId }));
  9696. }
  9697. /// <summary>
  9698. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  9699. /// </summary>
  9700. /// <returns></returns>
  9701. [HttpPost]
  9702. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9703. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  9704. {
  9705. int id = dto.DraftId,currUserId = dto.CurrUserId;
  9706. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9707. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9708. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9709. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  9710. info.FirstItemRemark = dto.FirstItemRemark;
  9711. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9712. if (id <= 0) //add
  9713. {
  9714. info.CreateUserId = dto.CurrUserId;
  9715. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9716. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9717. if (add < 1) return Ok(JsonView(false));
  9718. id = add;
  9719. }
  9720. else //update
  9721. {
  9722. var upd = await _sqlSugar.Updateable(info)
  9723. .UpdateColumns(x => new
  9724. {
  9725. x.ChoiceOne,
  9726. x.InsidePay,
  9727. x.VisaRemark,
  9728. x.Visa,
  9729. x.Service,
  9730. x.Safe,
  9731. x.Ticket,
  9732. x.HeSuan,
  9733. x.YiMiao,
  9734. x.FirstItemRemark
  9735. })
  9736. .Where(x => x.Id == id)
  9737. .ExecuteCommandAsync();
  9738. if (upd < 1) return Ok(JsonView(false));
  9739. }
  9740. ////消息通知
  9741. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9742. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9743. }
  9744. /// <summary>
  9745. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  9746. /// </summary>
  9747. /// <returns></returns>
  9748. [HttpPost]
  9749. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9750. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  9751. {
  9752. int id = dto.DraftId;
  9753. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9754. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  9755. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9756. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9757. info.OutsideJJPay = dto.OutsideJJPay;
  9758. info.OutsideGWPay = dto.OutsideGWPay;
  9759. info.OutsideTDPay = dto.OutsideTDPay;
  9760. info.AirJJ = dto.AirJJ;
  9761. info.AirGW = dto.AirGW;
  9762. info.AirTD = dto.AirTD;
  9763. info.CityTranffic = dto.CityTranffic;
  9764. info.TwoItemRemark = dto.TwoItemRemark;
  9765. info.SumJJC = dto.ChoiceTwoJJ;
  9766. info.SumGWC = dto.ChoiceTwoGW;
  9767. info.SumTDC = dto.ChoiceTwoTD;
  9768. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9769. if (id <= 0) //add
  9770. {
  9771. info.CreateUserId = dto.CurrUserId;
  9772. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9773. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9774. if (addId <= 0) return Ok(JsonView(false));
  9775. id = addId;
  9776. }
  9777. else //update
  9778. {
  9779. var upd = await _sqlSugar.Updateable(info)
  9780. .UpdateColumns(x => new
  9781. {
  9782. x.SumJJC,
  9783. x.OutsideJJPay,
  9784. x.SumGWC,
  9785. x.OutsideGWPay,
  9786. x.SumTDC,
  9787. x.OutsideTDPay,
  9788. x.AirJJ,
  9789. x.AirGW,
  9790. x.AirTD,
  9791. x.CityTranffic,
  9792. x.TwoItemRemark
  9793. })
  9794. .Where(x => x.Id == id)
  9795. .ExecuteCommandAsync();
  9796. if (upd < 1) return Ok(JsonView(false));
  9797. }
  9798. jjcItemTotal = info.AirJJ + info.CityTranffic;
  9799. gwcItemTotal = info.AirGW + info.CityTranffic;
  9800. tdcItemTotal = info.AirTD + info.CityTranffic;
  9801. ////消息通知
  9802. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9803. return Ok(JsonView(new
  9804. {
  9805. parentId = id,
  9806. choiceTwoJJ = dto.ChoiceTwoJJ,
  9807. jjcItemTotal = jjcItemTotal,
  9808. choiceTwoGW = dto.ChoiceTwoGW,
  9809. gwcItemTotal = gwcItemTotal,
  9810. choiceTwoTD = dto.ChoiceTwoTD,
  9811. tdcItemTotal = tdcItemTotal
  9812. }));
  9813. }
  9814. /// <summary>
  9815. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9816. /// </summary>
  9817. /// <returns></returns>
  9818. [HttpPost]
  9819. [ApiExplorerSettings(IgnoreApi = true)]
  9820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9821. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  9822. {
  9823. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9824. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9825. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9826. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9827. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9828. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9829. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  9830. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  9831. {
  9832. Id = x.Id,
  9833. ParentId = dto.DraftId,
  9834. Type = dto.FeeType,
  9835. Days = x.Days,
  9836. NationalTravelFeeId = x.NationalTravelFeeId,
  9837. Cost = x.Cost,
  9838. Currency = x.Currency,
  9839. SubTotal = x.SubTotal,
  9840. CreateUserId = dto.CurrUserId
  9841. })
  9842. .ToList();
  9843. var adds = infos.Where(x => x.Id <= 0).ToList();
  9844. var upds = infos.Where(x => x.Id > 0).ToList();
  9845. if (adds.Count > 0)
  9846. {
  9847. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9848. if (add < 1) return Ok(JsonView(false));
  9849. }
  9850. if (upds.Count > 0)
  9851. {
  9852. var upd = await _sqlSugar.Updateable(adds)
  9853. .UpdateColumns(x => new
  9854. {
  9855. x.Days,
  9856. x.NationalTravelFeeId,
  9857. x.Cost,
  9858. x.Currency,
  9859. x.SubTotal
  9860. })
  9861. .WhereColumns(x => new { x.Id })
  9862. .ExecuteCommandAsync();
  9863. if (upd < 1) return Ok(JsonView(false));
  9864. }
  9865. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9866. ////消息通知
  9867. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  9868. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9869. return Ok(JsonView(new { itemTotal = itemTotal }));
  9870. }
  9871. /// <summary>
  9872. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9873. /// </summary>
  9874. /// <returns></returns>
  9875. [HttpPost]
  9876. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9877. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  9878. {
  9879. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9880. int subId = dto.SubId, feeType = dto.FeeType;
  9881. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9882. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9883. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9884. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9885. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  9886. subInfo.Id = subId;
  9887. subInfo.ParentId = dto.DraftId;
  9888. if (feeType == 3) subInfo.Type = 1;
  9889. else if (feeType == 4) subInfo.Type = 2;
  9890. else if (feeType == 5) subInfo.Type = 3;
  9891. else if (feeType == 6) subInfo.Type = 4;
  9892. subInfo.CreateUserId = dto.CurrUserId;
  9893. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  9894. if (parentId < 1) return Ok(JsonView(false));
  9895. //子表op
  9896. if (subId < 1)
  9897. {
  9898. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9899. if (subAdd < 1) return Ok(JsonView(false));
  9900. }
  9901. else
  9902. {
  9903. var subUpd = await _sqlSugar.Updateable(subInfo)
  9904. .UpdateColumns(x => new
  9905. {
  9906. x.Days,
  9907. x.NationalTravelFeeId,
  9908. x.Cost,
  9909. x.Currency,
  9910. x.SubTotal
  9911. })
  9912. .WhereColumns(x => new { x.Id })
  9913. .ExecuteCommandAsync();
  9914. if (subUpd < 1) return Ok(JsonView(false));
  9915. }
  9916. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  9917. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9918. }
  9919. /// <summary>
  9920. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  9921. /// </summary>
  9922. /// <returns></returns>
  9923. [HttpPost]
  9924. [ApiExplorerSettings(IgnoreApi = true)]
  9925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9926. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  9927. {
  9928. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9929. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9930. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9931. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  9932. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  9933. {
  9934. Id = x.Id,
  9935. ParentId = dto.DraftId,
  9936. SetDataId = x.SetDataId,
  9937. Index = x.Index,
  9938. Cost = x.Cost,
  9939. Currency = x.Currency,
  9940. SubTotal = x.SubTotal,
  9941. CreateUserId = dto.CurrUserId,
  9942. Remark = x.Remark
  9943. }).ToList();
  9944. var adds = infos.Where(x => x.Id <= 0).ToList();
  9945. var upds = infos.Where(x => x.Id > 0).ToList();
  9946. if (adds.Count > 0)
  9947. {
  9948. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9949. if (add < 1) return Ok(JsonView(false));
  9950. }
  9951. if (upds.Count > 0)
  9952. {
  9953. var upd = await _sqlSugar.Updateable(adds)
  9954. .UpdateColumns(x => new
  9955. {
  9956. x.Index,
  9957. x.SetDataId,
  9958. x.Cost,
  9959. x.Currency,
  9960. x.SubTotal,
  9961. x.Remark
  9962. })
  9963. .WhereColumns(x => new { x.Id })
  9964. .ExecuteCommandAsync();
  9965. if (upd < 1) return Ok(JsonView(false));
  9966. }
  9967. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  9968. //消息通知
  9969. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  9970. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9971. return Ok(JsonView(new { itemTotal = itemTotal }));
  9972. }
  9973. /// <summary>
  9974. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  9975. /// </summary>
  9976. /// <returns></returns>
  9977. [HttpPost]
  9978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9979. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  9980. {
  9981. int subId = dto.SubId,id = dto.DarftId;
  9982. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9983. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  9984. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9985. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  9986. subInfo.Id = subId;
  9987. subInfo.ParentId = dto.DarftId;
  9988. subInfo.CreateUserId = dto.CurrUserId;
  9989. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  9990. if (parentId < 1) return Ok(JsonView(false));
  9991. #region 子表op
  9992. if (subId < 1)//add
  9993. {
  9994. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9995. if (subAdd < 1) return Ok(JsonView(false));
  9996. }
  9997. else //upd
  9998. {
  9999. var subUpd = await _sqlSugar.Updateable(subInfo)
  10000. .UpdateColumns(x => new
  10001. {
  10002. x.Index,
  10003. x.SetDataId,
  10004. x.Cost,
  10005. x.Currency,
  10006. x.SubTotal,
  10007. x.Remark
  10008. })
  10009. .WhereColumns(x => new { x.Id })
  10010. .ExecuteCommandAsync();
  10011. if (subUpd < 1) return Ok(JsonView(false));
  10012. }
  10013. #endregion
  10014. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  10015. ////消息通知
  10016. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  10017. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  10018. }
  10019. /// <summary>
  10020. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  10021. /// </summary>
  10022. /// <returns></returns>
  10023. [HttpPost]
  10024. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10025. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10026. {
  10027. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10028. if (data.Code != 0)
  10029. {
  10030. return Ok(JsonView(false, data.Msg));
  10031. }
  10032. return Ok(JsonView(true, "操作成功!", data.Data));
  10033. }
  10034. /// <summary>
  10035. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  10036. /// </summary>
  10037. /// <param name="dto"></param>
  10038. /// <returns></returns>
  10039. [HttpPost]
  10040. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  10041. {
  10042. var data = new Grp_DayOtherPriceDraft()
  10043. {
  10044. Id = dto.Id,
  10045. IsDel = 1,
  10046. DeleteUserId = dto.DeleteUserId,
  10047. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10048. };
  10049. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10050. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  10051. return Ok(JsonView(false, "删除失败!"));
  10052. }
  10053. #endregion
  10054. #endregion
  10055. #region 签证费用录入
  10056. /// <summary>
  10057. /// 根据diid查询签证费用列表
  10058. /// </summary>
  10059. /// <param name="dto"></param>
  10060. /// <returns></returns>
  10061. [HttpPost]
  10062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10063. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10064. {
  10065. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10066. if (groupData.Code != 0)
  10067. {
  10068. return Ok(JsonView(false, groupData.Msg));
  10069. }
  10070. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10071. }
  10072. /// <summary>
  10073. /// 根据签证费用Id查询单条数据及c表数据
  10074. /// </summary>
  10075. /// <param name="dto"></param>
  10076. /// <returns></returns>
  10077. [HttpPost]
  10078. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10079. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10080. {
  10081. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10082. if (groupData.Code != 0)
  10083. {
  10084. return Ok(JsonView(false, groupData.Msg));
  10085. }
  10086. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10087. }
  10088. /// <summary>
  10089. /// 签证费用删除
  10090. /// </summary>
  10091. /// <param name="dto"></param>
  10092. /// <returns></returns>
  10093. [HttpPost]
  10094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10095. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10096. {
  10097. _sqlSugar.BeginTran();
  10098. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10099. if (!res)
  10100. {
  10101. _sqlSugar.RollbackTran();
  10102. return Ok(JsonView(false, "删除失败"));
  10103. }
  10104. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10105. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10106. .SetColumns(a => new Grp_CreditCardPayment()
  10107. {
  10108. IsDel = 1,
  10109. DeleteUserId = dto.DeleteUserId,
  10110. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10111. })
  10112. .ExecuteCommand();
  10113. if (resSub < 1)
  10114. {
  10115. _sqlSugar.RollbackTran();
  10116. return Ok(JsonView(false, "删除失败"));
  10117. }
  10118. _sqlSugar.CommitTran();
  10119. return Ok(JsonView(true, "删除成功!"));
  10120. }
  10121. /// <summary>
  10122. /// 签证费用录入下拉框初始化
  10123. /// </summary>
  10124. /// <returns></returns>
  10125. [HttpPost]
  10126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10127. public async Task<IActionResult> VisaPriceAddSelect()
  10128. {
  10129. //支付方式
  10130. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10131. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10132. //币种
  10133. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10134. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10135. //乘客类型
  10136. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10137. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10138. //卡类型
  10139. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10140. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10141. //代办费类型
  10142. var agencyFeeTypeData = new List<dynamic>() {
  10143. new { id = 0 , Text = "未选择" },
  10144. new { id = 1 , Text = "小公务" },
  10145. new { id = 2 , Text = "大公务" },
  10146. };
  10147. //签证费用标准国家Data
  10148. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10149. var data = new
  10150. {
  10151. Payment = _Payment,
  10152. CurrencyList = _CurrencyList,
  10153. PassengerType = _PassengerType,
  10154. BankCard = _BankCard,
  10155. AgencyFeeType = agencyFeeTypeData,
  10156. CountryFeeData = visaCountryFeeData
  10157. };
  10158. return Ok(JsonView(true, "查询成功!", data));
  10159. }
  10160. /// <summary>
  10161. /// 签证费用录入操作(Status:1.新增,2.修改)
  10162. /// </summary>
  10163. /// <param name="dto"></param>
  10164. /// <returns></returns>
  10165. [HttpPost]
  10166. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10167. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10168. {
  10169. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10170. if (groupData.Code != 0)
  10171. {
  10172. return Ok(JsonView(false, groupData.Msg));
  10173. }
  10174. #region 应用推送
  10175. try
  10176. {
  10177. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10178. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10179. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10180. //2024-10-21 新增LZ UID
  10181. var userIds = new List<int>() { 21 };
  10182. string title = $"系统通知";
  10183. string content = "";
  10184. var diId = dto.DiId;
  10185. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10186. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10187. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10188. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10189. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10190. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10191. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10192. }
  10193. catch (Exception ex)
  10194. {
  10195. }
  10196. #endregion
  10197. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10198. }
  10199. #endregion
  10200. #region 签证提成录入
  10201. /// <summary>
  10202. /// 签证提成录入
  10203. /// 基础数据
  10204. /// </summary>
  10205. /// <param name="_dto"></param>
  10206. /// <returns></returns>
  10207. [HttpGet]
  10208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10209. public async Task<IActionResult> VisaCommissionInit()
  10210. {
  10211. return Ok(await _visaCommissionRep.Init());
  10212. }
  10213. /// <summary>
  10214. /// 签证提成录入
  10215. /// Item
  10216. /// </summary>
  10217. /// <param name="_dto"></param>
  10218. /// <returns></returns>
  10219. [HttpPost]
  10220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10221. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10222. {
  10223. var validator = new VisaCommissionItemDtoValidator();
  10224. var validatorRes = await validator.ValidateAsync(_dto);
  10225. if (!validatorRes.IsValid)
  10226. {
  10227. StringBuilder sb = new StringBuilder();
  10228. foreach (var item in validatorRes.Errors)
  10229. {
  10230. sb.AppendLine(item.ErrorMessage);
  10231. }
  10232. return Ok(JsonView(false, sb.ToString()));
  10233. }
  10234. return Ok(await _visaCommissionRep.Item(_dto));
  10235. }
  10236. /// <summary>
  10237. /// 签证提成录入
  10238. /// Save
  10239. /// </summary>
  10240. /// <param name="_dto"></param>
  10241. /// <returns></returns>
  10242. [HttpPost]
  10243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10244. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10245. {
  10246. //参数验证
  10247. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10248. foreach (var item in _dto.Items)
  10249. {
  10250. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10251. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10252. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10253. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10254. }
  10255. return Ok(await _visaCommissionRep.Save(_dto));
  10256. }
  10257. /// <summary>
  10258. /// 签证提成录入
  10259. /// Create
  10260. /// </summary>
  10261. /// <param name="_dto"></param>
  10262. /// <returns></returns>
  10263. [HttpPost]
  10264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10265. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10266. {
  10267. var validator = new VisaCommissionCreateDtoValidator();
  10268. var validatorRes = await validator.ValidateAsync(_dto);
  10269. if (!validatorRes.IsValid)
  10270. {
  10271. StringBuilder sb = new StringBuilder();
  10272. foreach (var item in validatorRes.Errors)
  10273. {
  10274. sb.AppendLine(item.ErrorMessage);
  10275. }
  10276. return Ok(JsonView(false, sb.ToString()));
  10277. }
  10278. return Ok(await _visaCommissionRep.Create(_dto));
  10279. }
  10280. /// <summary>
  10281. /// 签证提成录入
  10282. /// Put(编辑)
  10283. /// </summary>
  10284. /// <param name="id"></param>
  10285. /// <param name="_dto"></param>
  10286. /// <returns></returns>
  10287. [HttpPut]
  10288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10289. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10290. {
  10291. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10292. var validator = new VisaCommissionCreateDtoValidator();
  10293. var validatorRes = await validator.ValidateAsync(_dto);
  10294. if (!validatorRes.IsValid)
  10295. {
  10296. StringBuilder sb = new StringBuilder();
  10297. foreach (var item in validatorRes.Errors)
  10298. {
  10299. sb.AppendLine(item.ErrorMessage);
  10300. }
  10301. return Ok(JsonView(false, sb.ToString()));
  10302. }
  10303. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10304. }
  10305. /// <summary>
  10306. /// 签证提成录入
  10307. /// Del
  10308. /// </summary>
  10309. /// <param name="id"></param>
  10310. /// <param name="currUserId"></param>
  10311. /// <returns></returns>
  10312. [HttpPost]
  10313. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10314. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10315. {
  10316. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10317. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10318. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10319. }
  10320. #endregion
  10321. #region op费用录入
  10322. /// <summary>
  10323. /// 根据diid查询op费用列表
  10324. /// </summary>
  10325. /// <param name="dto"></param>
  10326. /// <returns></returns>
  10327. [HttpPost]
  10328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10329. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10330. {
  10331. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10332. if (groupData.Code != 0)
  10333. {
  10334. return Ok(JsonView(false, groupData.Msg));
  10335. }
  10336. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10337. }
  10338. /// <summary>
  10339. /// 根据op费用Id查询单条数据及c表数据
  10340. /// </summary>
  10341. /// <param name="dto"></param>
  10342. /// <returns></returns>
  10343. [HttpPost]
  10344. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10345. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10346. {
  10347. try
  10348. {
  10349. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10350. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10351. var data = new
  10352. {
  10353. CarTouristGuideGround = _groupData,
  10354. CreditCardPayment = _creditCardPayment
  10355. };
  10356. return Ok(JsonView(true, "查询成功!", data));
  10357. }
  10358. catch (Exception ex)
  10359. {
  10360. return Ok(JsonView(false, "程序错误!"));
  10361. }
  10362. }
  10363. /// <summary>
  10364. /// op费用删除
  10365. /// </summary>
  10366. /// <param name="dto"></param>
  10367. /// <returns></returns>
  10368. [HttpPost]
  10369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10370. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10371. {
  10372. try
  10373. {
  10374. _sqlSugar.BeginTran();
  10375. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10376. if (!res)
  10377. {
  10378. return Ok(JsonView(false, "删除失败"));
  10379. }
  10380. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10381. {
  10382. IsDel = 1,
  10383. DeleteUserId = dto.DeleteUserId,
  10384. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10385. }).ExecuteCommandAsync();
  10386. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10387. {
  10388. IsDel = 1,
  10389. DeleteUserId = dto.DeleteUserId,
  10390. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10391. }).ExecuteCommandAsync();
  10392. #region 删除超支相关数据
  10393. //删除导入的超支数据
  10394. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10395. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10396. {
  10397. IsDel = 1,
  10398. DeleteUserId = dto.DeleteUserId,
  10399. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10400. }).ExecuteCommand();
  10401. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10402. {
  10403. IsDel = 1,
  10404. DeleteUserId = dto.DeleteUserId,
  10405. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10406. }).ExecuteCommand();
  10407. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10408. {
  10409. IsDel = 1,
  10410. DeleteUserId = dto.DeleteUserId,
  10411. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10412. }).ExecuteCommand();
  10413. #endregion
  10414. _sqlSugar.CommitTran();
  10415. return Ok(JsonView(true, "删除成功!"));
  10416. }
  10417. catch (Exception ex)
  10418. {
  10419. _sqlSugar.RollbackTran();
  10420. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10421. }
  10422. }
  10423. /// <summary>
  10424. /// op费用录入操作(Status:1.新增,2.修改)
  10425. /// </summary>
  10426. /// <param name="dto"></param>
  10427. /// <returns></returns>
  10428. [HttpPost]
  10429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10430. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10431. {
  10432. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10433. if (groupData.Code != 0)
  10434. {
  10435. return Ok(JsonView(false, groupData.Msg));
  10436. }
  10437. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10438. }
  10439. /// <summary>
  10440. /// 填写费用详细页面初始化绑定
  10441. /// </summary>
  10442. /// <param name="dto"></param>
  10443. /// <returns></returns>
  10444. [HttpPost]
  10445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10446. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10447. {
  10448. try
  10449. {
  10450. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10451. if (groupData.Code != 0)
  10452. {
  10453. return Ok(JsonView(false, groupData.Msg));
  10454. }
  10455. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10456. }
  10457. catch (Exception ex)
  10458. {
  10459. return Ok(JsonView(false, ex.Message));
  10460. }
  10461. }
  10462. /// <summary>
  10463. /// 根据op费用Id查询详细数据
  10464. /// </summary>
  10465. /// <param name="dto"></param>
  10466. /// <returns></returns>
  10467. [HttpPost]
  10468. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10469. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10470. {
  10471. try
  10472. {
  10473. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10474. if (groupData.Code != 0)
  10475. {
  10476. return Ok(JsonView(false, groupData.Msg));
  10477. }
  10478. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10479. }
  10480. catch (Exception ex)
  10481. {
  10482. return Ok(JsonView(false, ex.Message));
  10483. }
  10484. }
  10485. /// <summary>
  10486. /// OP费用录入填写详情
  10487. /// </summary>
  10488. /// <param name="dto"></param>
  10489. /// <returns></returns>
  10490. [HttpPost]
  10491. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10492. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10493. {
  10494. try
  10495. {
  10496. #region 参数校验
  10497. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10498. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10499. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10500. #endregion
  10501. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10502. if (groupData.Code != 0)
  10503. {
  10504. return Ok(JsonView(false, groupData.Msg));
  10505. }
  10506. //自动审核
  10507. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10508. #region 应用推送
  10509. try
  10510. {
  10511. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10512. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10513. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10514. //2024-10-21 新增LZ UID
  10515. var userIds = new List<int>() { 21 };
  10516. string title = $"系统通知";
  10517. var diId = dto.DiId;
  10518. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10519. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10520. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  10521. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10522. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10523. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10524. }
  10525. catch (Exception ex)
  10526. {
  10527. }
  10528. #endregion
  10529. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10530. }
  10531. catch (Exception ex)
  10532. {
  10533. return Ok(JsonView(false, ex.Message));
  10534. }
  10535. }
  10536. /// <summary>
  10537. /// 获取三公详细所有城市
  10538. /// </summary>
  10539. /// <returns></returns>
  10540. [HttpGet]
  10541. public IActionResult OpCarCityResult()
  10542. {
  10543. var jw = JsonView(false);
  10544. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10545. {
  10546. x.Id,
  10547. x.Country,
  10548. x.City,
  10549. }).ToList();
  10550. if (data.Count > 0)
  10551. {
  10552. jw = JsonView(true, "获取成功!", data);
  10553. }
  10554. else
  10555. {
  10556. jw.Msg = "城市数据为空!";
  10557. jw.Data = new string[0];
  10558. }
  10559. return Ok(jw);
  10560. }
  10561. /// <summary>
  10562. /// 导出地接费用明细
  10563. /// </summary>
  10564. /// <param name="dto"></param>
  10565. /// <returns></returns>
  10566. [HttpPost]
  10567. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10568. {
  10569. var jw = JsonView(false);
  10570. if (dto.Diid < 1)
  10571. {
  10572. jw.Msg = "请输入正确的diid!";
  10573. return Ok(jw);
  10574. }
  10575. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10576. if (group == null)
  10577. {
  10578. jw.Msg = "未找到团组信息!";
  10579. return Ok(jw);
  10580. }
  10581. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10582. if (localGuideArr.Count == 0)
  10583. {
  10584. jw.Msg = "该团组暂无地接信息!";
  10585. return Ok(jw);
  10586. }
  10587. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10588. var overspendSoure = new Dictionary<int, int>
  10589. {
  10590. { 91, 982 }, //车
  10591. { 92 , 1059} ,//导游
  10592. { 994 , 1073}, //翻译
  10593. { 988 , 1074 }, //早餐
  10594. { 93 , 1075 }, //午餐
  10595. { 989 , 1076 }, //晚餐
  10596. };
  10597. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10598. foreach (var groupArr in localGroup)
  10599. {
  10600. var keyValue = groupArr.Key;
  10601. if (int.TryParse(keyValue, out int cityid))
  10602. {
  10603. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10604. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10605. }
  10606. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10607. foreach (var item in groupArr)
  10608. {
  10609. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10610. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10611. new Grp_CarTouristGuideGroundReservationsContentExtend
  10612. {
  10613. Count = a.Count,
  10614. CreateTime = a.CreateTime,
  10615. CreateUserId = a.CreateUserId,
  10616. CTGGRId = a.CTGGRId,
  10617. Currency = a.Currency,
  10618. DatePrice = a.DatePrice,
  10619. DeleteTime = a.DeleteTime,
  10620. DeleteUserId = a.DeleteUserId,
  10621. DiId = a.DiId,
  10622. Id = a.Id,
  10623. IsDel = a.IsDel,
  10624. Price = a.Price,
  10625. PriceContent = a.PriceContent,
  10626. Remark = a.Remark,
  10627. SId = a.SId,
  10628. SidName = b.Name,
  10629. Units = a.Units,
  10630. }
  10631. ).ToList();
  10632. if (content.Count > 0)
  10633. {
  10634. contentArr.Add(content);
  10635. }
  10636. }
  10637. //open excel
  10638. //set excel
  10639. //save excel
  10640. try
  10641. {
  10642. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10643. IWorkbook workbook;
  10644. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10645. {
  10646. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10647. }
  10648. else
  10649. {
  10650. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10651. }
  10652. ISheet sheet = workbook.GetSheetAt(0);
  10653. var rowStartIndex = 2;
  10654. var clounmCount = 10;
  10655. var initStyleRow = sheet.GetRow(2);
  10656. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10657. //var overspendArrDetail =
  10658. var existsId = new List<CarCompare>();
  10659. var lastElem = arr.Last();
  10660. var thisSid = -1;
  10661. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10662. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10663. {
  10664. Name = "未知币种!",
  10665. Remark = "未知币种!",
  10666. };
  10667. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10668. Action cloneRowFn = () =>
  10669. {
  10670. rowStartIndex++;
  10671. var cloneRow = sheet.CreateRow(rowStartIndex);
  10672. // 复制样式
  10673. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10674. {
  10675. ICell sourceCell = initStyleRow.GetCell(i);
  10676. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10677. // 确保单元格存在样式
  10678. if (sourceCell.CellStyle != null)
  10679. {
  10680. targetCell.CellStyle = sourceCell.CellStyle;
  10681. }
  10682. }
  10683. };
  10684. var mergeRow = () =>
  10685. {
  10686. for (int i = 2; i < sheet.LastRowNum; i++)
  10687. {
  10688. var row = sheet.GetRow(i);
  10689. var cellFirst = row.GetCell(0);
  10690. var thisIndex = i + 1;
  10691. while (thisIndex < sheet.LastRowNum)
  10692. {
  10693. var nextRow = sheet.GetRow(thisIndex);
  10694. var nextCellFirst = nextRow.GetCell(0);
  10695. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10696. {
  10697. thisIndex++;
  10698. }
  10699. else
  10700. {
  10701. break;
  10702. }
  10703. }
  10704. thisIndex--;
  10705. if (thisIndex != i)
  10706. {
  10707. //合并row
  10708. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10709. i, // 起始行索引(0-based)
  10710. thisIndex, // 结束行索引(0-based)
  10711. 0, // 起始列索引(0-based)
  10712. 0 // 结束列索引(0-based)
  10713. );
  10714. sheet.AddMergedRegion(cellRangeAddress);
  10715. i = thisIndex;
  10716. }
  10717. }
  10718. };
  10719. var chaoshiNumber = 0;
  10720. var totalNumber = 0.00M;
  10721. string lastStr = "";
  10722. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10723. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10724. {
  10725. b.IsAuditGM,
  10726. x.Id,
  10727. x.Area,
  10728. b.PayPercentage,
  10729. b.PayMoney,
  10730. }).ToList();
  10731. string yesPayment = "", noPayment = "";
  10732. foreach (var item in queryCarArrByCityAndDiid)
  10733. {
  10734. if (item.IsAuditGM == 1)
  10735. {
  10736. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10737. }
  10738. else
  10739. {
  10740. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10741. }
  10742. }
  10743. lastStr = yesPayment + noPayment;
  10744. foreach (var item in arr)
  10745. {
  10746. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10747. {
  10748. if (thisSid != item.SId)
  10749. {
  10750. if (thisSid == -1)
  10751. {
  10752. thisSid = item.SId;
  10753. }
  10754. else
  10755. {
  10756. //合并小计行
  10757. //创建合并区域的实例
  10758. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10759. rowStartIndex, // 起始行索引(0-based)
  10760. rowStartIndex, // 结束行索引(0-based)
  10761. 0, // 起始列索引(0-based)
  10762. 3 // 结束列索引(0-based)
  10763. );
  10764. sheet.AddMergedRegion(cellRangeAddress);
  10765. var CellStyle = workbook.CreateCellStyle();
  10766. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10767. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10768. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10769. for (int i = 0; i <= clounmCount; i++)
  10770. {
  10771. if (i > 6)
  10772. {
  10773. var CellStyle1 = workbook.CreateCellStyle();
  10774. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10775. IFont Font = workbook.CreateFont(); // 创建字体
  10776. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10777. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10778. CellStyle1.SetFont(Font);
  10779. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10780. }
  10781. else
  10782. {
  10783. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10784. }
  10785. }
  10786. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10787. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10788. //超时合计
  10789. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10790. //超时数
  10791. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10792. //超时合计费用
  10793. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10794. thisSid = item.SId;
  10795. cloneRowFn();
  10796. chaoshiNumber = 0;
  10797. totalNumber = 0;
  10798. }
  10799. }
  10800. IRow row = sheet.GetRow(rowStartIndex);
  10801. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10802. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10803. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10804. if (isOpenOverspendSoure)
  10805. {
  10806. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10807. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10808. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10809. }
  10810. for (int i = 0; i <= clounmCount; i++)
  10811. {
  10812. var cell = row.GetCell(i);
  10813. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10814. if (cell == null)
  10815. {
  10816. cell = row.CreateCell(i);
  10817. }
  10818. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10819. fontRed.CloneStyleFrom(cell.CellStyle);
  10820. IFont Font = workbook.CreateFont(); // 创建字体
  10821. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10822. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10823. fontRed.SetFont(Font);
  10824. byte[] rgb = new byte[3] { 255, 242, 204 };
  10825. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10826. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10827. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10828. if (workbook is XSSFWorkbook)
  10829. {
  10830. BackgroundColor255_242_204.FillForegroundColor = 0;
  10831. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10832. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10833. }
  10834. else
  10835. {
  10836. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10837. }
  10838. if (i == 1 || i > 6)
  10839. {
  10840. if (i > 6)
  10841. {
  10842. fontRed.FillForegroundColor = 0;
  10843. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10844. fontRed.FillPattern = FillPattern.SolidForeground;
  10845. }
  10846. cell.CellStyle = fontRed;
  10847. }
  10848. if (i > 2 && i < 7)
  10849. {
  10850. cell.CellStyle = BackgroundColor255_242_204;
  10851. }
  10852. cell.SetCellValue(setCellValue); //写入单元格
  10853. }
  10854. if (overspendSoure.ContainsKey(thisSid))
  10855. {
  10856. var overspendId = overspendSoure[thisSid];
  10857. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10858. }
  10859. cloneRowFn();
  10860. existsId.Add(new CarCompare
  10861. {
  10862. DataPrice = item.DatePrice.ObjToDate(),
  10863. Sid = item.SId
  10864. });
  10865. }
  10866. if (item.Equals(lastElem))
  10867. {
  10868. //合并小计行
  10869. //创建合并区域的实例
  10870. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10871. rowStartIndex, // 起始行索引(0-based)
  10872. rowStartIndex, // 结束行索引(0-based)
  10873. 0, // 起始列索引(0-based)
  10874. 3 // 结束列索引(0-based)
  10875. );
  10876. sheet.AddMergedRegion(cellRangeAddress);
  10877. var CellStyle = workbook.CreateCellStyle();
  10878. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10879. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10880. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10881. for (int i = 0; i <= clounmCount; i++)
  10882. {
  10883. if (i > 6)
  10884. {
  10885. var CellStyle1 = workbook.CreateCellStyle();
  10886. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10887. IFont Font = workbook.CreateFont(); // 创建字体
  10888. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10889. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10890. CellStyle1.SetFont(Font);
  10891. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10892. }
  10893. else
  10894. {
  10895. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10896. }
  10897. }
  10898. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10899. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10900. //超时合计
  10901. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10902. //超时数
  10903. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10904. //超时合计费用
  10905. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10906. cloneRowFn();
  10907. // 创建合并区域的实例
  10908. cellRangeAddress = new CellRangeAddress(
  10909. rowStartIndex, // 起始行索引(0-based)
  10910. rowStartIndex, // 结束行索引(0-based)
  10911. 0, // 起始列索引(0-based)
  10912. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10913. );
  10914. // 添加合并区域
  10915. sheet.AddMergedRegion(cellRangeAddress);
  10916. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10917. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10918. }
  10919. }
  10920. mergeRow();
  10921. // 保存修改后的Excel文件到新文件
  10922. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10923. // new FileStream(newFilePath, FileMode.CreateNew)
  10924. using (var stream = new MemoryStream())
  10925. {
  10926. workbook.Write(stream, true);
  10927. stream.Flush();
  10928. stream.Seek(0, SeekOrigin.Begin);
  10929. MemoryStream memoryStream = new MemoryStream();
  10930. stream.CopyTo(memoryStream);
  10931. memoryStream.Seek(0, SeekOrigin.Begin);
  10932. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  10933. }
  10934. workbook.Close();
  10935. workbook.Dispose();
  10936. }
  10937. catch (Exception ex)
  10938. {
  10939. jw.Msg = "出现异常!" + ex.Message;
  10940. return Ok(jw);
  10941. }
  10942. }
  10943. if (Zips.Count > 0)
  10944. {
  10945. IOOperatorHelper io = new IOOperatorHelper();
  10946. var byts = io.ConvertZipStream(Zips);
  10947. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  10948. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  10949. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  10950. }
  10951. else
  10952. {
  10953. jw.Msg = "暂无生成文件!";
  10954. }
  10955. return Ok(jw);
  10956. }
  10957. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  10958. {
  10959. string outStr = string.Empty;
  10960. switch (i)
  10961. {
  10962. case 0:
  10963. outStr = arr[0].SidName;
  10964. break;
  10965. case 1:
  10966. outStr = arr[0].DataPriceStr;
  10967. break;
  10968. case 2:
  10969. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  10970. break;
  10971. case 4:
  10972. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  10973. break;
  10974. case 7:
  10975. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10976. {
  10977. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  10978. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  10979. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  10980. }
  10981. break;
  10982. case 8:
  10983. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10984. {
  10985. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  10986. }
  10987. break;
  10988. case 9:
  10989. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10990. {
  10991. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  10992. }
  10993. break;
  10994. case 10:
  10995. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10996. {
  10997. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  10998. }
  10999. break;
  11000. }
  11001. return outStr;
  11002. }
  11003. #region OP行程单
  11004. /// <summary>
  11005. /// OP行程单初始化
  11006. /// </summary>
  11007. /// <param name="dto"></param>
  11008. /// <returns></returns>
  11009. [HttpPost]
  11010. public IActionResult InitOpTravel(InitOpTravelDto dto)
  11011. {
  11012. var jw = JsonView(false);
  11013. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  11014. var group = groupList.First();
  11015. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  11016. if (group == null)
  11017. {
  11018. jw.Msg = "暂无团组!";
  11019. return Ok(jw);
  11020. }
  11021. group = groupList.Find(x => x.Id == diid);
  11022. if (group == null)
  11023. {
  11024. jw.Msg = "请输入正确的团组ID!";
  11025. return Ok(jw);
  11026. }
  11027. string city = string.Empty;
  11028. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  11029. if (blackCode.Count > 0)
  11030. {
  11031. var black = blackCode.First();
  11032. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  11033. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  11034. if (blackSp.Length > 0)
  11035. {
  11036. try
  11037. {
  11038. var cityArrCode = new List<string>(20);
  11039. foreach (var item in blackSp)
  11040. {
  11041. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  11042. var IndexSelect = itemSp[2];
  11043. var cityArrCodeLength = cityArrCode.Count - 1;
  11044. var startCity = IndexSelect.Substring(0, 3);
  11045. if (cityArrCodeLength > 0)
  11046. {
  11047. var arrEndCity = cityArrCode[cityArrCodeLength];
  11048. if (arrEndCity != startCity)
  11049. {
  11050. cityArrCode.Add(startCity.ToUpper());
  11051. }
  11052. }
  11053. else
  11054. {
  11055. cityArrCode.Add(startCity.ToUpper());
  11056. }
  11057. var endCity = IndexSelect.Substring(3, 3);
  11058. cityArrCode.Add(endCity.ToUpper());
  11059. }
  11060. var cityThree = string.Empty;
  11061. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  11062. cityThree = cityThree.TrimEnd(',');
  11063. if (string.IsNullOrWhiteSpace(cityThree))
  11064. {
  11065. throw new
  11066. Exception("error");
  11067. }
  11068. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11069. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11070. foreach (var item in cityArrCode)
  11071. {
  11072. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11073. if (find != null)
  11074. {
  11075. city += find.City + "/";
  11076. }
  11077. else
  11078. {
  11079. city += item + "三字码未收入/";
  11080. }
  11081. }
  11082. city = city.TrimEnd('/');
  11083. }
  11084. catch (Exception e)
  11085. {
  11086. city = "黑屏代码格式不正确!";
  11087. }
  11088. }
  11089. }
  11090. else
  11091. {
  11092. city = "未录入黑屏代码";
  11093. }
  11094. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11095. {
  11096. Date = x.Date,
  11097. Days = x.Days,
  11098. Diffgroup = x.Diffgroup,
  11099. Diid = x.Diid,
  11100. Traffic_First = x.Traffic_First,
  11101. Traffic_Second = x.Traffic_Second,
  11102. Trip = x.Trip,
  11103. WeekDay = x.WeekDay,
  11104. Id = x.Id
  11105. }).ToList();
  11106. jw.Data = new
  11107. {
  11108. groupList = groupList.Select(x => new
  11109. {
  11110. x.Id,
  11111. x.TeamName,
  11112. x.TourCode
  11113. }).ToList(),
  11114. groupInfo = new
  11115. {
  11116. group.VisitDays,
  11117. group.TourCode,
  11118. group.VisitPNumber,
  11119. group.TeamName,
  11120. city
  11121. },
  11122. OpTravelList
  11123. };
  11124. jw.Code = 200;
  11125. jw.Msg = "操作成功!";
  11126. return Ok(jw);
  11127. }
  11128. /// <summary>
  11129. /// 删除团组行程单
  11130. /// </summary>
  11131. /// <returns></returns>
  11132. [HttpPost]
  11133. public IActionResult DelTravel(DelOpTravelDto dto)
  11134. {
  11135. var jw = JsonView(false);
  11136. if (dto.UserId <= 0 || dto.Diid <= 0)
  11137. {
  11138. jw.Msg = "请输入正确的参数!";
  11139. return Ok(jw);
  11140. }
  11141. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11142. .SetColumns(x => new Grp_TravelList
  11143. {
  11144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11145. DeleteUserId = dto.UserId,
  11146. IsDel = 1,
  11147. }).ExecuteCommand();
  11148. jw = JsonView(true);
  11149. return Ok(jw);
  11150. }
  11151. /// <summary>
  11152. /// 行程单保存
  11153. /// </summary>
  11154. /// <returns></returns>
  11155. [HttpPost]
  11156. public IActionResult TravelSave(TravelSaveDto dto)
  11157. {
  11158. var jw = JsonView(false);
  11159. if (dto.Arr.Count > 0)
  11160. {
  11161. try
  11162. {
  11163. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11164. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  11165. .ToList();
  11166. _sqlSugar.BeginTran();
  11167. foreach (var item in dto.Arr)
  11168. {
  11169. if (item.Id == 0)
  11170. {
  11171. throw new Exception("请传入正确的Id");
  11172. }
  11173. //比较上一次的差异
  11174. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11175. if (findTravel != null)
  11176. {
  11177. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11178. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11179. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  11180. }
  11181. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11182. .SetColumns(x => new Grp_TravelList
  11183. {
  11184. Trip = item.Trip
  11185. }).ExecuteCommand();
  11186. }
  11187. _sqlSugar.CommitTran();
  11188. jw = JsonView(true);
  11189. }
  11190. catch (Exception ex)
  11191. {
  11192. _sqlSugar.RollbackTran();
  11193. jw.Msg = "程序异常!" + ex.Message;
  11194. }
  11195. }
  11196. else
  11197. {
  11198. jw.Msg = "请传入正确的参数!";
  11199. }
  11200. return Ok(jw);
  11201. }
  11202. private string CheckStr(string original, string changed)
  11203. {
  11204. // 创建diff_match_patch对象
  11205. var dmp = new diff_match_patch();
  11206. // 计算差异
  11207. List<Diff> diffs = dmp.diff_main(original, changed);
  11208. // 清理和合并差异
  11209. dmp.diff_cleanupSemantic(diffs);
  11210. // 使用StringBuilder构建最终的字符串
  11211. StringBuilder finalString = new StringBuilder();
  11212. // 输出差异结果,并构建变动后的字符串
  11213. foreach (Diff diff in diffs)
  11214. {
  11215. switch (diff.operation)
  11216. {
  11217. case Operation.EQUAL:
  11218. // 相等的部分,直接添加到最终字符串
  11219. finalString.Append(diff.text);
  11220. break;
  11221. case Operation.INSERT:
  11222. // 插入的部分,添加标记并添加到最终字符串
  11223. finalString.Append("[++]" + diff.text + "[++]");
  11224. break;
  11225. case Operation.DELETE:
  11226. // 删除的部分,不添加到最终字符串
  11227. //finalString.Append("[++]" + diff.text + "[++]");
  11228. break;
  11229. }
  11230. }
  11231. // 输出变动后的字符串
  11232. return finalString.ToString();
  11233. }
  11234. private class tagContent
  11235. {
  11236. public DateTime Date { get; set; }
  11237. public string StartTag { get; set; }
  11238. public string EndTag { get; set; }
  11239. public string Content { get; set; }
  11240. public static int tagLength { get { return 3; } }
  11241. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11242. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11243. public bool IsFinally { get; set; }
  11244. }
  11245. private List<string> ExtractContentBetweenTags(string input, string tag)
  11246. {
  11247. List<string> results = new List<string>();
  11248. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11249. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11250. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11251. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11252. string[] strValueArr = new string[1];
  11253. foreach (System.Text.RegularExpressions.Match match in matches)
  11254. {
  11255. var strValue = match.Groups[1].Value;
  11256. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11257. }
  11258. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11259. return results;
  11260. }
  11261. /// <summary>
  11262. /// 导出行程单
  11263. /// </summary>
  11264. /// <param name="dto"></param>
  11265. /// <returns></returns>
  11266. [HttpPost]
  11267. public IActionResult ExportTravel(ExportTravelDto dto)
  11268. {
  11269. var jw = JsonView(false);
  11270. jw.Data = "";
  11271. int diid = 0;
  11272. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11273. if (Find == null)
  11274. {
  11275. jw.Msg = "请选择正确的团组!";
  11276. return Ok(jw);
  11277. }
  11278. else
  11279. {
  11280. diid = Find.Id;
  11281. }
  11282. //数据源
  11283. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11284. DataTable dtBlack = null;
  11285. try
  11286. {
  11287. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11288. }
  11289. catch (Exception)
  11290. {
  11291. jw.Msg = "机票黑屏代码有误!";
  11292. return Ok(jw);
  11293. }
  11294. string CityStr = string.Empty;
  11295. if (dtBlack.Rows.Count == 0)
  11296. {
  11297. jw.Msg = "机票黑屏代码有误!";
  11298. return Ok(jw);
  11299. }
  11300. else
  11301. {
  11302. foreach (DataRow row in dtBlack.Rows)
  11303. {
  11304. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11305. {
  11306. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11307. return Ok(jw);
  11308. }
  11309. }
  11310. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11311. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11312. }
  11313. // 指定的文字
  11314. var targetTextDic = new Dictionary<string, List<string>>();
  11315. //创建数据源Table
  11316. DataTable dtSource = new DataTable();
  11317. dtSource.Columns.Add("Days", typeof(string));
  11318. dtSource.Columns.Add("Date", typeof(string));
  11319. dtSource.Columns.Add("Week", typeof(string));
  11320. dtSource.Columns.Add("Traffic", typeof(string));
  11321. dtSource.Columns.Add("Trip", typeof(string));
  11322. //获取数据,放到datatable
  11323. foreach (var item in _travelList)
  11324. {
  11325. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11326. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11327. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11328. .Replace("[++]", string.Empty);
  11329. DataRow dr = dtSource.NewRow();
  11330. dr["Days"] = item.Days;
  11331. dr["Date"] = item.Date;
  11332. dr["Week"] = item.WeekDay;
  11333. dr["Traffic"] = item.Traffic_First
  11334. + "\r\n"
  11335. + item.Traffic_Second;
  11336. dr["Trip"] = item.Trip;
  11337. dtSource.Rows.Add(dr);
  11338. }
  11339. Dictionary<string, string> dic = new Dictionary<string, string>();
  11340. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11341. dic.Add("City", CityStr);
  11342. dic.Add("Days", Find.VisitDays.ToString());
  11343. dic.Add("DeleCode", Find.TourCode);
  11344. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11345. //模板路径
  11346. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11347. //载入模板
  11348. Document doc = null;
  11349. DocumentBuilder builder = null;
  11350. try
  11351. {
  11352. //载入模板
  11353. doc = new Document(tempPath);
  11354. builder = new DocumentBuilder(doc);
  11355. }
  11356. catch (Exception)
  11357. {
  11358. jw.Msg = "模板位置不存在!";
  11359. return Ok(jw);
  11360. }
  11361. foreach (var key in dic.Keys)
  11362. {
  11363. Bookmark bookmark = doc.Range.Bookmarks[key];
  11364. if (bookmark != null)
  11365. {
  11366. builder.MoveToBookmark(key);
  11367. builder.Write(dic[key]);
  11368. }
  11369. }
  11370. //获取word里所有表格
  11371. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11372. //获取所填表格的序数
  11373. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11374. try
  11375. {
  11376. //循环赋值
  11377. for (int i = 0; i < dtSource.Rows.Count; i++)
  11378. {
  11379. builder.MoveToCell(0, i + 1, 0, 0);
  11380. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11381. builder.MoveToCell(0, i + 1, 1, 0);
  11382. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11383. builder.MoveToCell(0, i + 1, 2, 0);
  11384. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11385. var trip = dtSource.Rows[i]["Trip"].ToString();
  11386. builder.MoveToCell(0, i + 1, 3, 0);
  11387. builder.Write(trip);
  11388. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11389. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11390. // 获取特定索引的段落
  11391. Paragraph paragraph = (Paragraph)paragraphs[0];
  11392. Run run = paragraph.Runs[0];
  11393. Aspose.Words.Font font = run.Font;
  11394. font.Name = "黑体";
  11395. //设置双休红色
  11396. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11397. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11398. paragraph = (Paragraph)paragraphs[1];
  11399. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11400. {
  11401. run = paragraph.Runs[0];
  11402. font = run.Font;
  11403. font.Color = Color.Red;
  11404. }
  11405. }
  11406. }
  11407. catch (Exception ex)
  11408. {
  11409. }
  11410. //删除多余行
  11411. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11412. {
  11413. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11414. }
  11415. var targetTextList = new List<string>();
  11416. // 遍历文档中的表格
  11417. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11418. {
  11419. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11420. {
  11421. var cellIndex = 0;
  11422. foreach (Cell cell in row.Cells)
  11423. {
  11424. if (cellIndex == 1 && row.Cells.Count == 4)
  11425. {
  11426. foreach (var target in targetTextDic.Keys)
  11427. {
  11428. if (cell.GetText().Contains(target))
  11429. {
  11430. targetTextList = targetTextDic[target];
  11431. break;
  11432. }
  11433. }
  11434. }
  11435. // 遍历单元格中的所有段落
  11436. foreach (Paragraph paragraph in cell.Paragraphs)
  11437. {
  11438. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11439. List<Run> runs = new List<Run>();
  11440. foreach (Run run in paragraph.Runs)
  11441. {
  11442. runs.Add(run);
  11443. }
  11444. foreach (Run run in runs)
  11445. {
  11446. foreach (var targetText in targetTextList)
  11447. {
  11448. // 检查文字是否包含指定文字
  11449. if (run.Text.Contains(targetText))
  11450. {
  11451. // 将包含的部分设置为红色
  11452. HighlightText(run, targetText, Color.Red);
  11453. }
  11454. }
  11455. }
  11456. }
  11457. cellIndex++;
  11458. }
  11459. }
  11460. }
  11461. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11462. if (!Directory.Exists(savePath))
  11463. {
  11464. try
  11465. {
  11466. Directory.CreateDirectory(savePath);
  11467. }
  11468. catch
  11469. {
  11470. }
  11471. }
  11472. string path = savePath + Find.TeamName + "出访日程";
  11473. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11474. try
  11475. {
  11476. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11477. string postfix = ".docx";
  11478. if (dto.IsPDF == 1)
  11479. {
  11480. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11481. postfix = ".pdf";
  11482. }
  11483. doc.Save(path + postfix, saveFormat);
  11484. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11485. }
  11486. catch (Exception)
  11487. {
  11488. jw = JsonView(false);
  11489. }
  11490. return Ok(jw);
  11491. }
  11492. /// <summary>
  11493. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11494. /// </summary>
  11495. /// <param name="num"></param>
  11496. /// <returns></returns>
  11497. string GetNum(string num)
  11498. {
  11499. string str = "";
  11500. switch (num)
  11501. {
  11502. case "1":
  11503. str = "一";
  11504. break;
  11505. case "2":
  11506. str = "二";
  11507. break;
  11508. case "3":
  11509. str = "三";
  11510. break;
  11511. case "4":
  11512. str = "四";
  11513. break;
  11514. case "5":
  11515. str = "五";
  11516. break;
  11517. case "6":
  11518. str = "六";
  11519. break;
  11520. case "7":
  11521. str = "七";
  11522. break;
  11523. case "8":
  11524. str = "八";
  11525. break;
  11526. case "9":
  11527. str = "九";
  11528. break;
  11529. case "10":
  11530. str = "十";
  11531. break;
  11532. case "11":
  11533. str = "十一";
  11534. break;
  11535. case "12":
  11536. str = "十二";
  11537. break;
  11538. case "一":
  11539. str = "1";
  11540. break;
  11541. case "二":
  11542. str = "2";
  11543. break;
  11544. case "三":
  11545. str = "3";
  11546. break;
  11547. case "四":
  11548. str = "4";
  11549. break;
  11550. case "五":
  11551. str = "5";
  11552. break;
  11553. case "六":
  11554. str = "6";
  11555. break;
  11556. case "七":
  11557. str = "7";
  11558. break;
  11559. case "八":
  11560. str = "8";
  11561. break;
  11562. case "九":
  11563. str = "9";
  11564. break;
  11565. case "十":
  11566. str = "10";
  11567. break;
  11568. case "十一":
  11569. str = "11";
  11570. break;
  11571. case "十二":
  11572. str = "12";
  11573. break;
  11574. }
  11575. return str;
  11576. }
  11577. // 高亮包含指定文字的部分
  11578. void HighlightText(Run run, string targetText, Color color)
  11579. {
  11580. string text = run.Text;
  11581. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11582. if (startIndex >= 0)
  11583. {
  11584. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11585. // 前部分
  11586. if (startIndex > 0)
  11587. {
  11588. Run beforeRun = (Run)run.Clone(true);
  11589. beforeRun.Text = text.Substring(0, startIndex);
  11590. parentParagraph.InsertBefore(beforeRun, run);
  11591. }
  11592. // 匹配部分
  11593. Run matchRun = (Run)run.Clone(true);
  11594. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11595. matchRun.Font.Color = color;
  11596. parentParagraph.InsertBefore(matchRun, run);
  11597. // 后部分
  11598. if (startIndex + targetText.Length < text.Length)
  11599. {
  11600. Run afterRun = (Run)run.Clone(true);
  11601. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11602. parentParagraph.InsertBefore(afterRun, run);
  11603. }
  11604. // 删除原始Run
  11605. run.Remove();
  11606. }
  11607. }
  11608. #endregion
  11609. #endregion
  11610. #region 团组成本
  11611. /// <summary>
  11612. /// 团组成本数据初始化
  11613. /// </summary>
  11614. /// <param name="dto"></param>
  11615. /// <returns></returns>
  11616. [HttpPost]
  11617. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11618. {
  11619. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11620. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11621. WHEN COUNT(*) >= 0 THEN 'True'
  11622. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11623. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11624. ").ToList(); //团组列表
  11625. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11626. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11627. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11628. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11629. if (groupinfoValue != null)
  11630. {
  11631. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11632. var spArr = new string[1] { countryArr };
  11633. if (countryArr.Contains("|"))
  11634. {
  11635. spArr = countryArr.Split("|");
  11636. }
  11637. else if (countryArr.Contains("、"))
  11638. {
  11639. spArr = countryArr.Split("、");
  11640. }
  11641. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11642. {
  11643. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11644. if (dbQueryCountry != null)
  11645. {
  11646. visaCountryInfoArr.Add(dbQueryCountry);
  11647. }
  11648. }
  11649. }
  11650. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11651. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11652. var create = _GroupCostRepository.
  11653. CreateGroupCostByBlackCode(dto.Diid);
  11654. if (groupCost.Count == 0 && create.Code == 0)
  11655. {
  11656. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11657. }
  11658. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11659. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11660. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11661. groupCostMap = groupCostMap.Select(x =>
  11662. {
  11663. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11664. {
  11665. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11666. }
  11667. return x;
  11668. }).ToList();
  11669. //GroupCostParameter.Add(new
  11670. // Grp_GroupCostParameter());
  11671. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11672. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11673. return Ok(JsonView(new
  11674. {
  11675. groupList,
  11676. groupInfo,
  11677. groupChecks,
  11678. groupCost = groupCostMap,
  11679. hotelNumber,
  11680. GroupCostParameter = GroupCostParameterMap,
  11681. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11682. {
  11683. x.VisaCountry,
  11684. x.VisaPrice,
  11685. x.Id,
  11686. }).ToList(),
  11687. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11688. blackCodeIsTrue = create.Code == 0 ? true : false,
  11689. hotelIsTrue = hotelIsTrue,
  11690. }));
  11691. }
  11692. /// <summary>
  11693. /// 团组成本信息保存
  11694. /// </summary>
  11695. /// <param name="dto"></param>
  11696. /// <returns></returns>
  11697. [HttpPost]
  11698. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11699. {
  11700. if (dto.Diid <= 0 || dto.Userid <= 0)
  11701. {
  11702. return Ok(JsonView(false));
  11703. }
  11704. JsonView jw = null;
  11705. bool isTrue = false;
  11706. #region 复制团组成本
  11707. //if (dto.Diid == 2581)
  11708. //{
  11709. // dto.Diid = 2599;
  11710. // dto.CheckBoxs.ForEach(x =>
  11711. // {
  11712. // x.Diid = 2599;
  11713. // });
  11714. // dto.GroupCosts.ForEach(x =>
  11715. // {
  11716. // x.Diid = 2599;
  11717. // });
  11718. // dto.CostTypeHotelNumbers.ForEach(x =>
  11719. // {
  11720. // x.Diid = 2599;
  11721. // });
  11722. // dto.GroupCostParameters.ForEach(x =>
  11723. // {
  11724. // x.DiId = 2599;
  11725. // });
  11726. //}
  11727. #endregion
  11728. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11729. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11730. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11731. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11732. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11733. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11734. try
  11735. {
  11736. _sqlSugar.BeginTran();
  11737. isTrue = await _GroupCostRepository.
  11738. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11739. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11740. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11741. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11742. _sqlSugar.CommitTran();
  11743. jw = JsonView(true, "保存成功!", isTrue);
  11744. }
  11745. catch (Exception)
  11746. {
  11747. _sqlSugar.RollbackTran();
  11748. jw = JsonView(false);
  11749. }
  11750. return Ok(jw);
  11751. }
  11752. /// <summary>
  11753. /// 司兼导数据
  11754. /// </summary>
  11755. /// <param name="dto"></param>
  11756. /// <returns></returns>
  11757. [HttpPost]
  11758. public IActionResult GetCarGuides(CarGuidesDto dto)
  11759. {
  11760. JsonView jw = null;
  11761. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11762. jw = JsonView(true, "获取成功!", Data);
  11763. return Ok(jw);
  11764. }
  11765. /// <summary>
  11766. /// 导游数据
  11767. /// </summary>
  11768. /// <param name="dto"></param>
  11769. /// <returns></returns>
  11770. [HttpPost]
  11771. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11772. {
  11773. JsonView jw = null;
  11774. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11775. // 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
  11776. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11777. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11778. jw = JsonView(true, "获取成功!", Data);
  11779. return Ok(jw);
  11780. }
  11781. /// <summary>
  11782. /// 成本车数据
  11783. /// </summary>
  11784. /// <param name="dto"></param>
  11785. /// <returns></returns>
  11786. [HttpPost]
  11787. public IActionResult GetCarInfo(CarGuidesDto dto)
  11788. {
  11789. JsonView jw = null;
  11790. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11791. jw = JsonView(true, "获取成功!", Data);
  11792. return Ok(jw);
  11793. }
  11794. /// <summary>
  11795. /// 景点数据
  11796. /// </summary>
  11797. /// <param name="dto"></param>
  11798. /// <returns></returns>
  11799. [HttpPost]
  11800. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11801. {
  11802. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11803. return Ok(JsonView(true, "获取成功!", Data));
  11804. }
  11805. /// <summary>
  11806. /// 成本通知
  11807. /// </summary>
  11808. /// <param name="dto"></param>
  11809. /// <returns></returns>
  11810. [HttpPost]
  11811. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11812. {
  11813. if (dto.Diid < 0)
  11814. {
  11815. return Ok(JsonView(false));
  11816. }
  11817. JsonView jw = null;
  11818. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11819. if (GroupCostParameter != null)
  11820. {
  11821. int IsShare = 0;
  11822. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11823. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11824. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11825. string msg = string.Empty;
  11826. if (isTrue)
  11827. {
  11828. if (IsShare == 0)
  11829. {
  11830. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11831. }
  11832. else
  11833. {
  11834. #region 企微通知对应岗位用户
  11835. try
  11836. {
  11837. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11838. }
  11839. catch (Exception ex)
  11840. {
  11841. }
  11842. #endregion
  11843. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11844. }
  11845. jw = JsonView(isTrue, msg, new { IsShare });
  11846. }
  11847. else
  11848. {
  11849. msg = "修改失败!";
  11850. jw = JsonView(isTrue, msg);
  11851. }
  11852. }
  11853. else
  11854. {
  11855. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11856. }
  11857. return Ok(jw);
  11858. }
  11859. /// <summary>
  11860. /// 导出报价单
  11861. /// </summary>
  11862. /// <param name="dto"></param>
  11863. /// <returns></returns>
  11864. [HttpPost]
  11865. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11866. {
  11867. if (dto.Diid == 0)
  11868. {
  11869. return Ok(JsonView(false, "请传递团组id"));
  11870. }
  11871. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11872. if (deleInfo.Code != 0)
  11873. {
  11874. return Ok(JsonView(false, "团组信息查询失败!"));
  11875. }
  11876. var di = deleInfo.Data as DelegationInfoWebView;
  11877. if (di != null)
  11878. {
  11879. di.TeamName = di.TeamName.Replace("|", "、");
  11880. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11881. //文件名
  11882. string strFileName = di.TeamName + "-收款账单.doc";
  11883. //获取模板
  11884. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11885. //载入模板
  11886. Document doc = new Document(tmppath);
  11887. decimal TotalPrice = 0.00M;
  11888. string itemStr = string.Empty;
  11889. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11890. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11891. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11892. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11893. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11894. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11895. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11896. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11897. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11898. foreach (var cost in groupCostType)
  11899. {
  11900. var List = cost.ToList();
  11901. if (cost.Key == "A")
  11902. {
  11903. foreach (var ListItem in List)
  11904. {
  11905. if (ListItem.number > 0)
  11906. {
  11907. if (ListItem.code.Contains("TBR"))
  11908. {
  11909. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11910. }
  11911. else
  11912. {
  11913. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11914. }
  11915. TotalPrice += (ListItem.number * ListItem.price);
  11916. }
  11917. }
  11918. }
  11919. else
  11920. {
  11921. itemStr = itemStr.Insert(0, "A段\r\n");
  11922. itemStr += "B段\r\n";
  11923. foreach (var ListItem in List)
  11924. {
  11925. if (ListItem.number > 0)
  11926. {
  11927. if (ListItem.code.Contains("TBR"))
  11928. {
  11929. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11930. }
  11931. else
  11932. {
  11933. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11934. }
  11935. TotalPrice += (ListItem.number * ListItem.price);
  11936. }
  11937. }
  11938. }
  11939. }
  11940. #region 替换Word模板书签内容
  11941. Dictionary<string, string> marks = new Dictionary<string, string>();
  11942. marks.Add("To", di.ClientUnit);//付款方
  11943. marks.Add("ToTel", di.TellPhone);//付款方电话
  11944. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  11945. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  11946. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  11947. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  11948. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  11949. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  11950. marks.Add("PayItemContent", itemStr);//详细信息
  11951. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  11952. #endregion
  11953. ////注
  11954. //if (doc.Range.Bookmarks["Attention"] != null)
  11955. //{
  11956. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  11957. // mark.Text = frList[0].Attention;
  11958. //}
  11959. foreach (var item in marks.Keys)
  11960. {
  11961. if (doc.Range.Bookmarks[item] != null)
  11962. {
  11963. Bookmark mark = doc.Range.Bookmarks[item];
  11964. mark.Text = marks[item];
  11965. }
  11966. }
  11967. byte[] bytes = null;
  11968. using (MemoryStream stream = new MemoryStream())
  11969. {
  11970. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11971. bytes = stream.ToArray();
  11972. }
  11973. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  11974. return Ok(JsonView(true, "", new
  11975. {
  11976. Data = bytes,
  11977. strFileName,
  11978. }));
  11979. }
  11980. else
  11981. {
  11982. return Ok(JsonView(false, "团组信息不存在!"));
  11983. }
  11984. }
  11985. /// <summary>
  11986. /// 导出团组成本
  11987. /// </summary>
  11988. /// <param name="dto"></param>
  11989. /// <returns></returns>
  11990. [HttpPost]
  11991. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  11992. {
  11993. var jw = JsonView(false);
  11994. if (dto.Diid == 0)
  11995. {
  11996. return Ok(JsonView(false, "请传递团组id"));
  11997. }
  11998. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11999. if (deleInfo.Code != 0)
  12000. {
  12001. return Ok(JsonView(false, "团组信息查询失败!"));
  12002. }
  12003. var di = deleInfo.Data as DelegationInfoWebView;
  12004. if (di == null)
  12005. {
  12006. return Ok(JsonView(false, "团组信息查询失败!"));
  12007. }
  12008. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  12009. WorkbookDesigner designer = new WorkbookDesigner();
  12010. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  12011. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  12012. for (int i = 0; i < List_GC.Count; i++)
  12013. {
  12014. GroupCost_Excel gc = new GroupCost_Excel();
  12015. gc.Id = List_GC[i].Id;
  12016. gc.Diid = List_GC[i].Diid.ToString();
  12017. gc.DAY = List_GC[i].DAY;
  12018. string week = "";
  12019. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  12020. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  12021. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  12022. gc.ITIN = List_GC[i].ITIN;
  12023. gc.CarType = List_GC[i].CarType;
  12024. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  12025. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  12026. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  12027. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  12028. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  12029. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  12030. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  12031. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  12032. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  12033. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  12034. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  12035. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  12036. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12037. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  12038. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  12039. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  12040. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  12041. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  12042. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  12043. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  12044. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  12045. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  12046. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  12047. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  12048. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  12049. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  12050. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  12051. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  12052. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  12053. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  12054. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  12055. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  12056. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  12057. List_GC1.Add(gc);
  12058. }
  12059. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  12060. dt.TableName = "TB";
  12061. //报表标题等不用dt的值
  12062. designer.SetDataSource("TeamName", dto.title.TeamName);
  12063. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12064. designer.SetDataSource("Tax", dto.title.Tax);
  12065. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12066. designer.SetDataSource("Currency", dto.title.Currency);
  12067. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12068. designer.SetDataSource("Rate", dto.title.Rate);
  12069. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12070. var Aparams = hotels.Find(x => x.Type == "Default");
  12071. if (Aparams == null)
  12072. {
  12073. return Ok(jw);
  12074. }
  12075. //酒店数量
  12076. var txtSGRNumber = Aparams.SGR.ToString();
  12077. var txtTBRNumber = Aparams.TBR.ToString();
  12078. var txtJSESNumber = Aparams.JSES.ToString();
  12079. var txtSUITENumbe = Aparams.SUITE.ToString();
  12080. if (dto.costType == "B")
  12081. {
  12082. Aparams = hotels.Find(x => x.Type == "A");
  12083. var Bparams = hotels.Find(x => x.Type == "B");
  12084. if (Aparams == null || Bparams == null)
  12085. {
  12086. return Ok(jw);
  12087. }
  12088. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12089. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12090. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12091. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12092. }
  12093. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12094. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12095. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12096. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12097. var ws = designer.Workbook.Worksheets[0];
  12098. int Row = List_GC.Count;
  12099. int startIndex = 11;
  12100. int HideRows = 0;
  12101. List<int> hideRowsList = new List<int>();
  12102. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12103. #region A段left数据
  12104. var left = dto.leftInfo.Find(x => x.Type == "A");
  12105. if (left == null)
  12106. {
  12107. return Ok(jw);
  12108. }
  12109. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12110. if (leftBindData != null)
  12111. {
  12112. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12113. designer.SetDataSource("VisaRS", leftBindData.rs);
  12114. designer.SetDataSource("VisaXS", leftBindData.xs);
  12115. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12116. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12117. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12118. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12119. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12120. }
  12121. else
  12122. {
  12123. hideRowsList.Add(Row + startIndex + HideRows);
  12124. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12125. }
  12126. HideRows += 2;
  12127. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12128. if (leftBindData != null)
  12129. {
  12130. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12131. designer.SetDataSource("BXRS", leftBindData.rs);
  12132. designer.SetDataSource("BXXS", leftBindData.xs);
  12133. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12134. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12135. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12136. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12137. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12138. }
  12139. else
  12140. {
  12141. hideRowsList.Add(Row + startIndex + HideRows);
  12142. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12143. }
  12144. HideRows += 2;
  12145. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12146. if (leftBindData != null)
  12147. {
  12148. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12149. designer.SetDataSource("HSRS", leftBindData.rs);
  12150. designer.SetDataSource("HSXS", leftBindData.xs);
  12151. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12152. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12153. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12154. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12155. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12156. }
  12157. else
  12158. {
  12159. hideRowsList.Add(Row + startIndex + HideRows);
  12160. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12161. }
  12162. HideRows += 2;
  12163. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12164. if (leftBindData != null)
  12165. {
  12166. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12167. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12168. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12169. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12170. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12171. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12172. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12173. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12174. }
  12175. else
  12176. {
  12177. hideRowsList.Add(Row + startIndex + HideRows);
  12178. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12179. }
  12180. HideRows += 2;
  12181. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12182. if (leftBindData != null)
  12183. {
  12184. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12185. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12186. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12187. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12188. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12189. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12190. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12191. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12192. }
  12193. else
  12194. {
  12195. hideRowsList.Add(Row + startIndex + HideRows);
  12196. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12197. }
  12198. HideRows += 2;
  12199. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12200. if (leftBindData != null)
  12201. {
  12202. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12203. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12204. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12205. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12206. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12207. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12208. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12209. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12210. }
  12211. else
  12212. {
  12213. hideRowsList.Add(Row + startIndex + HideRows);
  12214. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12215. }
  12216. HideRows += 2;
  12217. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12218. if (leftBindData != null)
  12219. {
  12220. ////TBR
  12221. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12222. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12223. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12224. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12225. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12226. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12227. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12228. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12229. }
  12230. else
  12231. {
  12232. hideRowsList.Add(Row + startIndex + HideRows);
  12233. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12234. }
  12235. HideRows += 2;
  12236. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12237. if (leftBindData != null)
  12238. {
  12239. ////SGR
  12240. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12241. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12242. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12243. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12244. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12245. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12246. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12247. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12248. }
  12249. else
  12250. {
  12251. hideRowsList.Add(Row + startIndex + HideRows);
  12252. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12253. }
  12254. HideRows += 2;
  12255. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12256. if (leftBindData != null)
  12257. {
  12258. ////JS/ES
  12259. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12260. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12261. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12262. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12263. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12264. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12265. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12266. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12267. }
  12268. else
  12269. {
  12270. hideRowsList.Add(Row + startIndex + HideRows);
  12271. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12272. }
  12273. HideRows += 2;
  12274. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12275. if (leftBindData != null)
  12276. {
  12277. ////SUITE
  12278. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12279. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12280. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12281. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12282. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12283. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12284. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12285. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12286. }
  12287. else
  12288. {
  12289. hideRowsList.Add(Row + startIndex + HideRows);
  12290. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12291. }
  12292. HideRows += 2;
  12293. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12294. if (leftBindData != null)
  12295. {
  12296. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12297. designer.SetDataSource("DJRS", leftBindData.rs);
  12298. designer.SetDataSource("DJXS", leftBindData.xs);
  12299. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12300. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12301. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12302. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12303. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12304. }
  12305. else
  12306. {
  12307. hideRowsList.Add(Row + startIndex + HideRows);
  12308. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12309. }
  12310. HideRows += 2;
  12311. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12312. if (leftBindData != null)
  12313. {
  12314. designer.SetDataSource("HCPCB", leftBindData.cb);
  12315. designer.SetDataSource("HCPRS", leftBindData.rs);
  12316. designer.SetDataSource("HCPXS", leftBindData.xs);
  12317. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12318. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12319. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12320. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12321. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12322. }
  12323. else
  12324. {
  12325. hideRowsList.Add(Row + startIndex + HideRows);
  12326. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12327. }
  12328. HideRows += 2;
  12329. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12330. if (leftBindData != null)
  12331. {
  12332. designer.SetDataSource("CPCB", leftBindData.cb);
  12333. designer.SetDataSource("CPRS", leftBindData.rs);
  12334. designer.SetDataSource("CPXS", leftBindData.xs);
  12335. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12336. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12337. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12338. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12339. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12340. }
  12341. else
  12342. {
  12343. hideRowsList.Add(Row + startIndex + HideRows);
  12344. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12345. }
  12346. HideRows += 2;
  12347. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12348. if (leftBindData != null)
  12349. {
  12350. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12351. designer.SetDataSource("GWRS", leftBindData.rs);
  12352. designer.SetDataSource("GWXS", leftBindData.xs);
  12353. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12354. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12355. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12356. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12357. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12358. }
  12359. else
  12360. {
  12361. hideRowsList.Add(Row + startIndex + HideRows);
  12362. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12363. }
  12364. HideRows += 2;
  12365. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12366. if (leftBindData != null)
  12367. {
  12368. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12369. designer.SetDataSource("LYJRS", leftBindData.rs);
  12370. designer.SetDataSource("LYJXS", leftBindData.xs);
  12371. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12372. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12373. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12374. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12375. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12376. }
  12377. else
  12378. {
  12379. hideRowsList.Add(Row + startIndex + HideRows);
  12380. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12381. }
  12382. #endregion
  12383. #region A段Right信息
  12384. var right = dto.rightInfo.Find(x => x.Type == "A");
  12385. if (right == null)
  12386. {
  12387. return Ok(jw);
  12388. }
  12389. HideRows += 4;
  12390. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12391. if (rightBindData != null)
  12392. {
  12393. //经济舱 + 双人间 TBR
  12394. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12395. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12396. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12397. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12398. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12399. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12400. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12401. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12402. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12403. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12404. }
  12405. else
  12406. {
  12407. hideRowsList.Add(Row + startIndex + HideRows);
  12408. }
  12409. HideRows += 2;
  12410. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12411. if (rightBindData != null)
  12412. {
  12413. //经济舱 + 单人间 SGR
  12414. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12415. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12416. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12417. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12418. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12419. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12420. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12421. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12422. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12423. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12424. }
  12425. else
  12426. {
  12427. hideRowsList.Add(Row + startIndex + HideRows);
  12428. }
  12429. HideRows += 2;
  12430. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12431. if (rightBindData != null)
  12432. {
  12433. //公务舱 + 单人间 SGR
  12434. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12435. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12436. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12437. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12438. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12439. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12440. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12441. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12442. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12443. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12444. }
  12445. else
  12446. {
  12447. hideRowsList.Add(Row + startIndex + HideRows);
  12448. }
  12449. HideRows += 2;
  12450. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12451. if (rightBindData != null)
  12452. {
  12453. //公务舱 + 小套房 JSES
  12454. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12455. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12456. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12457. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12458. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12459. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12460. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12461. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12462. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12463. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12464. }
  12465. else
  12466. {
  12467. hideRowsList.Add(Row + startIndex + HideRows);
  12468. }
  12469. HideRows += 2;
  12470. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12471. if (rightBindData != null)
  12472. {
  12473. //公务舱 + 小套房 JSES
  12474. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12475. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12476. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12477. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12478. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12479. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12480. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12481. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12482. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12483. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12484. }
  12485. else
  12486. {
  12487. hideRowsList.Add(Row + startIndex + HideRows);
  12488. }
  12489. HideRows += 2;
  12490. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12491. if (rightBindData != null)
  12492. {
  12493. //经济舱 + 大套房
  12494. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12495. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12496. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12497. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12498. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12499. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12500. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12501. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12502. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12503. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12504. }
  12505. else
  12506. {
  12507. hideRowsList.Add(Row + startIndex + HideRows);
  12508. }
  12509. HideRows += 2;
  12510. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12511. if (rightBindData != null)
  12512. {
  12513. //头等舱 + 小套房 JSES
  12514. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12515. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12516. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12517. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12518. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12519. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12520. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12521. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12522. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12523. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12524. }
  12525. else
  12526. {
  12527. hideRowsList.Add(Row + startIndex + HideRows);
  12528. }
  12529. HideRows += 2;
  12530. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12531. if (rightBindData != null)
  12532. {
  12533. //头等舱 + 大套房
  12534. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12535. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12536. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12537. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12538. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12539. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12540. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12541. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12542. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12543. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12544. }
  12545. else
  12546. {
  12547. hideRowsList.Add(Row + startIndex + HideRows);
  12548. }
  12549. #endregion
  12550. #region B段标题清空
  12551. designer.SetDataSource("CostBDRCB", "");
  12552. designer.SetDataSource("CostBRS", "");
  12553. designer.SetDataSource("CostBXS", "");
  12554. designer.SetDataSource("CostBZCB", "");
  12555. designer.SetDataSource("CostBDRBJ", "");
  12556. designer.SetDataSource("CostBZBJ", "");
  12557. designer.SetDataSource("CostBDRLR", "");
  12558. designer.SetDataSource("CostBZLR", "");
  12559. designer.SetDataSource("CostBDRCBOM", "");
  12560. designer.SetDataSource("CostBRSOM", "");
  12561. designer.SetDataSource("CostBZCBOM", "");
  12562. designer.SetDataSource("CostBDRBJOM", "");
  12563. designer.SetDataSource("CostBZBJOM", "");
  12564. designer.SetDataSource("CostBDRLROM", "");
  12565. designer.SetDataSource("CostBZLROM", "");
  12566. #endregion
  12567. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12568. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12569. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12570. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12571. designer.SetDataSource("DJName", "地接(CNY)");
  12572. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12573. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12574. designer.SetDataSource("GWName", "公务(CNY)");
  12575. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12576. designer.SetDataSource("LYJName", "零用金(CNY)");
  12577. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12578. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12579. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12580. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12581. designer.SetDataSource("BXName", "保险(CNY)");
  12582. designer.SetDataSource("VisaName", "签证(CNY)");
  12583. #region B段基本数据
  12584. if (dto.costType == "B")
  12585. {
  12586. left = dto.leftInfo.Find(x => x.Type == "B");
  12587. if (left == null)
  12588. {
  12589. return Ok(jw);
  12590. }
  12591. #region B段left数据
  12592. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12593. if (leftBindData != null)
  12594. {
  12595. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12596. designer.SetDataSource("BHSRS", leftBindData.rs);
  12597. designer.SetDataSource("BHSXS", leftBindData.xs);
  12598. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12599. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12600. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12601. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12602. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12603. }
  12604. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12605. if (leftBindData != null)
  12606. {
  12607. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12608. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12609. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12610. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12611. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12612. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12613. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12614. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12615. }
  12616. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12617. if (leftBindData != null)
  12618. {
  12619. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12620. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12621. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12622. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12623. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12624. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12625. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12626. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12627. }
  12628. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12629. if (leftBindData != null)
  12630. {
  12631. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12632. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12633. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12634. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12635. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12636. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12637. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12638. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12639. }
  12640. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12641. if (leftBindData != null)
  12642. {
  12643. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12644. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12645. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12646. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12647. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12648. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12649. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12650. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12651. }
  12652. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12653. if (leftBindData != null)
  12654. {
  12655. designer.SetDataSource("BCPCB", leftBindData.cb);
  12656. designer.SetDataSource("BCPRS", leftBindData.rs);
  12657. designer.SetDataSource("BCPXS", leftBindData.xs);
  12658. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12659. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12660. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12661. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12662. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12663. }
  12664. //TBR
  12665. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12666. if (leftBindData != null)
  12667. {
  12668. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12669. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12670. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12671. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12672. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12673. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12674. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12675. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12676. }
  12677. //SGR
  12678. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12679. if (leftBindData != null)
  12680. {
  12681. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12682. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12683. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12684. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12685. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12686. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12687. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12688. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12689. }
  12690. //JS/ES
  12691. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12692. if (leftBindData != null)
  12693. {
  12694. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12695. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12696. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12697. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12698. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12699. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12700. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12701. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12702. }
  12703. //SUITE
  12704. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12705. if (leftBindData != null)
  12706. {
  12707. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12708. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12709. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12710. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12711. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12712. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12713. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12714. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12715. }
  12716. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12717. if (leftBindData != null)
  12718. {
  12719. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  12720. designer.SetDataSource("BDJRS", leftBindData.rs);
  12721. designer.SetDataSource("BDJXS", leftBindData.xs);
  12722. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12723. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12724. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12725. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12726. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12727. }
  12728. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12729. if (leftBindData != null)
  12730. {
  12731. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12732. designer.SetDataSource("BGWRS", leftBindData.rs);
  12733. designer.SetDataSource("BGWXS", leftBindData.xs);
  12734. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12735. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12736. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12737. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12738. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12739. }
  12740. #region 优化方案
  12741. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12742. //excelBind.Add("零用金", new {
  12743. //cb="",
  12744. //rs="",
  12745. //xs ="",
  12746. //zcb = "",
  12747. //});
  12748. #endregion
  12749. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12750. if (leftBindData != null)
  12751. {
  12752. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12753. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12754. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12755. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12756. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12757. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12758. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12759. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12760. }
  12761. #endregion
  12762. #region B段Right信息
  12763. right = dto.rightInfo.Find(x => x.Type == "B");
  12764. if (right == null)
  12765. {
  12766. return Ok(jw);
  12767. }
  12768. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12769. if (rightBindData != null)
  12770. {
  12771. //经济舱 + 双人间 TBR
  12772. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12773. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12774. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12775. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12776. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12777. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12778. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12779. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12780. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12781. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12782. }
  12783. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12784. if (rightBindData != null)
  12785. {
  12786. //经济舱 + 单人间 SGR
  12787. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12788. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12789. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12790. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12791. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12792. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12793. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12794. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12795. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12796. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12797. }
  12798. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12799. if (rightBindData != null)
  12800. {
  12801. //公务舱 + 单人间 SGR
  12802. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12803. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12804. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12805. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12806. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12807. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12808. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12809. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12810. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12811. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12812. }
  12813. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12814. if (rightBindData != null)
  12815. {
  12816. //公务舱 + 小套房 JSES
  12817. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12818. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12819. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12820. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12821. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12822. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12823. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12824. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12825. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12826. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12827. }
  12828. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12829. if (rightBindData != null)
  12830. {
  12831. //公务舱 + 小套房 JSES
  12832. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12833. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12834. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12835. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12836. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12837. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12838. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12839. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12840. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12841. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12842. }
  12843. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12844. if (rightBindData != null)
  12845. {
  12846. //经济舱 + 大套房
  12847. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12848. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12849. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12850. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12851. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12852. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12853. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12854. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12855. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12856. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12857. }
  12858. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12859. if (rightBindData != null)
  12860. {
  12861. //头等舱 + 小套房 JSES
  12862. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12863. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12864. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12865. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12866. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12867. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12868. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12869. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12870. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12871. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12872. }
  12873. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12874. if (rightBindData != null)
  12875. {
  12876. //头等舱 + 大套房
  12877. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12878. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12879. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12880. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12881. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12882. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12883. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12884. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12885. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12886. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12887. }
  12888. #endregion
  12889. #region 标题
  12890. designer.SetDataSource("CostBDRCB", "单人成本");
  12891. designer.SetDataSource("CostBRS", "人数");
  12892. designer.SetDataSource("CostBXS", "系数");
  12893. designer.SetDataSource("CostBZCB", "总成本");
  12894. designer.SetDataSource("CostBDRBJ", "单人报价");
  12895. designer.SetDataSource("CostBZBJ", "总报价");
  12896. designer.SetDataSource("CostBDRLR", "单人利润");
  12897. designer.SetDataSource("CostBZLR", "总利润");
  12898. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12899. designer.SetDataSource("CostBRSOM", "人数");
  12900. designer.SetDataSource("CostBZCBOM", "总成本");
  12901. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12902. designer.SetDataSource("CostBZBJOM", "总报价");
  12903. designer.SetDataSource("CostBDRLROM", "单人利润");
  12904. designer.SetDataSource("CostBZLROM", "总利润");
  12905. #endregion
  12906. }
  12907. #endregion
  12908. designer.SetDataSource("TzZCB2", TzZCB2);
  12909. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12910. designer.SetDataSource("TzZLR2", TzZLR2);
  12911. string[] dataSourceKeys = new string[]
  12912. {
  12913. "VF",
  12914. "TGS",
  12915. "TGOF",
  12916. "TGM",
  12917. "TGA",
  12918. "TGTF",
  12919. "TGEF",
  12920. "CFM",
  12921. "CFOF",
  12922. "B",
  12923. "L",
  12924. "D",
  12925. "TBR",
  12926. "SGR",
  12927. "JSES",
  12928. "Suite",
  12929. "TV",
  12930. "1L",
  12931. "IF",
  12932. "EF",
  12933. "BRF",
  12934. "TE",
  12935. "TGT",
  12936. "DRVT",
  12937. "PC",
  12938. "TLF",
  12939. "ECT"
  12940. };
  12941. foreach (var item in dataSourceKeys)
  12942. {
  12943. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  12944. if (find != null)
  12945. {
  12946. designer.SetDataSource(item, find.text);
  12947. }
  12948. else
  12949. {
  12950. designer.SetDataSource(item, 0);
  12951. }
  12952. }
  12953. designer.SetDataSource(dt);
  12954. //根据数据源处理生成报表内容
  12955. designer.Process();
  12956. designer.Workbook.Worksheets[0].Name = "清单";
  12957. Worksheet sheet = designer.Workbook.Worksheets[0];
  12958. foreach (var Rowindex in hideRowsList)
  12959. {
  12960. ws.Cells.HideRows(Rowindex, 2);
  12961. }
  12962. byte[] bytes = null;
  12963. string strFileName = di.TeamName + "-团组-成本.xls";
  12964. using (MemoryStream stream = new MemoryStream())
  12965. {
  12966. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  12967. bytes = stream.ToArray();
  12968. }
  12969. return Ok(JsonView(true, "", new
  12970. {
  12971. Data = bytes,
  12972. strFileName,
  12973. }));
  12974. }
  12975. /// <summary>
  12976. /// 导出客户报表
  12977. /// </summary>
  12978. /// <returns></returns>
  12979. [HttpPost]
  12980. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  12981. {
  12982. var jw = JsonView(false);
  12983. if (dto.Diid == 0)
  12984. {
  12985. return Ok(JsonView(false, "请传递团组id"));
  12986. }
  12987. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12988. if (deleInfo.Code != 0)
  12989. {
  12990. return Ok(JsonView(false, "团组信息查询失败!"));
  12991. }
  12992. var di = deleInfo.Data as DelegationInfoWebView;
  12993. if (di == null)
  12994. {
  12995. return Ok(JsonView(false, "团组信息查询失败!"));
  12996. }
  12997. //文件名
  12998. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  12999. //获取模板
  13000. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  13001. //载入模板
  13002. Document doc = new Document(tmppath);
  13003. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  13004. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  13005. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  13006. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  13007. var AParameter = ParameterList.Find(x => x.CostType == "A");
  13008. var BParameter = ParameterList.Find(x => x.CostType == "B");
  13009. if (AParameter == null)
  13010. {
  13011. return Ok(JsonView(false, "系数不存在!"));
  13012. }
  13013. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  13014. , TzAirDesc, TzZCost;
  13015. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  13016. = TzAirDesc = TzZCost = string.Empty;
  13017. TzNumber = AParameter.CostTypenumber.ToString();
  13018. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  13019. CarGuides1 = dto.CarGuides1;
  13020. Meal = dto.Meal;
  13021. SubsidizedMeals = dto.SubsidizedMeals;
  13022. NightRepair = dto.NightRepair;
  13023. AttractionsTickets = dto.AttractionsTickets;
  13024. MiscellaneousFees = dto.MiscellaneousFees;
  13025. ATip = dto.ATip;
  13026. TzHotelDesc = "";
  13027. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  13028. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  13029. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  13030. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  13031. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  13032. TzAirDesc = "";
  13033. TzZCost = dto.TzZCost;
  13034. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  13035. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  13036. var index = 1;
  13037. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  13038. foreach (var item in TzHotelDescArr)
  13039. {
  13040. if (AinfoArr != null)
  13041. {
  13042. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13043. if (Ainfo != null)
  13044. {
  13045. if (int.Parse(Ainfo.rs) <= 0)
  13046. {
  13047. continue;
  13048. }
  13049. var hotelText = string.Empty;
  13050. switch (item)
  13051. {
  13052. case "SGR":
  13053. hotelText = "单人间";
  13054. break;
  13055. case "JSES":
  13056. hotelText = "小套房";
  13057. break;
  13058. case "SUITE":
  13059. hotelText = "套房";
  13060. break;
  13061. case "TBR":
  13062. hotelText = "双人间";
  13063. break;
  13064. }
  13065. if (item != "TBR")
  13066. {
  13067. 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";
  13068. }
  13069. else
  13070. {
  13071. 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";
  13072. }
  13073. index++;
  13074. }
  13075. }
  13076. }
  13077. index = 1;
  13078. foreach (var item in TzAirDescArr)
  13079. {
  13080. if (AinfoArr != null)
  13081. {
  13082. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13083. if (Ainfo != null)
  13084. {
  13085. if (int.Parse(Ainfo.rs) <= 0)
  13086. {
  13087. continue;
  13088. }
  13089. 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";
  13090. index++;
  13091. }
  13092. }
  13093. }
  13094. if (dto.costType == "B")
  13095. {
  13096. if (BParameter == null)
  13097. {
  13098. return Ok(JsonView(false, "B段系数不存在!"));
  13099. }
  13100. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13101. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13102. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13103. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13104. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13105. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13106. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13107. foreach (var item in TzHotelDescArr)
  13108. {
  13109. if (AinfoArr != null)
  13110. {
  13111. TzHotelDesc += "B段信息 \r\n";
  13112. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13113. if (Ainfo != null)
  13114. {
  13115. if (int.Parse(Ainfo.rs) <= 0)
  13116. {
  13117. continue;
  13118. }
  13119. var hotelText = string.Empty;
  13120. switch (item)
  13121. {
  13122. case "SGR":
  13123. hotelText = "单人间";
  13124. break;
  13125. case "JSES":
  13126. hotelText = "小套房";
  13127. break;
  13128. case "SUITE":
  13129. hotelText = "套房";
  13130. break;
  13131. case "TBR":
  13132. hotelText = "双人间";
  13133. break;
  13134. }
  13135. if (item != "TBR")
  13136. {
  13137. 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";
  13138. }
  13139. else
  13140. {
  13141. 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";
  13142. }
  13143. index++;
  13144. }
  13145. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13146. }
  13147. }
  13148. index = 1;
  13149. foreach (var item in TzAirDescArr)
  13150. {
  13151. if (AinfoArr != null)
  13152. {
  13153. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13154. if (Ainfo != null)
  13155. {
  13156. if (int.Parse(Ainfo.rs) <= 0)
  13157. {
  13158. continue;
  13159. }
  13160. 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";
  13161. index++;
  13162. }
  13163. }
  13164. }
  13165. }
  13166. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13167. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13168. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13169. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13170. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13171. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13172. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13173. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13174. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13175. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13176. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13177. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13178. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13179. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13180. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13181. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13182. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13183. DickeyValue.Add("TzZCost", TzZCost);
  13184. foreach (var key in DickeyValue.Keys)
  13185. {
  13186. if (doc.Range.Bookmarks[key] != null)
  13187. {
  13188. Bookmark mark = doc.Range.Bookmarks[key];
  13189. mark.Text = DickeyValue[key];
  13190. }
  13191. }
  13192. byte[] bytes = null;
  13193. string strFileName = di.TeamName + "-客户报价.doc";
  13194. using (MemoryStream stream = new MemoryStream())
  13195. {
  13196. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13197. bytes = stream.ToArray();
  13198. }
  13199. return Ok(JsonView(true, "", new
  13200. {
  13201. Data = bytes,
  13202. strFileName,
  13203. }));
  13204. }
  13205. /// <summary>
  13206. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13207. /// </summary>
  13208. /// <param name="dto"></param>
  13209. /// <returns></returns>
  13210. [HttpPost]
  13211. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13212. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13213. {
  13214. try
  13215. {
  13216. #region 参数验证
  13217. if (dto.DiId < 0)
  13218. {
  13219. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13220. }
  13221. List<int> cTableIds = new List<int>() {
  13222. 76 ,//酒店预订
  13223. 77 ,//行程
  13224. 79 ,//车/导游地接
  13225. 80 ,//签证
  13226. 81 ,//邀请/公务活
  13227. 82 ,//团组客户保险
  13228. 85 ,//机票预订
  13229. 98 ,//其他款项
  13230. 285 ,//收款退还
  13231. 751 ,//酒店早餐
  13232. 1015 // 超支费用
  13233. };
  13234. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13235. {
  13236. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13237. }
  13238. #endregion
  13239. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13240. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13241. if (_GroupCostParameters.Count <= 0)
  13242. {
  13243. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13244. }
  13245. if (_GroupCostParameters[0].IsShare == 0)
  13246. {
  13247. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13248. }
  13249. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13250. //处理date为空问题
  13251. if (_GroupCosts.Count > 0)
  13252. {
  13253. for (int i = 0; i < _GroupCosts.Count; i++)
  13254. {
  13255. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13256. {
  13257. if (i > 0)
  13258. {
  13259. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13260. }
  13261. }
  13262. }
  13263. }
  13264. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13265. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13266. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13267. string currCode = "";
  13268. #region currCode 验证
  13269. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13270. if (isInt)
  13271. {
  13272. var currData = currDatas.Find(it => it.Id == intCurrency);
  13273. if (currData != null)
  13274. {
  13275. currCode = currData.Name;
  13276. }
  13277. }
  13278. else
  13279. {
  13280. currCode = _GroupCostParameters[0].Currency.Trim();
  13281. }
  13282. #endregion
  13283. //op,酒店单段模式存储
  13284. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13285. {
  13286. CurrencyCode = currCode,
  13287. Rate = _GroupCostParameters[0].Rate,
  13288. CostType = _GroupCostParameters[0].CostType,
  13289. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13290. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13291. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13292. };
  13293. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13294. if (_GroupCostParameters.Count == 2)
  13295. {
  13296. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13297. }
  13298. foreach (var item in _GroupCostParameters)
  13299. {
  13300. decimal _rate = 1;
  13301. decimal _rate1 = item.Rate;
  13302. decimal _scale = 1;
  13303. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13304. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13305. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13306. //if (userInfo != null)
  13307. //{
  13308. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13309. // {
  13310. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13311. // {
  13312. // _scale = 1.00M;
  13313. // }
  13314. // }
  13315. //}
  13316. #endregion
  13317. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13318. {
  13319. CurrencyCode = currCode,
  13320. Rate = _rate1,
  13321. CostType = item.CostType,
  13322. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13323. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13324. CostTypeNumber = item.CostTypenumber
  13325. };
  13326. if (_GroupCostParameters.Count > 1)
  13327. {
  13328. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13329. }
  13330. else
  13331. {
  13332. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13333. }
  13334. if (dto.CTable == 79)//
  13335. {
  13336. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13337. modulePromptInfo.TotalCost = item.DJCB;
  13338. }
  13339. List<string> costTypes = new List<string>() { "A", "B" };
  13340. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13341. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13342. if (_GroupCostsDuplicates.Count() == 1)
  13343. {
  13344. _GroupCostsTypeData = _GroupCosts;
  13345. }
  13346. else
  13347. {
  13348. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13349. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13350. }
  13351. /*
  13352. * 76 酒店预订
  13353. * 77 行程
  13354. * 79 车/导游地接
  13355. * 80 签证
  13356. * 81 邀请/公务活动
  13357. * 82 团组客户保险
  13358. * 85 机票预订
  13359. * 98 其他款项
  13360. * 285 收款退还
  13361. * 751 酒店早餐
  13362. * 1015 超支费用
  13363. */
  13364. switch (dto.CTable)
  13365. {
  13366. case 76: // 酒店预订
  13367. _ModuleSubPromptInfo.AddRange(
  13368. _GroupCostsTypeData.Select(it => new
  13369. {
  13370. it.DAY,
  13371. it.Date,
  13372. it.ACCON,
  13373. it.ITIN,
  13374. it.SGR,
  13375. it.TBR,
  13376. it.JS_ES,
  13377. it.Suite
  13378. })
  13379. );
  13380. break;
  13381. case 79: // 车/导游地接
  13382. _ModuleSubPromptInfo.AddRange(
  13383. _GroupCostsTypeData.Select(it => new
  13384. {
  13385. Date = it.Date, //日期
  13386. CarFee = it.CarCost * _rate * _scale, //车费用
  13387. CarType = it.CarType, //车型
  13388. DriverFee = it.CFS * _rate * _scale, //司机工资
  13389. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13390. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13391. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13392. GuideFee = it.TGS * _rate * _scale, //导游费用
  13393. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13394. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13395. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13396. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13397. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13398. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13399. Breakfast = it.B * _rate * _scale, //早餐费
  13400. Lunch = it.L * _rate * _scale, //午餐费
  13401. Dinner = it.D * _rate * _scale, //晚餐费
  13402. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13403. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13404. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13405. TicketFee = it.EF * _rate * _scale, //门票费
  13406. TicketRemark = it.EFR, //门票费描述
  13407. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13408. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13409. SpentCash = it.PC * _rate * _scale, //零用金
  13410. LeadersFee = it.TLF * _rate * _scale, //领队费
  13411. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13412. })
  13413. );
  13414. break;
  13415. case 85: // 机票
  13416. List<dynamic> datas = new List<dynamic>();
  13417. datas.Add(
  13418. new
  13419. {
  13420. AirType = "经济舱",
  13421. AirNum = item.JJCRS,
  13422. AirDRCB = item.JJCCB,
  13423. AirZCB = (item.JJCRS * item.JJCCB)
  13424. }
  13425. );
  13426. datas.Add(
  13427. new
  13428. {
  13429. AirType = "公务舱",
  13430. AirNum = item.GWCRS,
  13431. AirDRCB = item.GWCCB,
  13432. AirZCB = (item.GWCRS * item.GWCCB)
  13433. }
  13434. );
  13435. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13436. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13437. modulePromptInfo.Data = new
  13438. {
  13439. airFeeData = datas,
  13440. airInitData = initDatas
  13441. };
  13442. _ModulePromptInfos.Add(modulePromptInfo);
  13443. break;
  13444. default:
  13445. break;
  13446. }
  13447. }
  13448. if (dto.CTable != 85)
  13449. {
  13450. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13451. _ModulePromptInfos.Add(_ModulePromptInfo);
  13452. }
  13453. _view.ModulePromptInfos = _ModulePromptInfos;
  13454. return Ok(JsonView(true, "操作成功!", _view));
  13455. }
  13456. catch (Exception ex)
  13457. {
  13458. return Ok(JsonView(false, ex.Message));
  13459. }
  13460. }
  13461. /// <summary>
  13462. /// 根据黑屏代码重新生成行程
  13463. /// </summary>
  13464. /// <param name="dto"></param>
  13465. /// <returns></returns>
  13466. [HttpPost]
  13467. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13468. {
  13469. var jw = JsonView(false);
  13470. var Create = _GroupCostRepository.
  13471. CreateGroupCostByBlackCode(dto.Diid);
  13472. jw.Msg = Create.Msg;
  13473. if (Create.Code == 0)
  13474. {
  13475. jw.Code = 200;
  13476. jw.Data = new
  13477. {
  13478. groupCost = Create.Data,
  13479. blackCodeIsTrue = true
  13480. };
  13481. }
  13482. else
  13483. {
  13484. jw.Code = 400;
  13485. jw.Data = new
  13486. {
  13487. groupCost = Create.Data,
  13488. blackCodeIsTrue = false,
  13489. };
  13490. }
  13491. return Ok(jw);
  13492. }
  13493. /// <summary>
  13494. /// 成本获取OP历史车费用
  13495. /// </summary>
  13496. /// <param name="dto"></param>
  13497. /// <returns></returns>
  13498. [HttpPost]
  13499. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13500. {
  13501. var jw = JsonView(false);
  13502. try
  13503. {
  13504. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13505. //获取现有所有车的数据
  13506. if (!dto.Param.IsNullOrWhiteSpace())
  13507. {
  13508. string sql = $@"
  13509. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13510. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13511. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13512. 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
  13513. AND gctggr.ServiceEndTime is not NULL
  13514. ORDER by gctggrc.id DESC
  13515. ";
  13516. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13517. var numeberResult = await Task.Run(() =>
  13518. {
  13519. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13520. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13521. return numberArr;
  13522. });
  13523. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13524. foreach (var item in numeberResult)
  13525. {
  13526. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13527. {
  13528. Country = "数据异常!",
  13529. City = string.Empty,
  13530. };
  13531. item.Area = find.Country + " " + find.City;
  13532. }
  13533. dbResult.AddRange(numeberResult);
  13534. if (dto.Param.Contains("、"))
  13535. {
  13536. var sp = dto.Param.Split("、");
  13537. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13538. .Where(x =>
  13539. {
  13540. return System.Array.Exists(sp, e =>
  13541. {
  13542. bool where = false;
  13543. if (x.Area != null)
  13544. {
  13545. where = x.Area.Contains(e);
  13546. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13547. {
  13548. return false;
  13549. }
  13550. }
  13551. if (x.PriceName != null && !where)
  13552. {
  13553. where = x.PriceName.Contains(e);
  13554. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13555. {
  13556. return false;
  13557. }
  13558. }
  13559. return where;
  13560. });
  13561. }).ToList();
  13562. }
  13563. else
  13564. {
  13565. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13566. .Where(x =>
  13567. {
  13568. bool where = false;
  13569. if (x.Area != null)
  13570. {
  13571. where = x.Area.Contains(dto.Param);
  13572. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13573. {
  13574. return false;
  13575. }
  13576. }
  13577. if (x.PriceName != null && !where)
  13578. {
  13579. where = x.PriceName.Contains(dto.Param);
  13580. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13581. {
  13582. return false;
  13583. }
  13584. }
  13585. return where;
  13586. }
  13587. )
  13588. .ToList();
  13589. }
  13590. }
  13591. var view = dbResult.Select(x =>
  13592. {
  13593. decimal dp = 0.00M;
  13594. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13595. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13596. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13597. {
  13598. if (startB && endB)
  13599. {
  13600. var timesp = endD.Subtract(startD);
  13601. if ((timesp.Days + 1) != 0)
  13602. {
  13603. dp = x.Price / (timesp.Days + 1);
  13604. }
  13605. }
  13606. }
  13607. else
  13608. {
  13609. dp = x.Price;
  13610. }
  13611. return new
  13612. {
  13613. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13614. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13615. x.Area,
  13616. x.id,
  13617. price = x.Price.ToString("F2"),
  13618. x.PriceName,
  13619. x.PriceContent,
  13620. x.TeamName,
  13621. x.DatePrice,
  13622. dayPrice = dp.ToString("F2"),
  13623. };
  13624. }).OrderByDescending(x => x.id).ToList();
  13625. jw = JsonView(true, "获取成功!", view);
  13626. }
  13627. catch (Exception e)
  13628. {
  13629. jw = JsonView(false, e.Message);
  13630. }
  13631. return Ok(jw);
  13632. }
  13633. #endregion
  13634. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13635. /// <summary>
  13636. /// 酒店预订
  13637. /// 酒店费用列表 根据团组Id查询
  13638. /// </summary>
  13639. /// <param name="_dto"></param>
  13640. /// <returns></returns>
  13641. [HttpPost]
  13642. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13643. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13644. {
  13645. #region 参数验证
  13646. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13647. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13648. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13649. #region 团组操作权限验证 76 酒店预定模块
  13650. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13651. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13652. #endregion
  13653. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13654. #region 页面操作权限验证
  13655. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13656. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13657. #endregion
  13658. #endregion
  13659. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13660. }
  13661. /// <summary>
  13662. /// 酒店预订
  13663. /// 基础数据
  13664. /// </summary>
  13665. /// <param name="_dto"></param>
  13666. /// <returns></returns>
  13667. [HttpPost]
  13668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13669. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13670. {
  13671. #region 参数验证
  13672. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13673. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13674. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13675. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13676. #region 页面操作权限验证
  13677. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13678. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13679. #endregion
  13680. #region 团组操作权限验证 76 酒店预定模块
  13681. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13682. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13683. #endregion
  13684. #endregion
  13685. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13686. }
  13687. /// <summary>
  13688. /// 酒店预订
  13689. /// 创建 入住卷号码
  13690. /// </summary>
  13691. /// <param name="_dto"></param>
  13692. /// <returns></returns>
  13693. [HttpPost]
  13694. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13695. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _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. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13702. #region 页面操作权限验证
  13703. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13704. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13705. #endregion
  13706. #region 团组操作权限验证 76 酒店预定模块
  13707. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13708. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13709. #endregion
  13710. #endregion
  13711. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13712. if (data.Code != 0)
  13713. {
  13714. return Ok(JsonView(false, data.Msg));
  13715. }
  13716. return Ok(JsonView(true, data.Msg, data.Data));
  13717. }
  13718. /// <summary>
  13719. /// 酒店预订
  13720. /// 详情
  13721. /// </summary>
  13722. /// <param name="_dto"></param>
  13723. /// <returns></returns>
  13724. [HttpPost]
  13725. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13726. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13727. {
  13728. #region 参数验证
  13729. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13730. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13731. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  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. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13737. #region 页面操作权限验证
  13738. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13739. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13740. #endregion
  13741. #endregion
  13742. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13743. }
  13744. /// <summary>
  13745. /// 酒店预订
  13746. /// Add Or Edit
  13747. /// </summary>
  13748. /// <param name="_dto"></param>
  13749. /// <returns></returns>
  13750. [HttpPost]
  13751. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13752. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13753. {
  13754. #region 参数验证
  13755. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13756. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13757. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  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. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13763. #region 页面操作权限验证
  13764. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13765. if (_dto.Id == 0) // Add
  13766. {
  13767. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13768. }
  13769. else if (_dto.Id > 1) // Edit
  13770. {
  13771. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13772. }
  13773. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13774. #endregion
  13775. #endregion
  13776. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13777. if (_view.Code != 200)
  13778. {
  13779. return Ok(_view);
  13780. }
  13781. #region 成本无酒店价格数据进入超支
  13782. _sqlSugar.BeginTran();
  13783. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13784. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13785. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13786. for (int i = 0; i < groupCost.Count; i++)
  13787. {
  13788. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13789. {
  13790. groupCost[i].Date = groupCost[i - 1].Date;
  13791. }
  13792. }
  13793. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13794. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13795. List<Fin_GroupExtraCostDto_OP>();
  13796. if (start_Bool && end_Bool)
  13797. {
  13798. while (start_Time < end_Time)
  13799. {
  13800. foreach (var item in groupCost_Grp)
  13801. {
  13802. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13803. {
  13804. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13805. {
  13806. extraCostList.Add(new
  13807. Fin_GroupExtraCostDto_OP
  13808. {
  13809. Area = _dto.AreaId,
  13810. coefficient = 1.5M,
  13811. createUser = _dto.UserId,
  13812. currency = _dto.CardPriceCurrency,
  13813. diId = _dto.DiId,
  13814. ManagerConfirm = 0,
  13815. SupervisorConfirm = 0,
  13816. SYsupervisorConfirm = 0,
  13817. editType = 1,
  13818. PortType = 1,
  13819. price = _dto.CardPrice,
  13820. PriceCount = 1,
  13821. priceType = 1027,
  13822. priceDetailType = 1044,
  13823. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13824. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13825. });
  13826. }
  13827. }
  13828. }
  13829. start_Time = start_Time.AddDays(1);
  13830. }
  13831. }
  13832. if (extraCostList.Any())
  13833. {
  13834. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13835. }
  13836. _sqlSugar.CommitTran();
  13837. #endregion
  13838. #region 应用推送
  13839. try
  13840. {
  13841. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13842. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13843. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13844. var diId = _dto.DiId;
  13845. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13846. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13847. #region 操作记录
  13848. var opInfo = new Crm_TableOperationRecord() {
  13849. TableName = "Grp_HotelReservations",
  13850. PortType = _dto.PortType,
  13851. DataId = hotelId,
  13852. CreateUserId = _dto.UserId
  13853. };
  13854. var opStatus = OperationEnum.NoOperation;
  13855. if (_dto.Id<1) //添加操作
  13856. {
  13857. opInfo.OperationItem = OperationEnum.Add;
  13858. }
  13859. else if (_dto.Id > 0)
  13860. {
  13861. opInfo.OperationItem = OperationEnum.Edit;
  13862. }
  13863. string opRemark = string.Empty;
  13864. if (ccpInfo != null)
  13865. {
  13866. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13867. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13868. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13869. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13870. }
  13871. opInfo.Remark = opRemark;
  13872. await _tableorRep.AddAsync(opInfo);
  13873. #endregion
  13874. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13875. //2024-10-21 新增LZ UID
  13876. var userIds = new List<int>() { 21 };
  13877. string title = $"费用审核";
  13878. string content = "";
  13879. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13880. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13881. try
  13882. {
  13883. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13884. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13885. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13886. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13887. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13888. }
  13889. catch (Exception ex )
  13890. {
  13891. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13892. }
  13893. }
  13894. catch (Exception ex)
  13895. {
  13896. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13897. }
  13898. try
  13899. {
  13900. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13901. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13902. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13903. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13904. //自动审核
  13905. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13906. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13907. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13908. //2024-10-21 新增LZ UID
  13909. var userIds = new List<int>() { 21 };
  13910. string title = $"系统通知";
  13911. var diId = _dto.DiId;
  13912. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13913. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13914. string content = "";
  13915. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13916. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13917. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13918. }
  13919. catch (Exception ex)
  13920. {
  13921. }
  13922. #endregion
  13923. return Ok(_view);
  13924. }
  13925. /// <summary>
  13926. /// 酒店自动审核测试
  13927. /// Add Or Edit
  13928. /// </summary>
  13929. /// <param name="_dto"></param>
  13930. /// <returns></returns>
  13931. [HttpPost]
  13932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13933. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  13934. {
  13935. #region 应用推送
  13936. try
  13937. {
  13938. //自动审核
  13939. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  13940. }
  13941. catch (Exception ex)
  13942. {
  13943. return Ok(JsonView(false, "操作失败"));
  13944. }
  13945. #endregion
  13946. return Ok(JsonView(false, "操作成功"));
  13947. }
  13948. /// <summary>
  13949. /// 酒店预订
  13950. /// Del
  13951. /// </summary>
  13952. /// <param name="_dto"></param>
  13953. /// <returns></returns>
  13954. [HttpPost]
  13955. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13956. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  13957. {
  13958. #region 参数验证
  13959. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13960. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13961. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13962. #region 团组操作权限验证 76 酒店预定模块
  13963. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13964. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13965. #endregion
  13966. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13967. #region 页面操作权限验证
  13968. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13969. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13970. #endregion
  13971. #endregion
  13972. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  13973. #region 操作记录
  13974. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  13975. {
  13976. TableName = "Grp_HotelReservations",
  13977. PortType = _dto.PortType,
  13978. OperationItem = OperationEnum.Del,
  13979. DataId = _dto.Id,
  13980. CreateUserId = _dto.UserId
  13981. });
  13982. #endregion
  13983. return Ok(data);
  13984. }
  13985. /// <summary>
  13986. /// 酒店预订
  13987. /// 生成VOUCHER
  13988. /// 2024.05.06 之前版本
  13989. /// </summary>
  13990. /// <param name="_dto"></param>
  13991. /// <returns></returns>
  13992. [HttpPost]
  13993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13994. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  13995. {
  13996. try
  13997. {
  13998. #region 参数验证
  13999. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  14000. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14001. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  14002. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  14003. #region 团组操作权限验证 76 酒店预定模块
  14004. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14005. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14006. #endregion
  14007. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14008. #region 页面操作权限验证
  14009. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14010. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14011. #endregion
  14012. #endregion
  14013. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  14014. //判断数据是否完整
  14015. if (hr != null)
  14016. {
  14017. if (!string.IsNullOrEmpty(hr.DetermineNo))
  14018. {
  14019. string strFileName = "HotelStatement/";
  14020. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14021. if (dele != null)
  14022. strFileName += dele.TourCode;
  14023. //载入模板
  14024. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  14025. Document doc = new Document(sss);
  14026. DocumentBuilder builder = new DocumentBuilder(doc);
  14027. #region 替换Word模板书签内容
  14028. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  14029. //入住卷预定号码
  14030. if (doc.Range.Bookmarks["VNO"] != null)
  14031. {
  14032. Bookmark mark = doc.Range.Bookmarks["VNO"];
  14033. mark.Text = hr.CheckNumber;
  14034. }
  14035. //酒店时间
  14036. if (doc.Range.Bookmarks["Date"] != null)
  14037. {
  14038. Bookmark mark = doc.Range.Bookmarks["Date"];
  14039. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14040. }
  14041. //团号
  14042. if (doc.Range.Bookmarks["TNo"] != null)
  14043. {
  14044. Bookmark mark = doc.Range.Bookmarks["TNo"];
  14045. mark.Text = dele.TourCode;
  14046. }
  14047. //预定号码
  14048. if (doc.Range.Bookmarks["BookingId"] != null)
  14049. {
  14050. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  14051. mark.Text = hr.ReservationsNo;
  14052. }
  14053. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  14054. {
  14055. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  14056. mark.Text = hr.DetermineNo;
  14057. }
  14058. //酒店城市
  14059. if (doc.Range.Bookmarks["City"] != null)
  14060. {
  14061. Bookmark mark = doc.Range.Bookmarks["City"];
  14062. mark.Text = hr.City;
  14063. }
  14064. //酒店名称
  14065. if (doc.Range.Bookmarks["HName"] != null)
  14066. {
  14067. Bookmark mark = doc.Range.Bookmarks["HName"];
  14068. mark.Text = hr.HotelName;
  14069. }
  14070. //酒店地址
  14071. if (doc.Range.Bookmarks["Address"] != null)
  14072. {
  14073. Bookmark mark = doc.Range.Bookmarks["Address"];
  14074. mark.Text = hr.HotelAddress;
  14075. }
  14076. //酒店电话
  14077. if (doc.Range.Bookmarks["Tel"] != null)
  14078. {
  14079. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14080. mark.Text = hr.HotelTel;
  14081. }
  14082. //酒店传真
  14083. if (doc.Range.Bookmarks["Fax"] != null)
  14084. {
  14085. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14086. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14087. {
  14088. mark.Text = hr.HotelFax;
  14089. }
  14090. }
  14091. //入住时间
  14092. if (doc.Range.Bookmarks["CIn"] != null)
  14093. {
  14094. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14095. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14096. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14097. }
  14098. //退房时间
  14099. if (doc.Range.Bookmarks["COut"] != null)
  14100. {
  14101. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14102. Bookmark mark = doc.Range.Bookmarks["COut"];
  14103. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14104. }
  14105. //客户名称
  14106. if (doc.Range.Bookmarks["GName"] != null)
  14107. {
  14108. string guestName = "";
  14109. string[] clients = new string[] { };
  14110. if (hr.GuestName.Contains(","))
  14111. {
  14112. clients = hr.GuestName.Split(",");
  14113. }
  14114. else
  14115. {
  14116. clients = new string[] { hr.GuestName };
  14117. }
  14118. List<int> clientIds_int = new List<int>();
  14119. if (clients.Length > 0)
  14120. {
  14121. foreach (var item in clients)
  14122. {
  14123. if (item.IsNumeric())
  14124. {
  14125. clientIds_int.Add(int.Parse(item));
  14126. }
  14127. }
  14128. }
  14129. if (clientIds_int.Count > 0)
  14130. {
  14131. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14132. foreach (var client in _clientDatas)
  14133. {
  14134. //男
  14135. if (client.Sex == 0) guestName += $"Mr.";
  14136. //女
  14137. else if (client.Sex == 1) guestName += $"Ms.";
  14138. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14139. {
  14140. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14141. }
  14142. //guestName += $"{client.Pinyin},";
  14143. }
  14144. if (guestName.Length > 0)
  14145. {
  14146. guestName = guestName.Substring(0, guestName.Length - 1);
  14147. }
  14148. }
  14149. else
  14150. {
  14151. guestName = hr.GuestName;
  14152. }
  14153. Bookmark mark = doc.Range.Bookmarks["GName"];
  14154. mark.Text = guestName;
  14155. }
  14156. //房间介绍
  14157. if (doc.Range.Bookmarks["ROOM"] != null)
  14158. {
  14159. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14160. mark.Text = hr.RoomExplanation;
  14161. }
  14162. //报价描述
  14163. if (doc.Range.Bookmarks["NOTE"] != null)
  14164. {
  14165. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14166. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14167. if (ss != null)
  14168. mark.Text = ss.Name;
  14169. }
  14170. //入住时间
  14171. if (doc.Range.Bookmarks["CheckIn"] != null)
  14172. {
  14173. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14174. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14175. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14176. }
  14177. //退房时间
  14178. if (doc.Range.Bookmarks["CheckOut"] != null)
  14179. {
  14180. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14181. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14182. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14183. }
  14184. //日期
  14185. if (doc.Range.Bookmarks["DT"] != null)
  14186. {
  14187. Bookmark mark = doc.Range.Bookmarks["DT"];
  14188. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14189. }
  14190. //名称
  14191. if (doc.Range.Bookmarks["VName"] != null)
  14192. {
  14193. Bookmark mark = doc.Range.Bookmarks["VName"];
  14194. mark.Text = hr.HotelName;
  14195. }
  14196. //号码
  14197. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14198. {
  14199. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14200. mark.Text = hr.CheckNumber;
  14201. }
  14202. #endregion
  14203. strFileName += "VOUCHER.doc";
  14204. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14205. doc.Save(fileDir);
  14206. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14207. return Ok(JsonView(true, "操作成功!", Url));
  14208. }
  14209. else
  14210. {
  14211. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14212. }
  14213. }
  14214. else
  14215. {
  14216. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14217. }
  14218. }
  14219. catch (Exception ex)
  14220. {
  14221. return Ok(JsonView(false, ex.Message));
  14222. }
  14223. }
  14224. /// <summary>
  14225. /// 酒店预订
  14226. /// 生成VOUCHER
  14227. /// 2024.05.06 之后版本
  14228. /// </summary>
  14229. /// <param name="_dto"></param>
  14230. /// <returns></returns>
  14231. [HttpPost]
  14232. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14233. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14234. {
  14235. #region 参数验证
  14236. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14237. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14238. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14239. #region 团组操作权限验证 76 酒店预定模块
  14240. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14241. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14242. #endregion
  14243. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14244. #region 页面操作权限验证
  14245. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14246. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14247. #endregion
  14248. #endregion
  14249. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14250. //判断数据是否完整
  14251. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14252. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14253. string strFileName = "HotelStatement/";
  14254. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14255. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14256. #region 数据处理
  14257. List<int> guestIds = new List<int>();
  14258. int index = 0;
  14259. foreach (var item in hrDtas)
  14260. {
  14261. if (item.GuestName.Contains(","))
  14262. {
  14263. string[] guestIdArr = item.GuestName.Split(',');
  14264. foreach (var guestIdStr in guestIdArr)
  14265. {
  14266. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14267. if (guestBool)
  14268. {
  14269. guestIds.Add(guestId);
  14270. }
  14271. }
  14272. }
  14273. else guestNames += item.GuestName;
  14274. var voucherInfo = new HotelVoucherInfoView()
  14275. {
  14276. HotelName = item.HotelName,
  14277. CheckInDate = item.CheckInDate,
  14278. CheckOutDate = item.CheckOutDate,
  14279. ConfirmationNumber = item.DetermineNo.Trim(),
  14280. RoomType = item.RoomExplanation
  14281. };
  14282. vouchers.Add(voucherInfo);
  14283. }
  14284. if (guestIds.Count > 0)
  14285. {
  14286. guestIds = guestIds.Distinct().ToList();
  14287. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14288. if (guestDatas.Count > 0)
  14289. {
  14290. guestNames = "";
  14291. foreach (var guest in guestDatas)
  14292. {
  14293. string guestName = "";
  14294. if (guest.Sex == 0) guestName += @"MR.";
  14295. else if (guest.Sex == 1) guestName += @"MS.";
  14296. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14297. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14298. guestNames += @$"{guestName.Trim()}、";
  14299. }
  14300. if (guestNames.Length > 0)
  14301. {
  14302. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14303. }
  14304. }
  14305. }
  14306. #endregion
  14307. //载入模板
  14308. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14309. Document doc = new Document(sss);
  14310. DocumentBuilder builder = new DocumentBuilder(doc);
  14311. if (doc.Range.Bookmarks["GuestName"] != null)
  14312. {
  14313. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14314. mark.Text = guestNames;
  14315. }
  14316. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14317. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14318. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14319. for (int i = 1; i <= vouchers.Count; i++)
  14320. {
  14321. HotelVoucherInfoView hviv = vouchers[i - 1];
  14322. builder.MoveToCell(0, i, 0, 0);
  14323. builder.Write(hviv.HotelName);
  14324. builder.MoveToCell(0, i, 1, 0);
  14325. builder.Write(hviv.CheckInDate);
  14326. builder.MoveToCell(0, i, 2, 0);
  14327. builder.Write(hviv.CheckOutDate);
  14328. builder.MoveToCell(0, i, 3, 0);
  14329. builder.Write(hviv.RoomType);
  14330. builder.MoveToCell(0, i, 4, 0);
  14331. builder.Write(hviv.ConfirmationNumber);
  14332. }
  14333. //删除多余行
  14334. int currRowIndex = vouchers.Count + 1;
  14335. int delRows = 21 - currRowIndex;
  14336. if (delRows > 0)
  14337. {
  14338. for (int i = 0; i < delRows; i++)
  14339. {
  14340. table.Rows.RemoveAt(currRowIndex);
  14341. //cultivateRowIndex++;
  14342. }
  14343. }
  14344. strFileName += "VOUCHER.docx";
  14345. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14346. doc.Save(fileDir);
  14347. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14348. return Ok(JsonView(true, "操作成功!", Url));
  14349. }
  14350. /// <summary>
  14351. /// 酒店预订
  14352. /// 生成VOUCHER 批量生成
  14353. /// New
  14354. /// </summary>
  14355. /// <param name="_dto"></param>
  14356. /// <returns></returns>
  14357. [HttpPost]
  14358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14359. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14360. {
  14361. #region 参数验证
  14362. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14363. if (_dto.PageId < 1) _dto.PageId = 28;
  14364. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14365. #region 团组操作权限验证 76 酒店预定模块
  14366. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14367. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14368. #endregion
  14369. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14370. #region 页面操作权限验证
  14371. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14372. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14373. #endregion
  14374. #endregion
  14375. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14376. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14377. .OrderBy(x => x.CheckInDate)
  14378. .ToListAsync();
  14379. //判断数据是否完整
  14380. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14381. string strFileName = "HotelStatement/";
  14382. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14383. if (dele != null)
  14384. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14385. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14386. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14387. .Where(it => it.IsDel == 0)
  14388. .ToListAsync();
  14389. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14390. for (int i = 0; i < hrDtas.Count; i++)
  14391. {
  14392. string guestNames = string.Empty;
  14393. List<int> guestIds = new List<int>();
  14394. var item = hrDtas[i];
  14395. //处理客户姓名
  14396. if (item.GuestName.Contains(","))
  14397. {
  14398. string[] guestIdArr = item.GuestName.Split(',');
  14399. foreach (var guestIdStr in guestIdArr)
  14400. if (int.TryParse(guestIdStr, out int guestId))
  14401. guestIds.Add(guestId);
  14402. }
  14403. else
  14404. {
  14405. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14406. if (guestIdBool)
  14407. {
  14408. guestIds.Add(guestId);
  14409. }
  14410. //NaN
  14411. if (item.GuestName.Contains("NaN"))
  14412. {
  14413. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14414. }
  14415. }
  14416. if (guestIds.Count > 0)
  14417. {
  14418. guestIds = guestIds.Distinct().ToList();
  14419. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14420. if (guestDatas1.Count > 0)
  14421. {
  14422. guestNames = "";
  14423. foreach (var guest in guestDatas1)
  14424. {
  14425. string guestName = "";
  14426. if (guest.Sex == 0) guestName += @"MR.";
  14427. else if (guest.Sex == 1) guestName += @"MS.";
  14428. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14429. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14430. guestNames += @$"{guestName.Trim()}、";
  14431. }
  14432. if (guestNames.Length > 0)
  14433. {
  14434. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14435. }
  14436. }
  14437. }
  14438. //if (!string.IsNullOrEmpty(guestNames))
  14439. //{
  14440. hrDtas[i].GuestName = guestNames;
  14441. //}
  14442. }
  14443. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14444. Document doc = new Document();
  14445. DocumentBuilder builder = new DocumentBuilder(doc);
  14446. try
  14447. {
  14448. builder.MoveToDocumentStart();
  14449. foreach (var item in hrDtas)
  14450. {
  14451. //标题
  14452. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14453. builder.ParagraphFormat.LineSpacing = 1;
  14454. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14455. builder.ParagraphFormat.Style.Font.Size = 9;
  14456. builder.ParagraphFormat.Style.Font.Bold = true;
  14457. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14458. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14459. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14460. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14461. builder.ParagraphFormat.LineSpacing = 1;
  14462. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14463. builder.ParagraphFormat.Style.Font.Size = 9;
  14464. builder.ParagraphFormat.Style.Font.Bold = true;
  14465. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14466. builder.StartTable();
  14467. // 设置边框颜色
  14468. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14469. //设置边框样式
  14470. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14471. //表格
  14472. #region 第一行
  14473. builder.InsertCell();
  14474. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14475. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14476. //builder.CellFormat.AllowAutoFit = false;
  14477. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14478. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14479. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14480. builder.CellFormat.WrapText = true; //自动换行
  14481. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14482. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14483. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14484. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14485. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14486. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14487. builder.Write("TOUR NO:");
  14488. builder.InsertCell();
  14489. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14490. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14492. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14493. builder.ParagraphFormat.Style.Font.Bold = false;
  14494. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14495. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14496. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14497. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14498. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14499. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14500. builder.Write($"{dele?.TourCode ?? "-"}");
  14501. builder.InsertCell();
  14502. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14503. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14504. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14505. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14506. builder.ParagraphFormat.Style.Font.Bold = false;
  14507. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14508. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14509. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14510. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14511. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14512. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14513. builder.Write($"CITY:");
  14514. builder.InsertCell();
  14515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14516. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14519. builder.ParagraphFormat.Style.Font.Bold = false;
  14520. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14521. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14522. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14523. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14524. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14525. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14526. builder.Write($"{item.City}");
  14527. builder.EndRow();
  14528. #endregion
  14529. #region 第二行
  14530. builder.InsertCell();
  14531. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14532. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14533. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14534. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14535. builder.ParagraphFormat.Style.Font.Bold = false;
  14536. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14537. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14538. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14539. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14540. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14541. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14542. builder.Write("CONFIRMATION NO:");
  14543. builder.InsertCell();
  14544. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14545. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14546. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14547. builder.ParagraphFormat.Style.Font.Bold = false;
  14548. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14549. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14550. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14551. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14552. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14553. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14554. builder.CellFormat.VerticalMerge = CellMerge.None;
  14555. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14556. builder.Write($"{item.DetermineNo}");
  14557. builder.InsertCell();
  14558. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14559. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14560. builder.InsertCell();
  14561. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14562. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14563. builder.EndRow();
  14564. #endregion
  14565. #region 第三行
  14566. builder.InsertCell();
  14567. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14568. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14569. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14570. builder.ParagraphFormat.Style.Font.Bold = false;
  14571. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14572. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14573. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  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($"HOTEL NAME:");
  14579. builder.InsertCell();
  14580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14581. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14582. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14583. builder.ParagraphFormat.Style.Font.Bold = false;
  14584. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14585. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14586. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14587. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14588. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14589. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14590. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14591. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14592. builder.Write($"{item.HotelName}");
  14593. builder.InsertCell();
  14594. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14595. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14596. builder.InsertCell();
  14597. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14598. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14599. builder.EndRow();
  14600. #endregion
  14601. #region 第四行
  14602. builder.InsertCell();
  14603. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14604. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14605. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14606. builder.ParagraphFormat.Style.Font.Bold = false;
  14607. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14608. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14609. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14610. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14611. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14612. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14613. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14614. builder.Write($"HOTEL ADDRESS:");
  14615. builder.InsertCell();
  14616. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14617. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14618. builder.ParagraphFormat.Style.Font.Size = 8;
  14619. builder.ParagraphFormat.Style.Font.Bold = false;
  14620. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14621. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14622. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14623. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14624. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14625. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14626. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14627. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14628. builder.Write($"{item.HotelAddress}");
  14629. builder.InsertCell();
  14630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14631. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14632. builder.InsertCell();
  14633. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14634. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14635. builder.EndRow();
  14636. #endregion
  14637. #region 第五行
  14638. builder.InsertCell();
  14639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14641. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14642. builder.ParagraphFormat.Style.Font.Bold = false;
  14643. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14650. builder.Write("TEL:");
  14651. builder.InsertCell();
  14652. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14653. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14654. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14655. builder.ParagraphFormat.Style.Font.Bold = false;
  14656. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14657. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14659. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14660. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14661. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14662. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14663. builder.Write($"{item.HotelTel}");
  14664. builder.InsertCell();
  14665. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14666. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14667. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14668. builder.ParagraphFormat.Style.Font.Bold = false;
  14669. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14670. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14671. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14672. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14673. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14674. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14675. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14676. builder.Write($"FAX:");
  14677. builder.InsertCell();
  14678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14679. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14680. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14681. builder.ParagraphFormat.Style.Font.Bold = false;
  14682. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14683. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14684. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14685. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14686. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14687. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14688. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14689. builder.Write($"{item.HotelFax}");
  14690. builder.EndRow();
  14691. #endregion
  14692. #region 第六行
  14693. builder.InsertCell();
  14694. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14695. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14696. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14697. builder.ParagraphFormat.Style.Font.Bold = false;
  14698. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14699. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14700. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14701. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14702. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14703. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14704. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14705. builder.Write("CHECK IN:");
  14706. builder.InsertCell();
  14707. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14708. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14709. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14710. builder.ParagraphFormat.Style.Font.Bold = false;
  14711. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14712. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14713. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14714. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14715. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14716. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14717. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14718. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14719. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14720. builder.Write($"{checkInStr}");
  14721. builder.InsertCell();
  14722. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14723. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14724. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14725. builder.ParagraphFormat.Style.Font.Bold = false;
  14726. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14727. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14728. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14729. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14730. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14731. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14732. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14733. builder.Write($"CHECK OUT:");
  14734. builder.InsertCell();
  14735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14737. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14738. builder.ParagraphFormat.Style.Font.Bold = false;
  14739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14746. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14747. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14748. builder.Write($"{checkOutStr}");
  14749. builder.EndRow();
  14750. #endregion
  14751. #region 第七行
  14752. builder.InsertCell();
  14753. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14754. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14755. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14756. builder.ParagraphFormat.Style.Font.Bold = false;
  14757. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14758. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14759. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14760. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14761. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14762. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14763. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14764. builder.Write($"GUEST NAME:");
  14765. builder.InsertCell();
  14766. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14767. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14768. builder.ParagraphFormat.Style.Font.Size = 8;
  14769. builder.ParagraphFormat.Style.Font.Bold = false;
  14770. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14771. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14772. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14773. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14774. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14775. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14776. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14777. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14778. builder.Write($"{item.GuestName}");
  14779. builder.InsertCell();
  14780. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14781. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14782. builder.InsertCell();
  14783. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14784. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14785. builder.EndRow();
  14786. #endregion
  14787. #region 第八行
  14788. builder.InsertCell();
  14789. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14790. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14791. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14792. builder.ParagraphFormat.Style.Font.Bold = false;
  14793. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14794. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14795. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14796. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14797. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14798. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14799. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14800. builder.Write($"ROOM TYPE:");
  14801. builder.InsertCell();
  14802. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14803. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14804. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14805. builder.ParagraphFormat.Style.Font.Bold = false;
  14806. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14807. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14808. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14809. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14810. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14811. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14812. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14813. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14814. builder.Write($"{item.RoomExplanation}");
  14815. builder.InsertCell();
  14816. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14817. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14818. builder.InsertCell();
  14819. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14820. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14821. builder.EndRow();
  14822. #endregion
  14823. #region 第九行
  14824. builder.InsertCell();
  14825. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14826. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14827. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14828. builder.ParagraphFormat.Style.Font.Bold = false;
  14829. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14830. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14831. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14832. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14833. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14834. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14835. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14836. builder.Write($"NOTE:");
  14837. builder.InsertCell();
  14838. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14839. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14840. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14841. builder.ParagraphFormat.Style.Font.Bold = false;
  14842. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14843. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14844. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14845. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14846. 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.");
  14847. builder.InsertCell();
  14848. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14849. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14850. builder.InsertCell();
  14851. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14852. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14853. builder.EndRow();
  14854. #endregion
  14855. builder.EndTable();
  14856. //换行
  14857. builder.Writeln("");
  14858. builder.Writeln("");
  14859. }
  14860. #region 获取文档中的所有表格 设置文字自适应
  14861. // 获取文档中的所有表格。
  14862. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14863. {
  14864. // 遍历表格中的所有行。
  14865. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14866. {
  14867. foreach (Cell cell in row.Cells)
  14868. {
  14869. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14870. cellFormat.Width = 0;
  14871. }
  14872. }
  14873. }
  14874. #endregion
  14875. #region 设置页眉
  14876. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14877. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14878. if (System.IO.File.Exists(voucherHeaderPath))
  14879. {
  14880. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14881. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14882. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14883. Shape shape = builder.InsertImage(imageBytes);
  14884. // 调整图片位置
  14885. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14886. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14887. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14888. shape.Left = 0; // 将图片距离页面左边缘的距离
  14889. shape.Width = 81; // 设置图片宽度
  14890. shape.Height = 36; // 设置图片高度
  14891. }
  14892. //靠右
  14893. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14894. //// 设置页脚上下边距
  14895. //builder.PageSetup.HeaderDistance = 42;
  14896. // 添加页眉线
  14897. Aspose.Words.Border borderHeader = null;
  14898. try
  14899. {
  14900. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14901. }
  14902. catch (Exception e)
  14903. {
  14904. // TODO Auto-generated catch block
  14905. //e.printStackTrace();
  14906. }
  14907. borderHeader.Shadow = true;
  14908. borderHeader.DistanceFromText = 2;
  14909. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14910. #endregion
  14911. }
  14912. catch (Exception ex)
  14913. {
  14914. }
  14915. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14916. doc.Save(fileDir);
  14917. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14918. return Ok(JsonView(true, "操作成功!", Url));
  14919. }
  14920. /// <summary>
  14921. /// 酒店预订
  14922. /// 生成 预定成本 Excel
  14923. /// </summary>
  14924. /// <param name="_dto"></param>
  14925. /// <returns></returns>
  14926. [HttpPost]
  14927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14928. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  14929. {
  14930. #region 参数验证
  14931. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  14932. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  14933. if (!vadalitorRes.IsValid)
  14934. {
  14935. var errors = new StringBuilder();
  14936. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  14937. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  14938. }
  14939. #region 团组操作权限验证 76 酒店预定模块
  14940. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14941. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14942. #endregion
  14943. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14944. #region 页面操作权限验证
  14945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14946. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14947. #endregion
  14948. #endregion
  14949. decimal _rate = 1.00M;
  14950. string _currency = string.Empty;
  14951. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  14952. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14953. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  14954. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14955. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  14956. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  14957. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  14958. if (_GroupCostParameter == null)
  14959. {
  14960. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  14961. bool isIntType = int.TryParse(_currency, out int currId);
  14962. if (isIntType)
  14963. {
  14964. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  14965. }
  14966. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  14967. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  14968. if (currInfo == null)
  14969. {
  14970. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  14971. }
  14972. else _rate = currInfo.Rate;
  14973. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  14974. {
  14975. _rate = _GroupCostParameter.Rate;
  14976. }
  14977. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14978. string strFileName = "HotelStatement/";
  14979. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14980. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  14981. var rateDatas = new List<dynamic>();
  14982. #region 数据处理
  14983. foreach (var item in hrDtas)
  14984. {
  14985. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  14986. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  14987. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  14988. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  14989. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  14990. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  14991. {
  14992. continue;
  14993. }
  14994. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  14995. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  14996. string singleRoomFeeStr = string.Empty,
  14997. doubleRoomFeeStr = string.Empty,
  14998. suiteRoomFeeStr = string.Empty,
  14999. otherRoomFeeStr = string.Empty,
  15000. payMoneyStr = string.Empty,
  15001. cardPriceStr = string.Empty;
  15002. if (roomCurr.Equals("CNY"))
  15003. {
  15004. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  15005. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15006. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15007. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15008. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15009. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  15010. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  15011. }
  15012. else
  15013. {
  15014. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15015. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15016. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15017. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15018. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15019. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15020. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15021. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15022. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15023. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  15024. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  15025. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  15026. if (ccpPaymentCurrency.Equals("CNY"))
  15027. {
  15028. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  15029. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15030. }
  15031. else
  15032. {
  15033. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  15034. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  15035. }
  15036. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  15037. if (hotelcardPriceCurrency.Equals("CNY"))
  15038. {
  15039. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  15040. }
  15041. else
  15042. {
  15043. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  15044. }
  15045. }
  15046. string breakfastPriceStr = string.Empty,
  15047. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15048. governmentRentStr = string.Empty,
  15049. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15050. cityTaxStr = string.Empty,
  15051. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15052. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  15053. if (!string.IsNullOrEmpty(breakfastCurrency1))
  15054. {
  15055. if (breakfastCurrency1.Equals("CNY"))
  15056. {
  15057. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15058. }
  15059. else
  15060. {
  15061. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  15062. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  15063. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15064. }
  15065. }
  15066. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15067. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15068. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15069. {
  15070. if (governmentRentCurrency.Equals("CNY"))
  15071. {
  15072. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15073. }
  15074. else
  15075. {
  15076. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15077. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15078. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15079. }
  15080. }
  15081. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15082. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15083. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15084. {
  15085. if (cityTaxStrCurrency1.Equals("CNY"))
  15086. {
  15087. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15088. }
  15089. else
  15090. {
  15091. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15092. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15093. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15094. }
  15095. }
  15096. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15097. int payDId = roomInfo?.PayDId ?? 0;
  15098. pcfds.Add(new HotelReservations_PCFD_View()
  15099. {
  15100. City = item.City,
  15101. HotelName = item.HotelName,
  15102. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15103. // SingleRoomCount = item.SingleRoomCount,
  15104. SingleRoomPrice = singleRoomFeeStr,
  15105. // DoubleRoomCount = item.DoubleRoomCount,
  15106. DoubleRoomPrice = doubleRoomFeeStr,
  15107. //SuiteRoomCount = item.SuiteRoomCount,
  15108. SuiteRoomPrice = suiteRoomFeeStr,
  15109. OtherRoomPrice = otherRoomFeeStr,
  15110. //OtherRoomCount = item.OtherRoomCount,
  15111. BreakfastPrice = breakfastPriceStr,
  15112. GovernmentRent = governmentRentStr,
  15113. CityTax = cityTaxStr,
  15114. RoomExplanation = item.RoomExplanation,
  15115. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15116. PayTime = roomInfo?.ConsumptionDate,
  15117. BankNo = roomInfo?.BankNo,
  15118. PayMoney = payMoneyStr,
  15119. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15120. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15121. CardPrice = cardPriceStr,
  15122. Remark = ccpInfo.Remark
  15123. });
  15124. }
  15125. #endregion
  15126. //载入模板
  15127. WorkbookDesigner designer = new WorkbookDesigner();
  15128. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15129. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15130. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15131. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15132. var rateDatas1 = rateDatas.Distinct();
  15133. var rateStr = string.Empty;
  15134. foreach (var item in rateDatas1)
  15135. {
  15136. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15137. }
  15138. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15139. designer.SetDataSource("Opertor", userInfo.CnName);
  15140. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15141. dt.TableName = "ViewMyHotelReservations";
  15142. designer.SetDataSource(dt);
  15143. designer.Process();
  15144. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15145. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15146. designer.Workbook.Save(serverPath);
  15147. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15148. #region 删除指定行
  15149. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15150. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15151. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15152. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15153. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15154. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15155. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15156. cssIndex = dt.Columns["CityTax"].Ordinal,
  15157. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15158. remarkIndex = dt.Columns["Remark"].Ordinal;
  15159. //删除指定列
  15160. foreach (DataRow item in dt.Rows)
  15161. {
  15162. string singleStr = item["SingleRoomPrice"].ToString();
  15163. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15164. if (containsDigitButNotZero1) singleDel = false;
  15165. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15166. string doubleStr = item["DoubleRoomPrice"].ToString();
  15167. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15168. if (containsDigitButNotZero2) doubleDel = false;
  15169. string suiteStr = item["SuiteRoomPrice"].ToString();
  15170. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15171. if (containsDigitButNotZero3) suiteDel = false;
  15172. string otherStr = item["OtherRoomPrice"].ToString();
  15173. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15174. if (containsDigitButNotZero4) otherDel = false;
  15175. string zcStr = item["BreakfastPrice"].ToString();
  15176. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15177. if (containsDigitButNotZero5) zcDel = false;
  15178. string dsStr = item["GovernmentRent"].ToString();
  15179. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15180. if (containsDigitButNotZero6) dsDel = false;
  15181. string cssStr = item["CityTax"].ToString();
  15182. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15183. if (containsDigitButNotZero7) cssDel = false;
  15184. string cpStr = item["ConsumptionPatterns"].ToString();
  15185. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15186. string remarkStr = item["Remark"].ToString();
  15187. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15188. }
  15189. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15190. DeleteColumn(serverPath, cpIndex, cpDel);
  15191. DeleteColumn(serverPath, dsIndex, dsDel);
  15192. DeleteColumn(serverPath, cssIndex, cssDel);
  15193. DeleteColumn(serverPath, zcIndex, zcDel);
  15194. DeleteColumn(serverPath, otherIndex, otherDel);
  15195. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15196. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15197. DeleteColumn(serverPath, singleIndex, singleDel);
  15198. #endregion
  15199. //只保留第一个表格
  15200. DeleteSheet(serverPath);
  15201. return Ok(JsonView(true, "操作成功", url = rst));
  15202. }
  15203. else
  15204. {
  15205. _currency = _GroupCostParameter.Currency;
  15206. bool isIntType = int.TryParse(_currency, out int currId);
  15207. if (isIntType)
  15208. {
  15209. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15210. }
  15211. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15212. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15213. if (currInfo == null)
  15214. {
  15215. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15216. }
  15217. if (!_currency.ToUpper().Equals("CNY"))
  15218. {
  15219. _rate = _GroupCostParameter.Rate;
  15220. }
  15221. _rate = currInfo.Rate;
  15222. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15223. //string strFileName = "HotelStatement/";
  15224. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  15225. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15226. #region 数据处理
  15227. foreach (var item in hrDtas)
  15228. {
  15229. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15230. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15231. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15232. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15233. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15234. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15235. string singleRoomFeeStr = string.Empty,
  15236. doubleRoomFeeStr = string.Empty,
  15237. suiteRoomFeeStr = string.Empty,
  15238. otherRoomFeeStr = string.Empty,
  15239. payMoneyStr = string.Empty,
  15240. cardPriceStr = string.Empty;
  15241. if (roomCurr.Equals(_currency))
  15242. {
  15243. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15244. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15245. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15246. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15247. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15248. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15249. }
  15250. else
  15251. {
  15252. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15253. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15254. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15255. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15256. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15257. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15258. }
  15259. string breakfastPriceStr = string.Empty,
  15260. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15261. governmentRentStr = string.Empty,
  15262. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15263. cityTaxStrStr = string.Empty,
  15264. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15265. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15266. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15267. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15268. int payDId = roomInfo?.PayDId ?? 0;
  15269. pcfds.Add(new HotelReservations_PCFD_View()
  15270. {
  15271. City = item.City,
  15272. HotelName = item.HotelName,
  15273. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15274. // SingleRoomCount = item.SingleRoomCount,
  15275. SingleRoomPrice = singleRoomFeeStr,
  15276. // DoubleRoomCount = item.DoubleRoomCount,
  15277. DoubleRoomPrice = doubleRoomFeeStr,
  15278. //SuiteRoomCount = item.SuiteRoomCount,
  15279. SuiteRoomPrice = suiteRoomFeeStr,
  15280. OtherRoomPrice = otherRoomFeeStr,
  15281. //OtherRoomCount = item.OtherRoomCount,
  15282. BreakfastPrice = breakfastPriceStr,
  15283. GovernmentRent = governmentRentStr,
  15284. CityTax = cityTaxStrStr,
  15285. RoomExplanation = item.RoomExplanation,
  15286. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15287. PayTime = roomInfo?.ConsumptionDate,
  15288. BankNo = roomInfo?.BankNo,
  15289. PayMoney = payMoneyStr,
  15290. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15291. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15292. CardPrice = cardPriceStr,
  15293. Remark = ccpInfo.Remark
  15294. });
  15295. }
  15296. #endregion
  15297. //载入模板
  15298. WorkbookDesigner designer = new WorkbookDesigner();
  15299. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15300. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15301. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15302. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15303. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15304. designer.SetDataSource("Opertor", userInfo.CnName);
  15305. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15306. dt.TableName = "ViewMyHotelReservations";
  15307. designer.SetDataSource(dt);
  15308. designer.Process();
  15309. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15310. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15311. designer.Workbook.Save(serverPath);
  15312. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15313. #region 删除指定行
  15314. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15315. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15316. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15317. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15318. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15319. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15320. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15321. cssIndex = dt.Columns["CityTax"].Ordinal,
  15322. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15323. remarkIndex = dt.Columns["Remark"].Ordinal;
  15324. //删除指定列
  15325. foreach (DataRow item in dt.Rows)
  15326. {
  15327. string singleStr = item["SingleRoomPrice"].ToString();
  15328. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15329. if (containsDigitButNotZero1) singleDel = false;
  15330. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15331. string doubleStr = item["DoubleRoomPrice"].ToString();
  15332. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15333. if (containsDigitButNotZero2) doubleDel = false;
  15334. string suiteStr = item["SuiteRoomPrice"].ToString();
  15335. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15336. if (containsDigitButNotZero3) suiteDel = false;
  15337. string otherStr = item["OtherRoomPrice"].ToString();
  15338. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15339. if (containsDigitButNotZero4) otherDel = false;
  15340. string zcStr = item["BreakfastPrice"].ToString();
  15341. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15342. if (containsDigitButNotZero5) zcDel = false;
  15343. string dsStr = item["GovernmentRent"].ToString();
  15344. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15345. if (containsDigitButNotZero6) dsDel = false;
  15346. string cssStr = item["CityTax"].ToString();
  15347. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15348. if (containsDigitButNotZero7) cssDel = false;
  15349. string cpStr = item["ConsumptionPatterns"].ToString();
  15350. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15351. string remarkStr = item["Remark"].ToString();
  15352. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15353. }
  15354. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15355. DeleteColumn(serverPath, cpIndex, cpDel);
  15356. DeleteColumn(serverPath, dsIndex, dsDel);
  15357. DeleteColumn(serverPath, cssIndex, cssDel);
  15358. DeleteColumn(serverPath, zcIndex, zcDel);
  15359. DeleteColumn(serverPath, otherIndex, otherDel);
  15360. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15361. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15362. DeleteColumn(serverPath, singleIndex, singleDel);
  15363. #endregion
  15364. //只保留第一个表格
  15365. DeleteSheet(serverPath);
  15366. return Ok(JsonView(true, "操作成功", url = rst));
  15367. }
  15368. return Ok(JsonView(false));
  15369. }
  15370. /// <summary>
  15371. /// 删除指定列
  15372. /// </summary>
  15373. /// <param name="file"></param>
  15374. /// <param name="columnIndex"></param>
  15375. /// <param name="isDel"></param>
  15376. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15377. {
  15378. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15379. //wb.Save(file);
  15380. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15381. if (sheet1 != null)
  15382. {
  15383. if (isDel)
  15384. {
  15385. Cells cells = sheet1.Cells;
  15386. cells.DeleteColumn(columnIndex);
  15387. }
  15388. }
  15389. wb.Save(file);
  15390. }
  15391. /// <summary>
  15392. /// 删除sheet
  15393. /// </summary>
  15394. /// <param name="file"></param>
  15395. /// <param name="sheetName"></param>
  15396. private void DeleteSheet(string file, string sheetName = "")
  15397. {
  15398. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15399. //wb.Save(file);
  15400. List<string> sheets = new List<string>();
  15401. foreach (var item in wb.Worksheets)
  15402. {
  15403. sheets.Add(item.Name);
  15404. }
  15405. if (sheets.Count > 0)
  15406. {
  15407. sheets.RemoveAt(0);//不删除第一个sheet
  15408. foreach (var item in sheets)
  15409. {
  15410. wb.Worksheets.RemoveAt(item);
  15411. }
  15412. }
  15413. wb.Save(file);
  15414. }
  15415. /// <summary>
  15416. /// 酒店预订
  15417. /// 确认单
  15418. /// </summary>
  15419. /// <param name="_dto"></param>
  15420. /// <returns></returns>
  15421. [HttpPost]
  15422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15423. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15424. {
  15425. try
  15426. {
  15427. #region 参数验证
  15428. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15429. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15430. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15431. #region 团组操作权限验证 76 酒店预定模块
  15432. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15433. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15434. #endregion
  15435. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15436. #region 页面操作权限验证
  15437. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15438. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15439. #endregion
  15440. #endregion
  15441. //团组信息
  15442. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15443. //酒店数据
  15444. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15445. if (listhoteldata.Count < 0)
  15446. {
  15447. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15448. }
  15449. //利datatable存储
  15450. DataTable dt = new DataTable();
  15451. dt.Columns.Add("CheckInDate", typeof(string));
  15452. dt.Columns.Add("City", typeof(string));
  15453. dt.Columns.Add("Hotel", typeof(string));
  15454. dt.Columns.Add("Room", typeof(string));
  15455. for (int i = 0; i < listhoteldata.Count; i++)
  15456. {
  15457. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15458. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15459. while (dayStart < dayEnd)
  15460. {
  15461. string temp = "";
  15462. DataRow row = dt.NewRow();
  15463. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15464. row["City"] = listhoteldata[i].City;
  15465. row["Hotel"] = listhoteldata[i].HotelName;
  15466. if (listhoteldata[i].SingleRoomCount > 0)
  15467. {
  15468. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15469. }
  15470. if (listhoteldata[i].DoubleRoomCount > 0)
  15471. {
  15472. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15473. }
  15474. if (listhoteldata[i].SuiteRoomCount > 0)
  15475. {
  15476. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15477. }
  15478. if (listhoteldata[i].OtherRoomCount > 0)
  15479. {
  15480. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15481. }
  15482. row["Room"] = temp;
  15483. dt.Rows.Add(row);
  15484. dayStart = dayStart.AddDays(1);
  15485. }
  15486. }
  15487. Dictionary<string, string> dic = new Dictionary<string, string>();
  15488. dic.Add("Dele", di.TeamName);
  15489. dic.Add("City", di.VisitCountry);
  15490. //模板路径
  15491. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15492. //载入模板
  15493. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15494. DocumentBuilder builder = new DocumentBuilder(doc);
  15495. foreach (var key in dic.Keys)
  15496. {
  15497. builder.MoveToBookmark(key);
  15498. builder.Write(dic[key]);
  15499. }
  15500. //获取word里所有表格
  15501. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15502. //获取所填表格的序数
  15503. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15504. var rowStart = tableOne.Rows[0]; //获取第1行
  15505. //循环赋值
  15506. for (int i = 0; i < dt.Rows.Count; i++)
  15507. {
  15508. builder.MoveToCell(0, i + 1, 0, 0);
  15509. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15510. builder.MoveToCell(0, i + 1, 1, 0);
  15511. builder.Write(dt.Rows[i]["City"].ToString());
  15512. builder.MoveToCell(0, i + 1, 2, 0);
  15513. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15514. builder.MoveToCell(0, i + 1, 3, 0);
  15515. builder.Write(dt.Rows[i]["Room"].ToString());
  15516. }
  15517. //删除多余行
  15518. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15519. {
  15520. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15521. }
  15522. string strFileName = di.TeamName + "酒店确认单.doc";
  15523. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15524. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15525. return Ok(JsonView(true, "成功", url));
  15526. }
  15527. catch (Exception ex)
  15528. {
  15529. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15530. }
  15531. }
  15532. #endregion
  15533. #region 团组状态
  15534. /// <summary>
  15535. /// 团组状态列表 Page
  15536. /// </summary>
  15537. /// <param name="dto">团组列表请求dto</param>
  15538. /// <returns></returns>
  15539. [HttpPost]
  15540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15541. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15542. {
  15543. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15544. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15545. {
  15546. string sqlWhere = string.Empty;
  15547. if (dto.IsSure == 0) //未完成
  15548. {
  15549. sqlWhere += string.Format(@" And IsSure = 0");
  15550. }
  15551. else if (dto.IsSure == 1) //已完成
  15552. {
  15553. sqlWhere += string.Format(@" And IsSure = 1");
  15554. }
  15555. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15556. {
  15557. string tj = dto.SearchCriteria;
  15558. 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}%')",
  15559. tj, tj, tj, tj, tj);
  15560. }
  15561. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15562. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15563. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15564. From (
  15565. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15566. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15567. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15568. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15569. From Grp_DelegationInfo gdi
  15570. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15571. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15572. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15573. Where gdi.IsDel = 0 {0}
  15574. ) temp ", sqlWhere);
  15575. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15576. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15577. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15578. }
  15579. else
  15580. {
  15581. return Ok(JsonView(false, "查询失败"));
  15582. }
  15583. }
  15584. /// <summary>
  15585. /// 团组状态
  15586. /// 设置操作完成
  15587. /// </summary>
  15588. /// <param name="dto">团组列表请求dto</param>
  15589. /// <returns></returns>
  15590. [HttpPost]
  15591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15592. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15593. {
  15594. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15595. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15596. {
  15597. Id = dto.Id,
  15598. IsSure = 1
  15599. };
  15600. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15601. .UpdateColumns(it => new { it.IsSure })
  15602. .WhereColumns(it => new { it.Id })
  15603. .ExecuteCommandAsync();
  15604. if (result > 0)
  15605. {
  15606. return Ok(JsonView(true, "操作完成!"));
  15607. }
  15608. return Ok(JsonView(false, "操作失败!"));
  15609. }
  15610. #endregion
  15611. #region 保险费用录入
  15612. /// <summary>
  15613. /// 根据团组Id查询保险费用列表
  15614. /// </summary>
  15615. /// <param name="dto"></param>
  15616. /// <returns></returns>
  15617. [HttpPost]
  15618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15619. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15620. {
  15621. Result groupData = await _customersRep.CustomersByDiId(dto);
  15622. if (groupData.Code != 0)
  15623. {
  15624. return Ok(JsonView(false, groupData.Msg));
  15625. }
  15626. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15627. }
  15628. /// <summary>
  15629. /// 根据保险费用Id查询保险费用详细
  15630. /// </summary>
  15631. /// <param name="dto"></param>
  15632. /// <returns></returns>
  15633. [HttpPost]
  15634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15635. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15636. {
  15637. try
  15638. {
  15639. Result groupData = await _customersRep.CustomersById(dto);
  15640. if (groupData.Code != 0)
  15641. {
  15642. return Ok(JsonView(false, groupData.Msg));
  15643. }
  15644. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15645. }
  15646. catch (Exception ex)
  15647. {
  15648. return Ok(JsonView(false, ex.Message));
  15649. }
  15650. }
  15651. /// <summary>
  15652. /// 保险费用录入页面初始化绑定
  15653. /// </summary>
  15654. /// <param name="dto"></param>
  15655. /// <returns></returns>
  15656. [HttpPost]
  15657. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15658. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15659. {
  15660. try
  15661. {
  15662. Result groupData = await _customersRep.CustomersInitialize(dto);
  15663. if (groupData.Code != 0)
  15664. {
  15665. return Ok(JsonView(false, groupData.Msg));
  15666. }
  15667. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15668. }
  15669. catch (Exception ex)
  15670. {
  15671. return Ok(JsonView(false, ex.Message));
  15672. }
  15673. }
  15674. /// <summary>
  15675. /// 保险费用操作(Status:1.新增,2.修改)
  15676. /// </summary>
  15677. /// <param name="dto"></param>
  15678. /// <returns></returns>
  15679. [HttpPost]
  15680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15681. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15682. {
  15683. Result groupData = await _customersRep.OpCustomers(dto);
  15684. if (groupData.Code != 0)
  15685. {
  15686. return Ok(JsonView(false, groupData.Msg));
  15687. }
  15688. #region 应用推送
  15689. try
  15690. {
  15691. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15692. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15693. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15694. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15695. //自动审核
  15696. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15697. //2024-10-21 新增LZ UID
  15698. var userIds = new List<int>() { 21 };
  15699. string title = $"系统通知";
  15700. var diId = dto.DiId;
  15701. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15702. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15703. string content = "";
  15704. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15705. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15706. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15707. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15708. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15709. }
  15710. catch (Exception ex)
  15711. {
  15712. }
  15713. #endregion
  15714. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15715. }
  15716. /// <summary>
  15717. /// 保险文件上传
  15718. /// </summary>
  15719. /// <param name="file"></param>
  15720. /// <returns></returns>
  15721. [HttpPost]
  15722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15723. public async Task<IActionResult> UploadCus(IFormFile file)
  15724. {
  15725. try
  15726. {
  15727. if (file != null)
  15728. {
  15729. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15730. //文件名称
  15731. string projectFileName = file.FileName;
  15732. //上传的文件的路径
  15733. string filePath = "";
  15734. if (!Directory.Exists(fileDir))
  15735. {
  15736. Directory.CreateDirectory(fileDir);
  15737. }
  15738. //上传的文件的路径
  15739. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15740. using (FileStream fs = System.IO.File.Create(filePath))
  15741. {
  15742. file.CopyTo(fs);
  15743. fs.Flush();
  15744. }
  15745. return Ok(JsonView(true, "上传成功!", projectFileName));
  15746. }
  15747. else
  15748. {
  15749. return Ok(JsonView(false, "上传失败!"));
  15750. }
  15751. }
  15752. catch (Exception ex)
  15753. {
  15754. return Ok(JsonView(false, "程序错误!"));
  15755. throw;
  15756. }
  15757. }
  15758. /// <summary>
  15759. /// 保险删除指定文件
  15760. /// </summary>
  15761. /// <param name="dto"></param>
  15762. /// <returns></returns>
  15763. [HttpPost]
  15764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15765. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15766. {
  15767. try
  15768. {
  15769. string filePath = "";
  15770. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15771. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15772. //int id = 0;
  15773. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15774. // 删除该文件
  15775. try
  15776. {
  15777. System.IO.File.Delete(filePath);
  15778. 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()
  15779. {
  15780. Attachment = "",
  15781. }).ExecuteCommandAsync();
  15782. if (result != 0)
  15783. {
  15784. return Ok(JsonView(true, "成功!"));
  15785. }
  15786. else
  15787. {
  15788. return Ok(JsonView(false, "失败!"));
  15789. }
  15790. }
  15791. catch (Exception)
  15792. {
  15793. 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()
  15794. {
  15795. Attachment = "",
  15796. }).ExecuteCommandAsync();
  15797. if (result != 0)
  15798. {
  15799. return Ok(JsonView(true, "成功!"));
  15800. }
  15801. else
  15802. {
  15803. return Ok(JsonView(false, "失败!"));
  15804. }
  15805. }
  15806. }
  15807. catch (Exception ex)
  15808. {
  15809. return Ok(JsonView(false, "程序错误!"));
  15810. throw;
  15811. }
  15812. }
  15813. /// <summary>
  15814. /// 保险费用操作(删除)
  15815. /// </summary>
  15816. /// <param name="dto"></param>
  15817. /// <returns></returns>
  15818. [HttpPost]
  15819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15820. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15821. {
  15822. try
  15823. {
  15824. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15825. if (!res)
  15826. {
  15827. return Ok(JsonView(false, "删除失败"));
  15828. }
  15829. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15830. {
  15831. IsDel = 1,
  15832. DeleteUserId = dto.DeleteUserId,
  15833. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15834. }).ExecuteCommandAsync();
  15835. return Ok(JsonView(true, "删除成功!"));
  15836. }
  15837. catch (Exception ex)
  15838. {
  15839. return Ok(JsonView(false, "程序错误!"));
  15840. throw;
  15841. }
  15842. }
  15843. #endregion
  15844. #region 接团客户名单 PageId 104
  15845. /// <summary>
  15846. /// 接团客户名单
  15847. /// 迁移数据(慎用!)
  15848. /// </summary>
  15849. /// <param name="dto"></param>
  15850. /// <returns></returns>
  15851. [HttpPost]
  15852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15853. public async Task<IActionResult> PostTourClientListChange()
  15854. {
  15855. try
  15856. {
  15857. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15858. //var groupClinetData1
  15859. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15860. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15861. int updateCount = 0;
  15862. if (oldOAClientList.Count > 0)
  15863. {
  15864. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15865. _sqlSugar.BeginTran();
  15866. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15867. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15868. foreach (var item in oldOAClientList)
  15869. {
  15870. int comId = 0;
  15871. string format = "yyyy-MM-dd HH:mm:ss";
  15872. string data11 = "1990-01-01 00:00";
  15873. var data1 = IsValidDate(item.OPdate, format);
  15874. if (data1) data11 = item.OPdate;
  15875. //客户公司验证
  15876. if (!string.IsNullOrEmpty(item.Company))
  15877. {
  15878. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15879. if (clientComInfo == null) // add
  15880. {
  15881. var addInfo = new Crm_CustomerCompany()
  15882. {
  15883. CompanyAbbreviation = "",
  15884. CompanyFullName = item.Company,
  15885. Address = "",
  15886. PostCodes = "",
  15887. LastedOpUserId = item.OPer,
  15888. LastedOpDt = Convert.ToDateTime(data11),
  15889. CreateUserId = item.OPer,
  15890. CreateTime = Convert.ToDateTime(data11),
  15891. IsDel = 0
  15892. };
  15893. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15894. if (comId1 > 0) comId = comId1;
  15895. }
  15896. else comId = clientComInfo.Id;
  15897. }
  15898. //客户人员验证
  15899. int clientId = 0;
  15900. string name = item.LastName + item.Name;
  15901. if (!string.IsNullOrEmpty(name))
  15902. {
  15903. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15904. if (clientInfo == null)
  15905. {
  15906. DateTime? dateTime = null;
  15907. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15908. if (isDt) dateTime = birthDayDt;
  15909. var addInfo1 = new Crm_DeleClient()
  15910. {
  15911. CrmCompanyId = comId,
  15912. DiId = -1,
  15913. LastName = item.LastName,
  15914. FirstName = item.Name,
  15915. OldName = "",
  15916. Pinyin = item.Pinyin,
  15917. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15918. Marriage = 0,
  15919. Phone = item.Phone,
  15920. Job = item.Job,
  15921. BirthDay = dateTime
  15922. };
  15923. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  15924. if (clientId1 > 0) clientId = clientId1;
  15925. }
  15926. else clientId = clientInfo.Id;
  15927. }
  15928. if (clientId < 1)
  15929. {
  15930. continue;
  15931. }
  15932. int airType = 0;
  15933. if (item.AirType == "超经舱") airType = 459;
  15934. else if (item.AirType == "公务舱") airType = 458;
  15935. else if (item.AirType == "经济舱") airType = 460;
  15936. else if (item.AirType == "其他") airType = 565;
  15937. else if (item.AirType == "头等舱") airType = 457;
  15938. var _TourClientListEntity = new Grp_TourClientList()
  15939. {
  15940. DiId = item.Diid,
  15941. ClientId = clientId,
  15942. CreateUserId = item.OPer,
  15943. CreateTime = Convert.ToDateTime(data11),
  15944. Remark = item.Remark,
  15945. IsDel = item.Isdel,
  15946. ShippingSpaceTypeId = airType,
  15947. ShippingSpaceSpecialNeeds = item.AirRemark,
  15948. HotelSpecialNeeds = item.RoomType
  15949. };
  15950. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  15951. if (_TourClientList > 0)
  15952. {
  15953. updateCount++;
  15954. }
  15955. }
  15956. _sqlSugar.CommitTran();
  15957. }
  15958. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  15959. }
  15960. catch (Exception ex)
  15961. {
  15962. _sqlSugar.RollbackTran();
  15963. return Ok(JsonView(false, ex.Message));
  15964. }
  15965. return Ok(JsonView(true));
  15966. }
  15967. private bool IsValidDate(string dateString, string format)
  15968. {
  15969. DateTime dateValue;
  15970. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  15971. return valid;
  15972. }
  15973. /// <summary>
  15974. /// 接团客户名单
  15975. /// 根据团组Id查询List
  15976. /// </summary>
  15977. /// <param name="dto"></param>
  15978. /// <returns></returns>
  15979. [HttpPost]
  15980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15981. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  15982. {
  15983. #region 参数验证
  15984. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  15985. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  15986. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  15987. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15988. #region 页面操作权限验证
  15989. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15990. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15991. #endregion
  15992. #endregion
  15993. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  15994. if (viewData.Code != 0)
  15995. {
  15996. return Ok(JsonView(false, viewData.Msg));
  15997. }
  15998. return Ok(JsonView(viewData.Data));
  15999. }
  16000. /// <summary>
  16001. /// 接团客户名单
  16002. /// 基础数据 Init
  16003. /// </summary>
  16004. /// <param name="_dto"></param>
  16005. /// <returns></returns>
  16006. [HttpPost]
  16007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16008. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  16009. {
  16010. #region 参数验证
  16011. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16012. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16013. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16014. #region 页面操作权限验证
  16015. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16016. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16017. #endregion
  16018. #endregion
  16019. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  16020. }
  16021. /// <summary>
  16022. /// 接团客户名单
  16023. /// 根据 Id查询 Details
  16024. /// </summary>
  16025. /// <param name="_dto"></param>
  16026. /// <returns></returns>
  16027. [HttpPost]
  16028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16029. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  16030. {
  16031. #region 参数验证
  16032. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16033. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16034. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16035. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16036. #region 页面操作权限验证
  16037. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16038. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  16039. #endregion
  16040. #endregion
  16041. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  16042. if (viewData.Code != 0)
  16043. {
  16044. return Ok(JsonView(false, viewData.Msg));
  16045. }
  16046. return Ok(JsonView(viewData.Data));
  16047. }
  16048. /// <summary>
  16049. /// 接团客户名单
  16050. /// Add Or Edit
  16051. /// </summary>
  16052. /// <param name="_dto"></param>
  16053. /// <returns></returns>
  16054. [HttpPost]
  16055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16056. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  16057. {
  16058. #region 参数验证
  16059. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16060. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16061. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  16062. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16063. #region 页面操作权限验证
  16064. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16065. if (_dto.Id == 0) //添加
  16066. {
  16067. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16068. }
  16069. else if (_dto.Id >= 0) //修改
  16070. {
  16071. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16072. }
  16073. #endregion
  16074. #endregion
  16075. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16076. if (viewData.Code != 0)
  16077. {
  16078. return Ok(JsonView(false, viewData.Msg));
  16079. }
  16080. return Ok(JsonView(true));
  16081. }
  16082. /// <summary>
  16083. /// 接团客户名单
  16084. /// json字符串 AddMultiple(添加多个)
  16085. /// </summary>
  16086. /// <param name="_dto"></param>
  16087. /// <returns></returns>
  16088. [HttpPost]
  16089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16090. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16091. {
  16092. #region 参数验证
  16093. string jsonLabel = _dto.JsonLabel;
  16094. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16095. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16096. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16097. #region 页面操作权限验证
  16098. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16099. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16100. #endregion
  16101. #endregion
  16102. var request = new TourClientListAddMultipleDto();
  16103. request.DiId = _dto.DiId;
  16104. request.UserId = _dto.UserId;
  16105. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16106. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16107. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16108. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16109. var infos = new List<TourClientListInfo>();
  16110. foreach (var data in datas)
  16111. {
  16112. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16113. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16114. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16115. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16116. {
  16117. continue;
  16118. }
  16119. infos.Add(new TourClientListInfo() {
  16120. IsAccompany = 1,
  16121. LastName = lastName,
  16122. FirstName = firstName,
  16123. Pinyin = lastNameEn + @"/" + firstNameEn,
  16124. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  16125. CompanyFullName = data.CompanyFullName,
  16126. Job = data.Job
  16127. });
  16128. }
  16129. if (infos.Any())
  16130. {
  16131. var viewData = await _tourClientListRep._AddMultiple(request);
  16132. if (viewData.Code != 0)
  16133. {
  16134. return Ok(JsonView(false, viewData.Msg));
  16135. }
  16136. return Ok(JsonView(true));
  16137. }
  16138. return Ok(JsonView(false));
  16139. }
  16140. /// <summary>
  16141. /// 接团客户名单
  16142. /// AddMultiple(添加多个)
  16143. /// </summary>
  16144. /// <param name="_dto"></param>
  16145. /// <returns></returns>
  16146. [HttpPost]
  16147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16148. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16149. {
  16150. #region 参数验证
  16151. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16152. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16153. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16154. #region 页面操作权限验证
  16155. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16156. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16157. #endregion
  16158. #endregion
  16159. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16160. if (viewData.Code != 0)
  16161. {
  16162. return Ok(JsonView(false, viewData.Msg));
  16163. }
  16164. return Ok(JsonView(true));
  16165. }
  16166. /// <summary>
  16167. /// 接团客户名单
  16168. /// Del
  16169. /// </summary>
  16170. /// <param name="_dto"></param>
  16171. /// <returns></returns>
  16172. [HttpPost]
  16173. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16174. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16175. {
  16176. #region 参数验证
  16177. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16178. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16179. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16180. #region 页面操作权限验证
  16181. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16182. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16183. #endregion
  16184. #endregion
  16185. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16186. if (viewData.Code != 0)
  16187. {
  16188. return Ok(JsonView(false, viewData.Msg));
  16189. }
  16190. return Ok(JsonView(true));
  16191. }
  16192. /// <summary>
  16193. /// 接团客户名单
  16194. /// 文件下载 客户名单
  16195. /// </summary>
  16196. /// <param name="_dto"></param>
  16197. /// <returns></returns>
  16198. [HttpPost]
  16199. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16200. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16201. {
  16202. #region 参数验证
  16203. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16204. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16205. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16206. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16207. #region 页面操作权限验证
  16208. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16209. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16210. #endregion
  16211. #endregion
  16212. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16213. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16214. From Grp_TourClientList tcl
  16215. Left Join
  16216. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16217. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16218. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16219. From Crm_DeleClient dc
  16220. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16221. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16222. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16223. Where dc.IsDel = 0) temp
  16224. On temp.DcId =tcl.ClientId
  16225. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16226. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16227. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16228. //载入模板
  16229. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16230. if (_dto.Language == 1)
  16231. {
  16232. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16233. }
  16234. //载入模板
  16235. var doc = new Document(tempPath);
  16236. DocumentBuilder builder = new DocumentBuilder(doc);
  16237. //获取word里所有表格
  16238. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16239. //获取所填表格的序数
  16240. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16241. var rowStart = tableOne.Rows[0]; //获取第1行
  16242. if (_dto.Language == 0)
  16243. {
  16244. //循环赋值
  16245. for (int i = 0; i < DcList.Count; i++)
  16246. {
  16247. EncryptionProcessor.DecryptProperties(DcList[i]);
  16248. builder.MoveToCell(0, i + 1, 0, 0);
  16249. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16250. builder.MoveToCell(0, i + 1, 1, 0);
  16251. int sex = DcList[i].Sex;
  16252. string sexStr = string.Empty;
  16253. if (sex == 0) sexStr = "男";
  16254. else if (sex == 1) sexStr = "女";
  16255. else sexStr = "未设置";
  16256. builder.Write(sexStr);
  16257. builder.MoveToCell(0, i + 1, 2, 0);
  16258. string birthDay = DcList[i].BirthDay;
  16259. string birthDayStr = string.Empty;
  16260. if (!string.IsNullOrEmpty(birthDay))
  16261. {
  16262. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16263. }
  16264. builder.Write(birthDayStr);
  16265. builder.MoveToCell(0, i + 1, 3, 0);
  16266. string company = "";
  16267. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16268. {
  16269. company = DcList[i].CompanyFullName.ToString();
  16270. }
  16271. builder.Write(company);
  16272. builder.MoveToCell(0, i + 1, 4, 0);
  16273. builder.Write(DcList[i].Job);
  16274. }
  16275. }
  16276. else if (_dto.Language == 1)
  16277. {
  16278. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16279. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16280. List<string> transArrayStr = new List<string>();
  16281. string transStrRes1 = "";
  16282. for (int i = 0; i < DcList.Count; i++)
  16283. {
  16284. var dc = DcList[i];
  16285. EncryptionProcessor.DecryptProperties(dc);
  16286. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16287. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16288. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16289. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16290. else transStrRes1 += $"{str1}|";
  16291. }
  16292. //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";
  16293. string transStrRes = "";
  16294. if (transStrRes1.Length > 0)
  16295. {
  16296. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16297. }
  16298. //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
  16299. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16300. //List<string> transArray = new List<string> { };
  16301. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16302. if (transStrRes.Contains("|"))
  16303. {
  16304. string[] transArray1 = transStrRes.Split('|');
  16305. if (transArray1.Length > 0)
  16306. {
  16307. foreach (var item in transArray1)
  16308. {
  16309. if (item.Contains("&"))
  16310. {
  16311. string[] transArray2 = item.Split('&');
  16312. int index = 0;
  16313. string companyName = "", job = "";
  16314. if (transArray2.Length > 0)
  16315. {
  16316. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16317. if (1 < transArray2.Length) companyName = transArray2[1];
  16318. if (2 < transArray2.Length) job = transArray2[2];
  16319. }
  16320. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16321. }
  16322. }
  16323. }
  16324. }
  16325. //循环赋值
  16326. for (int i = 0; i < DcList.Count; i++)
  16327. {
  16328. string PYName = "";
  16329. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16330. {
  16331. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16332. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16333. PYName = PY_First + " " + PY_Last;
  16334. }
  16335. else
  16336. {
  16337. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16338. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16339. PYName = PY_First + " " + PY_Last;
  16340. }
  16341. builder.MoveToCell(0, i + 1, 0, 0);
  16342. builder.Write(PYName);
  16343. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16344. builder.MoveToCell(0, i + 1, 1, 0);
  16345. builder.Write(sex);
  16346. DateTime birthDt;
  16347. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16348. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16349. builder.MoveToCell(0, i + 1, 2, 0);
  16350. builder.Write(birthday);
  16351. string company = string.Empty, job = string.Empty;
  16352. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16353. if (dcTransInfo != null)
  16354. {
  16355. company = dcTransInfo.CompanyName;
  16356. job = dcTransInfo.Job;
  16357. }
  16358. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16359. {
  16360. //查询对照表
  16361. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16362. if (tempCec != null)
  16363. {
  16364. company = tempCec.enName;
  16365. }
  16366. //翻译
  16367. else
  16368. {
  16369. }
  16370. }
  16371. builder.MoveToCell(0, i + 1, 3, 0);
  16372. builder.Write(company);
  16373. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16374. {
  16375. //查询对照表
  16376. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16377. if (tempPec != null)
  16378. {
  16379. job = tempPec.enName;
  16380. }
  16381. //翻译
  16382. else
  16383. {
  16384. }
  16385. }
  16386. builder.MoveToCell(0, i + 1, 4, 0);
  16387. builder.Write(job);
  16388. }
  16389. }
  16390. //删除多余行
  16391. while (tableOne.Rows.Count > DcList.Count + 1)
  16392. {
  16393. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16394. }
  16395. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16396. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16397. doc.Save(fileDir);
  16398. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16399. return Ok(JsonView(true, "操作成功!", Url));
  16400. }
  16401. private class TranslateInfo
  16402. {
  16403. public int Index { get; set; }
  16404. public string CompanyName { get; set; }
  16405. public string Job { get; set; }
  16406. }
  16407. #endregion
  16408. #region 团组倒推表
  16409. /// <summary>
  16410. /// 倒推表基础数据
  16411. /// Init
  16412. /// </summary>
  16413. /// <param name="dto"></param>
  16414. /// <returns></returns>
  16415. [HttpPost]
  16416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16417. public async Task<IActionResult> PostInvertedListInit()
  16418. {
  16419. var viewData = await _invertedListRep._Init();
  16420. if (viewData.Code != 0)
  16421. {
  16422. return Ok(JsonView(false, viewData.Msg));
  16423. }
  16424. return Ok(JsonView(viewData.Data));
  16425. }
  16426. /// <summary>
  16427. /// 倒推表
  16428. /// Info
  16429. /// </summary>
  16430. /// <param name="dto"></param>
  16431. /// <returns></returns>
  16432. [HttpPost]
  16433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16434. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16435. {
  16436. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16437. if (viewData.Code != 0)
  16438. {
  16439. return Ok(JsonView(false, viewData.Msg));
  16440. }
  16441. return Ok(JsonView(viewData.Data));
  16442. }
  16443. /// <summary>
  16444. /// 倒推表
  16445. /// Create
  16446. /// </summary>
  16447. /// <param name="dto"></param>
  16448. /// <returns></returns>
  16449. [HttpPost]
  16450. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16451. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16452. {
  16453. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16454. if (viewData.Code != 0)
  16455. {
  16456. return Ok(JsonView(false, viewData.Msg));
  16457. }
  16458. return Ok(JsonView(viewData.Data));
  16459. }
  16460. /// <summary>
  16461. /// 倒推表
  16462. /// Update
  16463. /// </summary>
  16464. /// <param name="dto"></param>
  16465. /// <returns></returns>
  16466. [HttpPost]
  16467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16468. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16469. {
  16470. var viewData = await _invertedListRep._Update(dto);
  16471. if (viewData.Code != 0)
  16472. {
  16473. return Ok(JsonView(false, viewData.Msg));
  16474. }
  16475. return Ok(JsonView(viewData.Data));
  16476. }
  16477. /// <summary>
  16478. /// 倒推表
  16479. /// File Download
  16480. /// </summary>
  16481. /// <param name="dto"></param>
  16482. /// <returns></returns>
  16483. [HttpPost]
  16484. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16485. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16486. {
  16487. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16488. if (info2.Code != 0)
  16489. {
  16490. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16491. }
  16492. var info1 = info2.Data as InvertedListInfoView;
  16493. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16494. string teamName = "";
  16495. if (info != null) teamName = info.TeamName;
  16496. //载入模板
  16497. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  16498. DocumentBuilder builder = new DocumentBuilder(doc);
  16499. //利用键值对存放数据
  16500. Dictionary<string, string> dic = new Dictionary<string, string>();
  16501. dic.Add("TeamName", teamName);
  16502. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16503. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16504. dic.Add("BPRemark", info1.ApprovalDataRemark);
  16505. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16506. dic.Add("SQRemark", info1.ApprovalRemark);
  16507. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16508. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16509. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16510. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  16511. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16512. dic.Add("QZRemark", info1.VisaInformationRemark);
  16513. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16514. dic.Add("SQQZRemark", info1.SendVisaRemark);
  16515. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16516. dic.Add("CQRemark", info1.IssueVisaRemark);
  16517. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16518. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16519. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16520. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16521. #region 填充word模板书签内容
  16522. foreach (var key in dic.Keys)
  16523. {
  16524. builder.MoveToBookmark(key);
  16525. builder.Write(dic[key]);
  16526. }
  16527. #endregion
  16528. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16529. string fileName = $"{teamName}团出行准备流程表.doc";
  16530. string filePath = fileDir + $@"InvertedList/{fileName}";
  16531. doc.Save(filePath);
  16532. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16533. return Ok(JsonView(true, "操作成功!", Url));
  16534. }
  16535. #endregion
  16536. #region 三公签证费用(签证费、代办费)
  16537. /// <summary>
  16538. /// 三公签证费用(签证费、代办费)
  16539. /// List
  16540. /// </summary>
  16541. /// <returns></returns>
  16542. [HttpPost]
  16543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16544. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16545. {
  16546. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16547. if (_view.Code != 0)
  16548. {
  16549. return Ok(JsonView(false, _view.Msg));
  16550. }
  16551. return Ok(JsonView(true, "操作成功!", _view.Data));
  16552. }
  16553. /// <summary>
  16554. /// 三公签证费用(签证费、代办费)
  16555. /// Add Or Update
  16556. /// </summary>
  16557. /// <returns></returns>
  16558. [HttpPost]
  16559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16560. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16561. {
  16562. var _view = await _visaFeeInfoRep._Update(_dto);
  16563. if (_view.Code != 0)
  16564. {
  16565. return Ok(JsonView(false, _view.Msg));
  16566. }
  16567. return Ok(JsonView(true, _view.Msg));
  16568. }
  16569. #endregion
  16570. #region 酒店询价
  16571. /// <summary>
  16572. /// 酒店询价
  16573. /// Init
  16574. /// </summary>
  16575. /// <param name="dto"></param>
  16576. /// <returns></returns>
  16577. [HttpPost]
  16578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16579. public async Task<IActionResult> PostHotelInquiryInit()
  16580. {
  16581. var res = await _hotelInquiryRep._Init();
  16582. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16583. return Ok(JsonView(true, res.Msg, res.Data));
  16584. }
  16585. /// <summary>
  16586. /// 酒店询价
  16587. /// page Item
  16588. /// </summary>
  16589. /// <param name="_dto"></param>
  16590. /// <returns></returns>
  16591. [HttpPost]
  16592. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16593. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16594. {
  16595. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16596. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16597. var view = res.Data as PageDataViewBase;
  16598. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16599. }
  16600. /// <summary>
  16601. /// 酒店询价
  16602. /// info
  16603. /// </summary>
  16604. /// <param name="_dto"></param>
  16605. /// <returns></returns>
  16606. [HttpPost]
  16607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16608. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16609. {
  16610. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16611. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16612. return Ok(JsonView(true, res.Msg, res.Data));
  16613. }
  16614. /// <summary>
  16615. /// 酒店询价
  16616. /// Add Or Edit
  16617. /// </summary>
  16618. /// <param name="_dto"></param>
  16619. /// <returns></returns>
  16620. [HttpPost]
  16621. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16622. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16623. {
  16624. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16625. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16626. return Ok(JsonView(true, res.Msg, res.Data));
  16627. }
  16628. /// <summary>
  16629. /// 酒店询价
  16630. /// Del
  16631. /// </summary>
  16632. /// <param name="_dto"></param>
  16633. /// <returns></returns>
  16634. [HttpPost]
  16635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16636. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16637. {
  16638. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16639. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16640. return Ok(JsonView(true, res.Msg, res.Data));
  16641. }
  16642. #endregion
  16643. #region 下载匹配op行程单
  16644. /// <summary>
  16645. /// 匹配op行程单
  16646. /// Init
  16647. /// </summary>
  16648. /// <param name="dto">团组列表请求dto</param>
  16649. /// <returns></returns>
  16650. [HttpPost]
  16651. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16652. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16653. {
  16654. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16655. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16656. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16657. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16658. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16659. .Where(it => it.IsDel == 0)
  16660. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16661. .OrderByDescending(it => it.CreateUserId)
  16662. .ToList();
  16663. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16664. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16665. var diids = groupInfos.Select(it => it.Id).ToList();
  16666. List<string> countrys = new List<string>();
  16667. foreach (var item in country)
  16668. {
  16669. var data = _groupRepository.FormartTeamName(item);
  16670. var dataArray = _groupRepository.GroupSplitCountry(data);
  16671. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16672. }
  16673. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16674. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16675. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16676. foreach (var item in areaItem)
  16677. {
  16678. string areaStr = item.Value;
  16679. if (!string.IsNullOrEmpty(areaStr))
  16680. {
  16681. string[] str1 = areaStr.Split("-");
  16682. if (str1.Length > 0)
  16683. {
  16684. areaArray.AddRange(str1);
  16685. }
  16686. }
  16687. }
  16688. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  16689. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  16690. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  16691. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  16692. .ToList();
  16693. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  16694. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  16695. .Where(it => countriesIds.Contains(it.Id))
  16696. .Select(it => new { it.Id, Name = it.Name_CN })
  16697. .ToList();
  16698. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  16699. .Select(it => it.TeamName).ToList();
  16700. stopwatch.Stop();
  16701. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  16702. }
  16703. ///// <summary>
  16704. ///// 匹配op行程单
  16705. ///// Init 查询区域数据
  16706. ///// </summary>
  16707. ///// <param name="dto">团组列表请求dto</param>
  16708. ///// <returns></returns>
  16709. //[HttpPost]
  16710. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16711. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  16712. //{
  16713. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16714. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  16715. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  16716. // if (string.IsNullOrEmpty(countriesDataStr))
  16717. // {
  16718. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  16719. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  16720. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  16721. // }
  16722. // else
  16723. // {
  16724. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  16725. // }
  16726. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  16727. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  16728. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  16729. // List<dynamic> childList = new List<dynamic>();
  16730. // int parentId = dto.CountriesId;
  16731. // if (provinceData.Count > 1)
  16732. // {
  16733. // foreach (var item1 in provinceData)
  16734. // {
  16735. // List<dynamic> childList1 = new List<dynamic>();
  16736. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  16737. // foreach (var item2 in citiesData1)
  16738. // {
  16739. // List<dynamic> childList2 = new List<dynamic>();
  16740. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16741. // foreach (var item3 in countiesData1)
  16742. // {
  16743. // childList2.Add(new
  16744. // {
  16745. // id = item3.Id,
  16746. // parentId = item2.Id,
  16747. // level = "district",
  16748. // name = item3.Name_CN,
  16749. // });
  16750. // }
  16751. // childList1.Add(new
  16752. // {
  16753. // id = item2.Id,
  16754. // parentId = item1.Id,
  16755. // level = "city",
  16756. // name = item2.Name_CN,
  16757. // childList = childList2
  16758. // });
  16759. // }
  16760. // childList.Add(new
  16761. // {
  16762. // id = item1.Id,
  16763. // parentId = parentId,
  16764. // level = "province",
  16765. // name = item1.Name_CN,
  16766. // childList = childList1
  16767. // });
  16768. // }
  16769. // //城市
  16770. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  16771. // foreach (var item2 in citiesData2)
  16772. // {
  16773. // List<dynamic> childList22 = new List<dynamic>();
  16774. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16775. // foreach (var item3 in countiesData1)
  16776. // {
  16777. // childList22.Add(new
  16778. // {
  16779. // id = item3.Id,
  16780. // parentId = item2.Id,
  16781. // level = "district",
  16782. // name = item3.Name_CN,
  16783. // });
  16784. // }
  16785. // childList.Add(new
  16786. // {
  16787. // id = item2.Id,
  16788. // parentId = parentId,
  16789. // level = "city",
  16790. // name = item2.Name_CN,
  16791. // childList = childList22
  16792. // });
  16793. // }
  16794. // }
  16795. // else
  16796. // {
  16797. // foreach (var item2 in citiesData)
  16798. // {
  16799. // string cname = item2.Name_CN;
  16800. // List<dynamic> childList1 = new List<dynamic>();
  16801. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16802. // foreach (var item3 in countiesData1)
  16803. // {
  16804. // childList1.Add(new
  16805. // {
  16806. // Id = item3.Id,
  16807. // parentId = item2.Id,
  16808. // level = "district",
  16809. // name = item3.Name_CN
  16810. // });
  16811. // }
  16812. // childList.Add(new
  16813. // {
  16814. // id = item2.Id,
  16815. // parentId = parentId,
  16816. // level = "city",
  16817. // name = item2.Name_CN,
  16818. // childList = childList1
  16819. // });
  16820. // }
  16821. // }
  16822. // stopwatch.Stop();
  16823. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  16824. //}
  16825. /// <summary>
  16826. /// 匹配op行程单
  16827. /// 接团信息列表 Page
  16828. /// </summary>
  16829. /// <param name="dto">团组列表请求dto</param>
  16830. /// <returns></returns>
  16831. [HttpPost]
  16832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16833. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  16834. {
  16835. var swatch = new Stopwatch();
  16836. swatch.Start();
  16837. #region 参数验证
  16838. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16839. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16840. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16841. #region 页面操作权限验证
  16842. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16843. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  16844. #endregion
  16845. #endregion
  16846. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16847. {
  16848. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  16849. string sqlWhere = "";
  16850. if (!string.IsNullOrEmpty(dto.Country))
  16851. {
  16852. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  16853. }
  16854. if (!string.IsNullOrEmpty(dto.Area))
  16855. {
  16856. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  16857. }
  16858. if (!string.IsNullOrEmpty(dto.TeamName))
  16859. {
  16860. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  16861. }
  16862. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  16863. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  16864. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  16865. swatch.Stop();
  16866. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  16867. }
  16868. else
  16869. {
  16870. return Ok(JsonView(false, "查询失败"));
  16871. }
  16872. }
  16873. /// <summary>
  16874. /// 匹配op行程单
  16875. /// 行程单下载
  16876. /// </summary>
  16877. /// <param name="dto">团组列表请求dto</param>
  16878. /// <returns></returns>
  16879. [HttpPost]
  16880. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16881. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  16882. {
  16883. #region 参数验证
  16884. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16885. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16886. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16887. #region 页面操作权限验证
  16888. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16889. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  16890. #endregion
  16891. #endregion
  16892. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16893. {
  16894. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  16895. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  16896. }
  16897. else
  16898. {
  16899. return Ok(JsonView(false, "下载失败!"));
  16900. }
  16901. }
  16902. #endregion
  16903. #region 国家信息 数据 注释
  16904. //[HttpPost]
  16905. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  16906. //{
  16907. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  16908. // foreach (var item in dto)
  16909. // {
  16910. // infos.Add(new Grp_GroupsTaskAssignment()
  16911. // {
  16912. // DIId = item,
  16913. // CTId = 82,
  16914. // UId = 248,
  16915. // IsEnable = 1,
  16916. // CreateUserId = 233,
  16917. // CreateTime = DateTime.Now,
  16918. // IsDel = 0
  16919. // });
  16920. // infos.Add(new Grp_GroupsTaskAssignment()
  16921. // {
  16922. // DIId = item,
  16923. // CTId = 82,
  16924. // UId = 286,
  16925. // IsEnable = 1,
  16926. // CreateUserId = 233,
  16927. // CreateTime = DateTime.Now,
  16928. // IsDel = 0
  16929. // });
  16930. // }
  16931. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  16932. // return Ok("操作成功");
  16933. //}
  16934. //public class paramJsonDto
  16935. //{
  16936. // public List<CountriesInfo> str { get; set; }
  16937. //}
  16938. //[HttpPost]
  16939. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  16940. //{
  16941. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  16942. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  16943. // List<Sys_Cities> cities = new List<Sys_Cities>();
  16944. // List<Sys_Cities> districts = new List<Sys_Cities>();
  16945. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  16946. // _sqlSugar.BeginTran();
  16947. // int countitiesIndex = 0;
  16948. // foreach (var item in dto.str)
  16949. // {
  16950. // dynamic data = item.c;
  16951. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  16952. // if (data != null)
  16953. // {
  16954. // countitiesIndex++;
  16955. // foreach (var item1 in data)
  16956. // {
  16957. // string cnname = item1.cn;
  16958. // string enname = item1.en;
  16959. // Sys_Cities provinceInfo = new Sys_Cities()
  16960. // {
  16961. // CountriesId = countriesId,
  16962. // Name_CN = cnname,
  16963. // Name_EN = enname,
  16964. // ParentId = 0,
  16965. // IsCapital = 1,
  16966. // CreateUserId = 208,
  16967. // CreateTime = DateTime.Now,
  16968. // IsDel = 0
  16969. // };
  16970. // if (item1.lv == "province") //省份
  16971. // {
  16972. // provinceInfo.Level = 1;
  16973. // int provinceId = 0;
  16974. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  16975. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  16976. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  16977. // var data1 = item1.c;
  16978. // foreach (var item2 in data1)
  16979. // {
  16980. // if (item2.lv == "city")
  16981. // {
  16982. // string citycnname = item2.cn;
  16983. // string cityenname = item2.en;
  16984. // Sys_Cities cityInfo = new Sys_Cities()
  16985. // {
  16986. // CountriesId = countriesId,
  16987. // ParentId = provinceId,
  16988. // Level = 2,
  16989. // Name_CN = citycnname,
  16990. // Name_EN = cityenname,
  16991. // IsCapital = 1,
  16992. // CreateUserId = 208,
  16993. // CreateTime = DateTime.Now,
  16994. // IsDel = 0
  16995. // };
  16996. // if (item2.c != null)
  16997. // {
  16998. // int cityId = 0;
  16999. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  17000. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17001. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  17002. // foreach (var item3 in item2.c)
  17003. // {
  17004. // if (item3.lv == "district")
  17005. // {
  17006. // var districtInfo = new Sys_Cities()
  17007. // {
  17008. // CountriesId = countriesId,
  17009. // Name_CN = item3.cn,
  17010. // Name_EN = item3.en,
  17011. // Level = 3,
  17012. // ParentId = cityId,
  17013. // IsCapital = 1,
  17014. // CreateUserId = 208,
  17015. // CreateTime = DateTime.Now,
  17016. // IsDel = 0
  17017. // };
  17018. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17019. // //{
  17020. // districts.Add(districtInfo);
  17021. // //}
  17022. // }
  17023. // }
  17024. // }
  17025. // else
  17026. // {
  17027. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  17028. // //{
  17029. // cities.Add(cityInfo);
  17030. // //}
  17031. // }
  17032. // }
  17033. // }
  17034. // }
  17035. // else if (item1.lv == "city")//城市
  17036. // {
  17037. // provinceInfo.Level = 2;
  17038. // if (item1.c != null)
  17039. // {
  17040. // int cityId = 0;
  17041. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  17042. // if (citiesInfo != null) cityId = citiesInfo.Id;
  17043. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  17044. // foreach (var item3 in item1.c)
  17045. // {
  17046. // if (item3.lv == "district")
  17047. // {
  17048. // var districtInfo = new Sys_Cities()
  17049. // {
  17050. // CountriesId = countriesId,
  17051. // Name_CN = item3.cn,
  17052. // Name_EN = item3.en,
  17053. // Level = 3,
  17054. // ParentId = cityId,
  17055. // IsCapital = 1,
  17056. // CreateUserId = 208,
  17057. // CreateTime = DateTime.Now,
  17058. // IsDel = 0
  17059. // };
  17060. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  17061. // //{
  17062. // districts.Add(districtInfo);
  17063. // //}
  17064. // }
  17065. // }
  17066. // }
  17067. // else
  17068. // {
  17069. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17070. // //{
  17071. // cities.Add(provinceInfo);
  17072. // //}
  17073. // }
  17074. // }
  17075. // }
  17076. // }
  17077. // }
  17078. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17079. // cities = cities.Distinct().ToList();
  17080. // districts = districts.Distinct().ToList();
  17081. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17082. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17083. // cities.AddRange(districts);
  17084. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17085. // //_sqlSugar.RollbackTran();
  17086. // _sqlSugar.CommitTran();
  17087. // return Ok(JsonView(false, "操作成功!"));
  17088. //}
  17089. //[HttpPost]
  17090. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17091. //{
  17092. // List<CountitiesInfo> infos = dto.MyProperty;
  17093. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17094. // _sqlSugar.BeginTran();
  17095. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17096. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17097. // foreach (var item in infos)
  17098. // {
  17099. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17100. // if (countryInfo != null)
  17101. // {
  17102. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17103. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17104. // if (cityInfo1 != null)
  17105. // {
  17106. // cityInfo1.IsCapital = 0;
  17107. // cityInfos.Add(cityInfo1);
  17108. // }
  17109. // }
  17110. // }
  17111. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17112. // .UpdateColumns(it => it.IsCapital)
  17113. // .WhereColumns(it => it.Id)
  17114. // .ExecuteCommand();
  17115. // //_sqlSugar.RollbackTran();
  17116. // _sqlSugar.CommitTran();
  17117. // return Ok(JsonView(false, "操作成功!"));
  17118. //}
  17119. //public class CounrtiesDto
  17120. //{
  17121. // public List<CountitiesInfo> MyProperty { get; set; }
  17122. //}
  17123. //public class CountitiesInfo
  17124. //{
  17125. // /// <summary>
  17126. // /// 圣约翰
  17127. // /// </summary>
  17128. // public string capital_name_chinese { get; set; }
  17129. // /// <summary>
  17130. // ///
  17131. // /// </summary>
  17132. // public string capital_name { get; set; }
  17133. // /// <summary>
  17134. // ///
  17135. // /// </summary>
  17136. // public string country_type { get; set; }
  17137. // /// <summary>
  17138. // /// 安提瓜和巴布达
  17139. // /// </summary>
  17140. // public string country_name_chinese { get; set; }
  17141. // /// <summary>
  17142. // /// 安提瓜和巴布达
  17143. // /// </summary>
  17144. // public string country_name_chinese_short { get; set; }
  17145. // /// <summary>
  17146. // /// 安提瓜和巴布达
  17147. // /// </summary>
  17148. // public string country_name_chinese_UN { get; set; }
  17149. // /// <summary>
  17150. // ///
  17151. // /// </summary>
  17152. // public string country_name_english_abbreviation { get; set; }
  17153. // /// <summary>
  17154. // ///
  17155. // /// </summary>
  17156. // public string country_name_english_formal { get; set; }
  17157. // /// <summary>
  17158. // ///
  17159. // /// </summary>
  17160. // public string country_name_english_UN { get; set; }
  17161. // /// <summary>
  17162. // ///
  17163. // /// </summary>
  17164. // public string continent_name { get; set; }
  17165. // /// <summary>
  17166. // ///
  17167. // /// </summary>
  17168. // public string subregion_name { get; set; }
  17169. // /// <summary>
  17170. // ///
  17171. // /// </summary>
  17172. // public string country_code2 { get; set; }
  17173. // /// <summary>
  17174. // ///
  17175. // /// </summary>
  17176. // public string country_code3 { get; set; }
  17177. // /// <summary>
  17178. // ///
  17179. // /// </summary>
  17180. // public string phone_code { get; set; }
  17181. //}
  17182. //public class CountriesInfo : BasicInfo
  17183. //{
  17184. // public List<CitiesInfo> c { get; set; }
  17185. //}
  17186. //public class CitiesInfo : BasicInfo
  17187. //{
  17188. // public List<AreaInfo> c { get; set; }
  17189. //}
  17190. //public class AreaInfo : BasicInfo
  17191. //{
  17192. // public List<AreaInfo> c { get; set; }
  17193. //}
  17194. //public class BasicInfo
  17195. //{
  17196. // public string code { get; set; }
  17197. // public string cn { get; set; }
  17198. // public string lv { get; set; }
  17199. // public string en { get; set; }
  17200. //}
  17201. #endregion
  17202. #region 查看邀请方
  17203. /// <summary>
  17204. /// 查看邀请方
  17205. /// 邀请方信息 Init
  17206. /// </summary>
  17207. /// <param name="dto"></param>
  17208. /// <returns></returns>
  17209. [HttpPost]
  17210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17211. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17212. {
  17213. string sqlWhere = string.Empty;
  17214. if (!string.IsNullOrEmpty(dto.Search))
  17215. {
  17216. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17217. }
  17218. string sql = string.Format($@"Select
  17219. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17220. Id,
  17221. UnitName
  17222. From Res_InvitationOfficialActivityData
  17223. Where IsDel = 0
  17224. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17225. RefAsync<int> total = 0;
  17226. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17227. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17228. }
  17229. /// <summary>
  17230. /// 查看邀请方
  17231. /// 国家信息 Init
  17232. /// </summary>
  17233. /// <param name="dto"></param>
  17234. /// <returns></returns>
  17235. [HttpPost]
  17236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17237. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17238. {
  17239. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17240. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17241. var diids = groupInfos.Select(it => it.Id).ToList();
  17242. List<string> countrys = new List<string>();
  17243. foreach (var item in country)
  17244. {
  17245. var data = _groupRepository.FormartTeamName(item);
  17246. var dataArray = _groupRepository.GroupSplitCountry(data);
  17247. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17248. }
  17249. countrys = countrys.Distinct().ToList();
  17250. for (int i = 0; i < countrys.Count; i++)
  17251. {
  17252. string item = countrys[i];
  17253. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17254. {
  17255. countrys.Remove(item);
  17256. i--;
  17257. }
  17258. }
  17259. RefAsync<int> total = 0;
  17260. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17261. .Where(it => countrys.Contains(it.Name_CN))
  17262. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17263. .Select(it => new { id = it.Id, name = it.Name_CN })
  17264. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17265. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17266. }
  17267. /// <summary>
  17268. /// 查看邀请方
  17269. /// 城市信息 Init
  17270. /// </summary>
  17271. /// <param name="dto"></param>
  17272. /// <returns></returns>
  17273. [HttpPost]
  17274. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17275. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17276. {
  17277. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17278. RefAsync<int> total = 0;
  17279. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17280. .Where(it => it.CountriesId == dto.CountiesId)
  17281. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17282. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17283. .Select(it => new { id = it.Id, name = it.Name_CN })
  17284. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17285. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17286. }
  17287. /// <summary>
  17288. /// 查看邀请方
  17289. /// 团组名称 Init
  17290. /// </summary>
  17291. /// <param name="dto"></param>
  17292. /// <returns></returns>
  17293. [HttpPost]
  17294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17295. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17296. {
  17297. var watch = new Stopwatch();
  17298. watch.Start();
  17299. RefAsync<int> total = 0;
  17300. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17301. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17302. .Where((oa, di) => oa.IsDel == 0)
  17303. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17304. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17305. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17306. .Distinct()
  17307. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17308. watch.Stop();
  17309. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17310. }
  17311. /// <summary>
  17312. /// 查看邀请方
  17313. /// 团组 & 邀请方信息
  17314. /// </summary>
  17315. /// <param name="dto"></param>
  17316. /// <returns></returns>
  17317. [HttpPost]
  17318. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17319. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17320. {
  17321. var watch = new Stopwatch();
  17322. watch.Start();
  17323. RefAsync<int> total = 0;
  17324. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17325. .AS("Grp_DelegationInfo")
  17326. .Includes(x => x.InvitingInfos)
  17327. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17328. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17329. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17330. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17331. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17332. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17333. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17334. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17335. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17336. infos.ForEach(x =>
  17337. {
  17338. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17339. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17340. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17341. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17342. });
  17343. watch.Stop();
  17344. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17345. }
  17346. #endregion
  17347. #region 报批行程
  17348. /// <summary>
  17349. /// 报批行程初始化
  17350. /// </summary>
  17351. /// <param name="dto"></param>
  17352. /// <returns></returns>
  17353. [HttpPost]
  17354. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17355. {
  17356. const int chiNumber = 5;
  17357. var jw = JsonView(false);
  17358. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17359. var group = groupList.First();
  17360. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17361. group = groupList.First(x => x.Id == diid);
  17362. if (group == null)
  17363. {
  17364. jw.Msg = "暂无团组!";
  17365. return Ok(jw);
  17366. }
  17367. var data = new
  17368. {
  17369. groupList = groupList.Select(x => new
  17370. {
  17371. x.TeamName,
  17372. x.Id
  17373. }),
  17374. content = new ArrayList(),
  17375. groupInfo = new
  17376. {
  17377. group.VisitDays,
  17378. group.TourCode,
  17379. group.VisitPNumber,
  17380. group.TeamName,
  17381. group.Id,
  17382. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17383. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17384. },
  17385. };
  17386. var resultArr = new ArrayList();
  17387. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17388. if (content.Count == 0)
  17389. {
  17390. var stay = "-";
  17391. var cityPath = "-";
  17392. //添加城市路径以及住宿地
  17393. //黑屏代码数据
  17394. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17395. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17396. {
  17397. jw = JsonView(true, "黑屏代码有误!", data);
  17398. return Ok(jw);
  17399. }
  17400. foreach (DataRow row in dtBlack.Rows)
  17401. {
  17402. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17403. {
  17404. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17405. return Ok(jw);
  17406. }
  17407. }
  17408. //黑屏代码获取时间区间
  17409. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17410. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17411. _sqlSugar.BeginTran();
  17412. for (int i = 0; i < timeArr.Count; i++)
  17413. {
  17414. stay = "-";
  17415. cityPath = "-";
  17416. DateTime NewData = DateTime.Parse(timeArr[i]);
  17417. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17418. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17419. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17420. if (tbSelect.Length > 0)
  17421. {
  17422. List<string> threeCodeStr = new List<string>();
  17423. foreach (var item in tbSelect)
  17424. {
  17425. var threeCode = item["Three"].ToString() ?? "";
  17426. if (threeCode.Length == 6)
  17427. {
  17428. var start = threeCode.Substring(0, 3);
  17429. var end = threeCode.Substring(3, 3);
  17430. if (threeCodeStr.Count == 0)
  17431. {
  17432. threeCodeStr.Add(start);
  17433. threeCodeStr.Add(end);
  17434. }
  17435. else
  17436. {
  17437. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17438. {
  17439. threeCodeStr.Add(end);
  17440. }
  17441. else
  17442. {
  17443. threeCodeStr.Add(start);
  17444. threeCodeStr.Add(end);
  17445. }
  17446. }
  17447. }
  17448. }
  17449. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17450. var last = threeCodeStr.Last();
  17451. foreach (var item in threeCodeStr)
  17452. {
  17453. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17454. if (item.Equals(last))
  17455. {
  17456. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17457. }
  17458. }
  17459. cityPath = cityPath.Trim('-');
  17460. }
  17461. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17462. appro.Diid = diid ?? -1;
  17463. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17464. appro.Id = thisId;
  17465. appro.CreateUserId = dto.UserId;
  17466. appro.CreateTime = DateTime.Now;
  17467. content.Add(appro);
  17468. }
  17469. _sqlSugar.CommitTran();
  17470. }
  17471. foreach (var x in content)
  17472. {
  17473. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17474. if (chiList.Count < chiNumber)
  17475. {
  17476. for (int i = chiList.Count; i < chiNumber; i++)
  17477. {
  17478. chiList.Add(new Grp_ApprovalTravelDetails());
  17479. }
  17480. }
  17481. resultArr.Add(new
  17482. {
  17483. x.Id,
  17484. x.Date,
  17485. x.Diid,
  17486. chiList = chiList.Select(x1 => new
  17487. {
  17488. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17489. x1.Details,
  17490. x1.ParentId,
  17491. x1.Id
  17492. })
  17493. });
  17494. }
  17495. data = data with
  17496. {
  17497. content = resultArr,
  17498. };
  17499. jw = JsonView(true, "获取成功!", data);
  17500. return Ok(jw);
  17501. }
  17502. /// <summary>
  17503. /// 报批行程删除
  17504. /// </summary>
  17505. /// <param name="dto"></param>
  17506. /// <returns></returns>
  17507. [HttpPost]
  17508. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17509. {
  17510. var jw = JsonView(false);
  17511. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17512. if (group == null)
  17513. {
  17514. jw.Msg = "团组参数有误!";
  17515. return Ok(jw);
  17516. }
  17517. try
  17518. {
  17519. _sqlSugar.BeginTran();
  17520. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17521. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17522. {
  17523. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17524. DeleteUserId = dto.uesrId,
  17525. IsDel = 1
  17526. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17527. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17528. {
  17529. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17530. DeleteUserId = dto.uesrId,
  17531. IsDel = 1
  17532. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17533. _sqlSugar.CommitTran();
  17534. jw = JsonView(true, "删除成功");
  17535. }
  17536. catch (Exception ex)
  17537. {
  17538. jw = JsonView(false, ex.Message);
  17539. }
  17540. return Ok(jw);
  17541. }
  17542. /// <summary>
  17543. /// 报批行程保存
  17544. /// </summary>
  17545. /// <param name="dto"></param>
  17546. /// <returns></returns>
  17547. [HttpPost]
  17548. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17549. {
  17550. var jw = JsonView(false);
  17551. var Find = dto.Arr.Find(x => x.id == 0);
  17552. if (Find != null)
  17553. {
  17554. jw.Msg = "生成的ID为0!";
  17555. return Ok(jw);
  17556. }
  17557. foreach (var item in dto.Arr)
  17558. {
  17559. foreach (var chi in item.chiList)
  17560. {
  17561. if (chi.parentId == 0)
  17562. {
  17563. chi.parentId = item.id;
  17564. }
  17565. }
  17566. }
  17567. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17568. _sqlSugar.BeginTran();
  17569. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17570. {
  17571. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17572. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17573. {
  17574. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17575. DeleteUserId = dto.UserId,
  17576. IsDel = 1
  17577. }).ExecuteCommand();
  17578. }
  17579. try
  17580. {
  17581. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17582. {
  17583. CreateTime = DateTime.Now,
  17584. CreateUserId = dto.UserId,
  17585. Details = x.details,
  17586. ParentId = x.parentId,
  17587. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17588. Remark = "",
  17589. IsDel = 0
  17590. }).ToList()).ExecuteCommand();
  17591. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17592. {
  17593. Id = x.id,
  17594. Details = x.details,
  17595. ParentId = x.parentId,
  17596. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17597. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17598. {
  17599. Details = x.Details,
  17600. ParentId = x.ParentId,
  17601. Time = x.Time
  17602. }).ExecuteCommand();
  17603. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17604. {
  17605. Id = x.id,
  17606. Date = x.date,
  17607. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17608. {
  17609. Date = x.Date
  17610. }).ExecuteCommand();
  17611. _sqlSugar.CommitTran();
  17612. jw = JsonView(true, "保存成功!");
  17613. }
  17614. catch (Exception ex)
  17615. {
  17616. _sqlSugar.RollbackTran();
  17617. jw = JsonView(false, "保存失败!" + ex.Message);
  17618. }
  17619. return Ok(jw);
  17620. }
  17621. /// <summary>
  17622. /// 报批行程生成
  17623. /// </summary>
  17624. /// <param name="dto"></param>
  17625. /// <returns></returns>
  17626. [HttpPost]
  17627. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17628. {
  17629. var jw = JsonView(false);
  17630. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17631. if (group == null)
  17632. {
  17633. jw.Msg = "暂无该团组!";
  17634. return Ok(jw);
  17635. }
  17636. //黑屏代码数据
  17637. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17638. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17639. {
  17640. jw.Msg = "黑屏代码有误!";
  17641. return Ok(jw);
  17642. }
  17643. foreach (DataRow row in dtBlack.Rows)
  17644. {
  17645. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17646. {
  17647. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17648. return Ok(jw);
  17649. }
  17650. }
  17651. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17652. var resultArr = new ArrayList();
  17653. if (officialActivitiesArr.Count == 0)
  17654. {
  17655. jw.Msg = "暂无公务出访信息!";
  17656. return Ok(jw);
  17657. }
  17658. try
  17659. {
  17660. _sqlSugar.BeginTran();
  17661. DeleteApprovalJourney(new
  17662. Domain.Dtos.Groups.DeleteApprovalJourney
  17663. {
  17664. Diid = dto.Diid,
  17665. uesrId = dto.Userid
  17666. });
  17667. var stay = "-";
  17668. var cityPath = "-";
  17669. //添加城市路径以及住宿地
  17670. //黑屏代码获取时间区间
  17671. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17672. var empty = "【未收入该三字码!请机票同事录入】";
  17673. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17674. for (int i = 0; i < timeArr.Count; i++)
  17675. {
  17676. stay = "-";
  17677. cityPath = "-";
  17678. var chiarr = new List<Grp_ApprovalTravelDetails>();
  17679. DateTime NewData = DateTime.Parse(timeArr[i]);
  17680. 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();
  17681. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17682. if (tbSelect.Length > 0)
  17683. {
  17684. List<string> threeCodeStr = new List<string>();
  17685. bool isTrade = false;
  17686. string trip = string.Empty;
  17687. var rowLast = tbSelect.Last();
  17688. var rowFirst = tbSelect.First();
  17689. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  17690. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  17691. var takeOffTime = DateTime.Parse(timeArr[i]);
  17692. var fallToTime = DateTime.Parse(timeArr[i]);
  17693. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  17694. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  17695. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  17696. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  17697. foreach (var item in tbSelect)
  17698. {
  17699. var start = string.Empty;
  17700. var end = string.Empty;
  17701. var threeCode = item["Three"].ToString() ?? "";
  17702. if (threeCode.Length == 6)
  17703. {
  17704. start = threeCode.Substring(0, 3);
  17705. end = threeCode.Substring(3, 3);
  17706. if (threeCodeStr.Count == 0)
  17707. {
  17708. threeCodeStr.Add(start);
  17709. threeCodeStr.Add(end);
  17710. }
  17711. else
  17712. {
  17713. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17714. {
  17715. threeCodeStr.Add(end);
  17716. }
  17717. else
  17718. {
  17719. threeCodeStr.Add(start);
  17720. threeCodeStr.Add(end);
  17721. }
  17722. }
  17723. }
  17724. //处理机票信息
  17725. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  17726. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  17727. if (start_Object == null)
  17728. {
  17729. start_Object = new Res_ThreeCode()
  17730. {
  17731. AirPort = empty,
  17732. AirPort_En = empty,
  17733. City = empty,
  17734. Country = empty,
  17735. Four = empty,
  17736. Three = empty,
  17737. };
  17738. }
  17739. if (end_Object == null)
  17740. {
  17741. end_Object = new Res_ThreeCode()
  17742. {
  17743. AirPort = empty,
  17744. AirPort_En = empty,
  17745. City = empty,
  17746. Country = empty,
  17747. Four = empty,
  17748. Three = empty,
  17749. };
  17750. }
  17751. //机型判断
  17752. string airModel = item["AirModel"].ToString();
  17753. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  17754. string flightTime = item["FlightTime"].ToString();
  17755. if (flightTime!.Contains(":"))
  17756. {
  17757. flightTime = flightTime.Replace(":", "小时");
  17758. flightTime += "分钟";
  17759. }
  17760. if (flightTime.Contains("H"))
  17761. {
  17762. flightTime = flightTime.Replace("H", "小时");
  17763. }
  17764. if (flightTime.Contains("M"))
  17765. {
  17766. flightTime = flightTime.Replace("M", "分钟");
  17767. }
  17768. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  17769. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  17770. {
  17771. flightTime = flightDataTime.Hour > 0
  17772. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  17773. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  17774. ? flightDataTime.Minute.ToString() + "分钟" : "";
  17775. }
  17776. //航班号
  17777. string flightcode = item["Fliagtcode"].ToString();
  17778. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  17779. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  17780. if (aircompany == null)
  17781. {
  17782. aircompany = new Res_AirCompany
  17783. {
  17784. CnName = hsEmpty,
  17785. EnName = hsEmpty,
  17786. ShortCode = hsEmpty,
  17787. };
  17788. }
  17789. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  17790. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  17791. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  17792. if (isTrade)
  17793. {
  17794. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  17795. }
  17796. else
  17797. {
  17798. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  17799. }
  17800. }
  17801. chiarr.Add(new Grp_ApprovalTravelDetails
  17802. {
  17803. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  17804. CreateTime = DateTime.Now,
  17805. CreateUserId = dto.Userid,
  17806. ParentId = 0,
  17807. Details = trip
  17808. });
  17809. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17810. var last = threeCodeStr.Last();
  17811. foreach (var item in threeCodeStr)
  17812. {
  17813. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17814. if (item.Equals(last))
  17815. {
  17816. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17817. }
  17818. }
  17819. cityPath = cityPath.Trim('-');
  17820. }
  17821. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17822. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17823. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17824. appro.Diid = dto.Diid;
  17825. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17826. appro.Id = thisId;
  17827. appro.CreateUserId = dto.Userid;
  17828. appro.CreateTime = DateTime.Now;
  17829. foreach (var item in gwinfo)
  17830. {
  17831. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  17832. chi.Details = "拜访" + item.Client;
  17833. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  17834. {
  17835. chi.Details += "," + item.ReqSample;
  17836. }
  17837. chi.ParentId = thisId;
  17838. chi.Time = item.Time;
  17839. chiarr.Add(chi);
  17840. }
  17841. if (chiarr.Count < 5)
  17842. {
  17843. for (int j = chiarr.Count; j < 5; j++)
  17844. {
  17845. chiarr.Add(new
  17846. Grp_ApprovalTravelDetails());
  17847. }
  17848. }
  17849. resultArr.Add(new
  17850. {
  17851. appro.Id,
  17852. appro.Date,
  17853. appro.Diid,
  17854. chiList = chiarr.Select(x1 => new
  17855. {
  17856. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17857. x1.Details,
  17858. x1.ParentId,
  17859. x1.Id
  17860. })
  17861. });
  17862. }
  17863. _sqlSugar.CommitTran();
  17864. jw = JsonView(true, "生成成功!", resultArr);
  17865. }
  17866. catch (Exception ex)
  17867. {
  17868. jw.Code = 400;
  17869. jw.Msg = "生成失败!" + ex.Message;
  17870. }
  17871. return Ok(jw);
  17872. }
  17873. /// <summary>
  17874. /// 报批行程word导出
  17875. /// </summary>
  17876. /// <param name="dto"></param>
  17877. /// <returns></returns>
  17878. [HttpPost]
  17879. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  17880. {
  17881. var jw = JsonView(false);
  17882. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17883. if (group == null)
  17884. {
  17885. jw.Msg = "暂无该团组!";
  17886. return Ok(jw);
  17887. }
  17888. //模板路径
  17889. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  17890. //载入模板
  17891. Document doc = new Document(tempPath);
  17892. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17893. //获取所填表格的序数
  17894. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17895. Aspose.Words.Tables.Row titleRowClone = null;
  17896. Aspose.Words.Tables.Row CenterRowClone = null;
  17897. int index = 0;
  17898. int indexChi = 0;
  17899. int SetIndex = 0;
  17900. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  17901. //获取数据,放到datatable
  17902. foreach (var item in ApprovalTravelArr)
  17903. {
  17904. if (index > 0)
  17905. {
  17906. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  17907. tableOne.AppendChild(titleRowClone);
  17908. }
  17909. var textTime = item.Date;
  17910. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  17911. SetCells(tableOne, doc, SetIndex, 0, textTime);
  17912. SetIndex++;
  17913. if (ChiRep.Count > 0)
  17914. {
  17915. foreach (var itemChi in ChiRep)
  17916. {
  17917. var txtTime = itemChi.Time;
  17918. var txtDetail = itemChi.Details;
  17919. if (indexChi > 0)
  17920. {
  17921. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17922. tableOne.AppendChild(CenterRowClone);
  17923. }
  17924. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  17925. {
  17926. SetCells(tableOne, doc, SetIndex, 0, "");
  17927. SetCells(tableOne, doc, SetIndex, 1, "");
  17928. indexChi++;
  17929. SetIndex++;
  17930. break;
  17931. }
  17932. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  17933. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  17934. indexChi++;
  17935. SetIndex++;
  17936. }
  17937. }
  17938. else
  17939. {
  17940. if (indexChi > 0)
  17941. {
  17942. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17943. tableOne.AppendChild(CenterRowClone);
  17944. }
  17945. SetCells(tableOne, doc, SetIndex, 0, "");
  17946. SetCells(tableOne, doc, SetIndex, 1, "");
  17947. indexChi++;
  17948. SetIndex++;
  17949. }
  17950. index++;
  17951. }
  17952. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  17953. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17954. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17955. jw.Code = 200;
  17956. jw.Msg = "";
  17957. return Ok(jw);
  17958. }
  17959. private string intToString(int numberVal)
  17960. {
  17961. string numberval = numberVal.ToString();
  17962. Dictionary<char, string> Number = new Dictionary<char, string>();
  17963. Number.Add('1', "一");
  17964. Number.Add('2', "二");
  17965. Number.Add('3', "三");
  17966. Number.Add('4', "四");
  17967. Number.Add('5', "五");
  17968. Number.Add('6', "六");
  17969. Number.Add('7', "七");
  17970. Number.Add('8', "八");
  17971. Number.Add('9', "九");
  17972. string stringNumberVal = string.Empty;
  17973. for (int i = 0; i < numberval.Length; i++)
  17974. {
  17975. if (i == 0)
  17976. {
  17977. stringNumberVal += Number[numberval[i]];
  17978. }
  17979. else if (i >= 1)
  17980. {
  17981. if (numberval[i] == '0')
  17982. {
  17983. stringNumberVal = "十";
  17984. }
  17985. else
  17986. {
  17987. stringNumberVal += "十" + Number[numberval[i]];
  17988. }
  17989. }
  17990. }
  17991. return stringNumberVal;
  17992. }
  17993. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  17994. {
  17995. //获取table中的某个单元格,从0开始
  17996. Cell lshCell = table.Rows[rows].Cells[cells];
  17997. //将单元格中段落移除
  17998. foreach (Node item in lshCell.Paragraphs)
  17999. {
  18000. lshCell.Paragraphs.Remove(item);
  18001. }
  18002. if (val.Contains("\r\n"))
  18003. {
  18004. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  18005. foreach (var item in spArr)
  18006. {
  18007. //新建一个段落
  18008. Paragraph p = new Paragraph(doc);
  18009. var r = new Run(doc, item);
  18010. //把设置的值赋给之前新建的段落
  18011. p.AppendChild(r);
  18012. //将此段落加到单元格内
  18013. lshCell.AppendChild(p);
  18014. }
  18015. }
  18016. else
  18017. {
  18018. //新建一个段落
  18019. Paragraph p = new Paragraph(doc);
  18020. var r = new Run(doc, val);
  18021. //把设置的值赋给之前新建的段落
  18022. p.AppendChild(r);
  18023. //将此段落加到单元格内
  18024. lshCell.AppendChild(p);
  18025. }
  18026. }
  18027. [HttpPost]
  18028. public async Task<IActionResult> ServerHttp(string paramStr)
  18029. {
  18030. paramStr = paramStr.TrimEnd('\'');
  18031. paramStr = paramStr.TrimStart('\'');
  18032. JsonView jw = JsonView(false);
  18033. JObject param = JObject.Parse(paramStr);
  18034. if (!param.ContainsKey("url"))
  18035. {
  18036. jw.Msg = "url null";
  18037. return Ok(jw);
  18038. }
  18039. string url = param["url"]!.ToString();
  18040. var methon = "get";
  18041. Dictionary<string, string> headValues = null;
  18042. string bodyStr = string.Empty;
  18043. if (param.ContainsKey("methon"))
  18044. {
  18045. methon = param["methon"]!.ToString().ToLower();
  18046. }
  18047. if (param.ContainsKey("header"))
  18048. {
  18049. var header = param["header"]!.ToString();
  18050. JObject headerJobject = JObject.Parse(header);
  18051. headValues = new Dictionary<string, string>();
  18052. foreach (JProperty item in headerJobject.Properties())
  18053. {
  18054. var value = item.Value.ToString();
  18055. var head = item.Path;
  18056. headValues.Add(head, value);
  18057. }
  18058. }
  18059. HttpClient client = new HttpClient();
  18060. string responseString = string.Empty;
  18061. StringContent content = null;
  18062. if (headValues != null)
  18063. {
  18064. foreach (var item in headValues.Keys)
  18065. {
  18066. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18067. {
  18068. if (param.ContainsKey("body"))
  18069. {
  18070. bodyStr = param["body"]!.ToString();
  18071. }
  18072. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18073. }
  18074. else
  18075. {
  18076. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18077. }
  18078. }
  18079. }
  18080. try
  18081. {
  18082. if (methon == "get")
  18083. {
  18084. responseString = await client.GetStringAsync(url);
  18085. }
  18086. else if (methon == "post")
  18087. {
  18088. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18089. {
  18090. Content = content
  18091. };
  18092. var response = await client.SendAsync(request);
  18093. try
  18094. {
  18095. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18096. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18097. {
  18098. using (StreamReader reader = new StreamReader(gzipStream))
  18099. {
  18100. responseString = await reader.ReadToEndAsync();
  18101. }
  18102. }
  18103. }
  18104. catch (Exception)
  18105. {
  18106. responseString = await response.Content.ReadAsStringAsync();
  18107. }
  18108. }
  18109. else
  18110. {
  18111. responseString = "methon error";
  18112. }
  18113. jw = JsonView(true, "success", responseString);
  18114. }
  18115. catch (Exception ex)
  18116. {
  18117. jw.Msg = "error " + ex.Message;
  18118. jw.Data = ex.StackTrace;
  18119. }
  18120. finally
  18121. {
  18122. client.Dispose();
  18123. }
  18124. return Ok(jw);
  18125. }
  18126. #endregion
  18127. #region 团组接待意见调查
  18128. /// <summary>
  18129. /// 团组接待意见调查 - 信息管理
  18130. /// 基础数据(团组)
  18131. /// </summary>
  18132. /// <param name="dto"></param>
  18133. /// <returns></returns>
  18134. [HttpGet]
  18135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18136. public async Task<IActionResult> OpinionaireInit()
  18137. {
  18138. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18139. .Select(x => new
  18140. {
  18141. x.Id,
  18142. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18143. })
  18144. .OrderByDescending(x => x.Id)
  18145. .ToListAsync();
  18146. return Ok(JsonView(groupData, groupData.Count));
  18147. }
  18148. /// <summary>
  18149. /// 团组接待意见调查 - 信息管理
  18150. /// 列表
  18151. /// </summary>
  18152. /// <param name="groupId"></param>
  18153. /// <returns></returns>
  18154. [HttpGet("{groupId}")]
  18155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18156. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18157. {
  18158. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18159. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18160. .Select(x => new
  18161. {
  18162. x.Id,
  18163. x.TourGuideName,
  18164. x.CityName,
  18165. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18166. x.CreateTime
  18167. })
  18168. .OrderBy(x => x.Id)
  18169. .ToListAsync();
  18170. return Ok(JsonView(data));
  18171. }
  18172. /// <summary>
  18173. /// 团组接待意见调查 - 信息管理
  18174. /// 保存
  18175. /// </summary>
  18176. /// <param name="dto"></param>
  18177. /// <returns></returns>
  18178. [HttpPost]
  18179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18180. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18181. {
  18182. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18183. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18184. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18185. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18186. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18187. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18188. _opinionaireRep.BeginTran();
  18189. if (addData != null && addData.Count > 0)
  18190. {
  18191. foreach (var item in addData)
  18192. {
  18193. item.CreateUserId = currUserInfo.UserId;
  18194. item.DiId = dto.DiId;
  18195. }
  18196. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18197. }
  18198. if (updData != null && updData.Count > 0)
  18199. {
  18200. var upd = await _opinionaireRep._sqlSugar
  18201. .Updateable(updData)
  18202. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18203. .WhereColumns(x => new { x.Id })
  18204. .ExecuteCommandAsync();
  18205. }
  18206. _opinionaireRep.CommitTran();
  18207. return Ok(JsonView("操作成功!"));
  18208. }
  18209. /// <summary>
  18210. /// 团组接待意见调查 - 信息管理
  18211. /// 删除
  18212. /// </summary>
  18213. /// <param name="id"></param>
  18214. /// <returns></returns>
  18215. [HttpDelete("{id}")]
  18216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18217. public async Task<IActionResult> OpinionaireManageDel(int id)
  18218. {
  18219. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18220. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18221. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18222. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18223. if (!del) return Ok(JsonView("操作失败!"));
  18224. return Ok(JsonView("操作成功!"));
  18225. }
  18226. /// <summary>
  18227. /// 团组接待意见调查 - 用户
  18228. /// 列表
  18229. /// </summary>
  18230. /// <param name="id"></param>
  18231. /// <returns></returns>
  18232. [HttpGet("{diId}")]
  18233. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18234. public async Task<IActionResult> OpinionaireUserList(int diId)
  18235. {
  18236. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18237. var sql = string.Format(@"
  18238. SELECT
  18239. o.Id,
  18240. o.DiId,
  18241. di.TeamName AS 'GroupName',
  18242. di.VisitPNumber AS 'PeopleNumber',
  18243. di.ClientName AS 'LeadGroup',
  18244. di.VisitCountry AS 'Travel',
  18245. di.VisitDays AS 'Days',
  18246. o.CityName,
  18247. o.TourGuideName,
  18248. o.Catering,
  18249. o.CateringReason,
  18250. o.Stay,
  18251. o.StayReason,
  18252. o.[Route],
  18253. o.RouteReason,
  18254. o.OfficialActivity,
  18255. o.OfficialActivityReason,
  18256. o.TourGuide,
  18257. o.TourGuideReason,
  18258. o.[Translate],
  18259. o.TranslateReason,
  18260. o.Trip,
  18261. o.TripReason,
  18262. o.ESFileName,
  18263. o.SignatureDate,
  18264. o.Remark
  18265. FROM
  18266. Grp_Opinionaire o
  18267. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18268. WHERE
  18269. o.IsDel = 0
  18270. AND o.DiId = {0}
  18271. ORDER BY
  18272. o.Id ASC", diId);
  18273. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18274. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18275. return Ok(JsonView(data));
  18276. }
  18277. /// <summary>
  18278. /// 团组接待意见调查 - 用户
  18279. /// 保存
  18280. /// </summary>
  18281. /// <param name="id"></param>
  18282. /// <returns></returns>
  18283. [HttpPost]
  18284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18285. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18286. {
  18287. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18288. foreach (var item in dto)
  18289. {
  18290. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18291. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18292. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18293. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18294. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18295. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18296. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18297. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18298. }
  18299. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18300. if (!Directory.Exists(filePathBase))
  18301. {
  18302. Directory.CreateDirectory(filePathBase);
  18303. }
  18304. #region 上传文件
  18305. var filePaths = new List<string>();
  18306. foreach (var item in dto)
  18307. {
  18308. var file = item.File;
  18309. // 将文件保存到指定位置
  18310. var filePath = Path.Combine(filePathBase, file.FileName);
  18311. using (var stream = new FileStream(filePath, FileMode.Create))
  18312. {
  18313. await file.CopyToAsync(stream);
  18314. }
  18315. //验证文件是否上传成功
  18316. if (!System.IO.File.Exists(filePath))
  18317. {
  18318. foreach (var filePathStr in filePaths)
  18319. {
  18320. System.IO.File.Delete(filePathStr);
  18321. }
  18322. return Ok(JsonView(false, "文件上传失败!"));
  18323. }
  18324. item.ESFileName = file.FileName;
  18325. }
  18326. #endregion
  18327. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18328. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18329. .UpdateColumns(x => new
  18330. {
  18331. x.Catering,
  18332. x.CateringReason,
  18333. x.Stay,
  18334. x.StayReason,
  18335. x.Route,
  18336. x.RouteReason,
  18337. x.OfficialActivity,
  18338. x.OfficialActivityReason,
  18339. x.TourGuide,
  18340. x.TourGuideReason,
  18341. x.Translate,
  18342. x.TranslateReason,
  18343. x.Trip,
  18344. x.TripReason,
  18345. x.ESFileName,
  18346. x.SignatureDate,
  18347. x.Remark
  18348. })
  18349. .WhereColumns(x => new { x.Id })
  18350. .ExecuteCommandAsync();
  18351. if (upd < 1)
  18352. {
  18353. foreach (var filePathStr in filePaths)
  18354. {
  18355. System.IO.File.Delete(filePathStr);
  18356. }
  18357. return Ok(JsonView(false));
  18358. }
  18359. return Ok(JsonView(true));
  18360. }
  18361. #endregion
  18362. #region 团组餐厅相关信息
  18363. /// <summary>
  18364. /// 团组相关餐厅信息
  18365. /// 基础数据(团组)
  18366. /// </summary>
  18367. /// <returns></returns>
  18368. [HttpGet]
  18369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18370. public async Task<IActionResult> RestaurantInit()
  18371. {
  18372. return Ok(await _restaurantRep.InitAsync());
  18373. }
  18374. /// <summary>
  18375. /// 团组相关餐厅信息
  18376. /// Item
  18377. /// </summary>
  18378. /// <param name="dto"></param>
  18379. /// <returns></returns>
  18380. [HttpPost]
  18381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18382. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18383. {
  18384. int portType = dto.PortType,
  18385. groupId = dto.GroupId;
  18386. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
  18387. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18388. return Ok(await _restaurantRep.ItemAsync(portType,groupId));
  18389. }
  18390. /// <summary>
  18391. /// 团组相关餐厅信息
  18392. /// List
  18393. /// </summary>
  18394. /// <param name="dto"></param>
  18395. /// <returns></returns>
  18396. [HttpPost]
  18397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18398. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18399. {
  18400. int portType = dto.PortType,
  18401. groupId = dto.GroupId;
  18402. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18403. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18404. var sql = string.Format(@" SELECT
  18405. ri.Id,
  18406. ri.GroupId,
  18407. ri.Date,
  18408. ri.StartTime,
  18409. ri.EndTime,
  18410. CASE WHEN ri.Type = 1 THEN '早餐'
  18411. WHEN ri.Type = 2 THEN '午餐'
  18412. WHEN ri.Type = 3 THEN '晚餐'
  18413. ELSE '其他'
  18414. END AS 'Type',
  18415. ri.Name,
  18416. ri.Address,
  18417. ri.Tel,
  18418. ri.Remark,
  18419. ri.CreateTime,
  18420. u.CnName AS CreateUserName
  18421. FROM
  18422. Grp_RestaurantInfo ri
  18423. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18424. WHERE
  18425. ri.IsDel = 0
  18426. AND ri.GroupId = {0}
  18427. ORDER BY
  18428. ri.Date ASC
  18429. ", groupId);
  18430. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18431. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18432. return Ok(JsonView(infos));
  18433. }
  18434. /// <summary>
  18435. /// 团组相关餐厅信息
  18436. /// Info
  18437. /// </summary>
  18438. /// <param name="dto"></param>
  18439. /// <returns></returns>
  18440. [HttpPost]
  18441. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18442. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18443. {
  18444. int portType = dto.PortType,
  18445. id = dto.Id;
  18446. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18447. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18448. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18449. }
  18450. /// <summary>
  18451. /// 团组相关餐厅信息
  18452. /// Op
  18453. /// </summary>
  18454. /// <param name="dto"></param>
  18455. /// <returns></returns>
  18456. [HttpPost]
  18457. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18458. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18459. {
  18460. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18461. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18462. if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18463. return Ok(await _restaurantRep.OpAsync(dto));
  18464. }
  18465. /// <summary>
  18466. /// 团组相关餐厅信息
  18467. /// Del
  18468. /// </summary>
  18469. /// <param name="dto"></param>
  18470. /// <returns></returns>
  18471. [HttpPost]
  18472. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18473. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18474. {
  18475. int userId = dto.DeleteUserId;
  18476. var id = dto.Id;
  18477. if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
  18478. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18479. return Ok(await _restaurantRep.DelAsync(dto));
  18480. }
  18481. #endregion
  18482. // /// <summary>
  18483. // ///
  18484. // /// </summary>
  18485. // /// <param name="_dto"></param>
  18486. // /// <returns></returns>
  18487. // [HttpPost]
  18488. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18489. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18490. // {
  18491. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18492. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18493. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18494. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18495. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18496. // dic_psg.Add("客人", 974);
  18497. // dic_psg.Add("司机", 975);
  18498. // dic_psg.Add("导游", 976);
  18499. // dic_psg.Add("公司内部人员", 977);
  18500. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18501. // foreach (var item in list_visa)
  18502. // {
  18503. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18504. // temp.Id = item.Id;
  18505. // temp.DIId = item.DIId;
  18506. // temp.VisaClient = item.VisaClient;
  18507. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18508. // temp.VisaCurrency = item.VisaCurrency;
  18509. // temp.IsThird = item.IsThird;
  18510. // if (dic_psg.ContainsKey(item.PassengerType))
  18511. // {
  18512. // temp.PassengerType = dic_psg[item.PassengerType];
  18513. // }
  18514. // else {
  18515. // temp.PassengerType = -1;
  18516. // }
  18517. // temp.VisaNumber = item.VisaNumber;
  18518. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18519. // temp.CreateUserId = item.Operators;
  18520. // DateTime dt_ct;
  18521. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18522. // if (b_ct)
  18523. // {
  18524. // temp.CreateTime = dt_ct;
  18525. // }
  18526. // else
  18527. // {
  18528. // temp.CreateTime = DateTime.Now;
  18529. // }
  18530. // temp.DeleteTime = "";
  18531. // temp.DeleteUserId = 0;
  18532. // temp.Remark = item.Remark;
  18533. // if (string.IsNullOrEmpty(temp.Remark)) {
  18534. // temp.Remark = "";
  18535. // }
  18536. // temp.IsDel = item.IsDel;
  18537. // temp.VisaDescription = item.VisaAttachment;
  18538. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18539. //([Id]
  18540. // ,[DIId]
  18541. // ,[VisaClient]
  18542. // ,[VisaPrice]
  18543. // ,[VisaCurrency]
  18544. // ,[IsThird]
  18545. // ,[PassengerType]
  18546. // ,[VisaNumber]
  18547. // ,[VisaFreeNumber]
  18548. // ,[CreateUserId]
  18549. // ,[CreateTime]
  18550. // ,[DeleteTime]
  18551. // ,[DeleteUserId]
  18552. // ,[Remark]
  18553. // ,[IsDel]
  18554. // ,[visaDescription])
  18555. // VALUES
  18556. // ({0},{1},'{2}',{3},{4}
  18557. //,{5},{6},{7},{8},{9}
  18558. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18559. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18560. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18561. //);
  18562. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18563. // }
  18564. // return Ok(JsonView(true, "操作成功!"));
  18565. // }
  18566. /// <summary>
  18567. /// 123132123
  18568. /// </summary>
  18569. /// <param name="_dto"></param>
  18570. /// <returns></returns>
  18571. [HttpPost]
  18572. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18573. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18574. {
  18575. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18576. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18577. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18578. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18579. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18580. dicDetail.Add(789, 1034);
  18581. dicDetail.Add(790, 1035);
  18582. dicDetail.Add(791, 1036);
  18583. dicDetail.Add(792, 1037);
  18584. dicDetail.Add(793, 1038);
  18585. dicDetail.Add(794, 1039);
  18586. dicDetail.Add(795, 1040);
  18587. dicDetail.Add(796, 1041);
  18588. dicDetail.Add(797, 1042);
  18589. dicDetail.Add(798, 1043);
  18590. dicDetail.Add(801, 1044);
  18591. dicDetail.Add(802, 1045);
  18592. dicDetail.Add(803, 1046);
  18593. Dictionary<int, int> dic = new Dictionary<int, int>();
  18594. dic.Add(806, 1027);
  18595. dic.Add(807, 1028);
  18596. dic.Add(808, 1029);
  18597. dic.Add(809, 1030);
  18598. dic.Add(810, 1031);
  18599. dic.Add(811, 1032);
  18600. dic.Add(812, 1033);
  18601. foreach (var item in list_visa)
  18602. {
  18603. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18604. temp.Coefficient = item.coefficient;
  18605. DateTime dtCrt;
  18606. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18607. if (b1)
  18608. {
  18609. temp.CreateTime = dtCrt;
  18610. }
  18611. else
  18612. {
  18613. temp.CreateTime = DateTime.Now;
  18614. }
  18615. temp.CreateUserId = item.Operators;
  18616. temp.DeleteTime = "";
  18617. temp.DeleteUserId = 0;
  18618. temp.DiId = int.Parse(item.DIID);
  18619. temp.FilePath = item.FilePath;
  18620. temp.IsDel = item.IsDel;
  18621. temp.Price = item.Price;
  18622. temp.PriceCount = 1;
  18623. temp.PriceCurrency = item.Currency;
  18624. int detailId = 0;
  18625. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18626. {
  18627. detailId = dicDetail[item.PriceTypeDetail];
  18628. }
  18629. temp.PriceDetailType = detailId;
  18630. temp.PriceDt = DateTime.Now;
  18631. temp.PriceName = item.PriceName;
  18632. temp.PriceSum = item.Price;
  18633. int tid = 0;
  18634. if (dic.ContainsKey(item.PriceType))
  18635. {
  18636. tid = dic[item.PriceType];
  18637. }
  18638. temp.PriceType = tid;
  18639. temp.Remark = item.Remark;
  18640. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18641. }
  18642. return Ok(JsonView(true, "操作成功!"));
  18643. }
  18644. [HttpPost]
  18645. public IActionResult TimeTest()
  18646. {
  18647. var jw = JsonView(false, "error");
  18648. _sqlSugar.BeginTran();
  18649. try
  18650. {
  18651. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18652. .Select(x => new Crm_NewClientData
  18653. {
  18654. Id = x.Id,
  18655. Client = x.Client,
  18656. Contact = x.Contact,
  18657. Location = x.Location,
  18658. })
  18659. .ToList();
  18660. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  18661. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18662. Stopwatch stopwatch = new Stopwatch();
  18663. // 开始计时
  18664. stopwatch.Start();
  18665. foreach (var item in clientList)
  18666. {
  18667. EncryptionProcessor.DecryptProperties(item);
  18668. }
  18669. stopwatch.Stop();
  18670. jw.Code = 200;
  18671. jw.Data = stopwatch.ElapsedMilliseconds;
  18672. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  18673. }
  18674. catch (Exception ex)
  18675. {
  18676. jw.Code = 400;
  18677. jw.Msg = ex.Message;
  18678. }
  18679. return Ok(jw);
  18680. }
  18681. }
  18682. }