GroupsController.cs 1000 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556
  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.UserModel;
  10. using NPOI.SS.Util;
  11. using NPOI.XSSF.UserModel;
  12. using OASystem.API.Middlewares;
  13. using OASystem.API.OAMethodLib;
  14. using OASystem.API.OAMethodLib.APNs;
  15. using OASystem.API.OAMethodLib.File;
  16. using OASystem.API.OAMethodLib.Hub.HubClients;
  17. using OASystem.API.OAMethodLib.Hub.Hubs;
  18. using OASystem.API.OAMethodLib.JuHeAPI;
  19. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  20. using OASystem.Domain.AesEncryption;
  21. using OASystem.Domain.Dtos.CRM;
  22. using OASystem.Domain.Dtos.FileDto;
  23. using OASystem.Domain.Dtos.Financial;
  24. using OASystem.Domain.Dtos.Groups;
  25. using OASystem.Domain.Entities.Customer;
  26. using OASystem.Domain.Entities.Financial;
  27. using OASystem.Domain.Entities.Groups;
  28. using OASystem.Domain.ViewModels.Financial;
  29. using OASystem.Domain.ViewModels.Groups;
  30. using OASystem.Infrastructure.Repositories.CRM;
  31. using OASystem.Infrastructure.Repositories.Financial;
  32. using OASystem.Infrastructure.Repositories.Groups;
  33. using OfficeOpenXml;
  34. using Org.BouncyCastle.Asn1.Ocsp;
  35. using Org.BouncyCastle.Utilities.Encoders;
  36. using Quartz.Util;
  37. using SqlSugar.Extensions;
  38. using System.Collections;
  39. using System.Data;
  40. using System.Diagnostics;
  41. using System.Globalization;
  42. using System.IO.Compression;
  43. using static OASystem.API.OAMethodLib.JWTHelper;
  44. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  45. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  46. using Bookmark = Aspose.Words.Bookmark;
  47. using Cell = Aspose.Words.Tables.Cell;
  48. using Table = Aspose.Words.Tables.Table;
  49. namespace OASystem.API.Controllers
  50. {
  51. /// <summary>
  52. /// 团组相关
  53. /// </summary>
  54. //[Authorize]
  55. [Route("api/[controller]/[action]")]
  56. public class GroupsController : ControllerBase
  57. {
  58. private readonly ILogger<GroupsController> _logger;
  59. private readonly GrpScheduleRepository _grpScheduleRep;
  60. private readonly IMapper _mapper;
  61. private readonly DelegationInfoRepository _groupRepository;
  62. private readonly TaskAssignmentRepository _taskAssignmentRep;
  63. private readonly AirTicketResRepository _airTicketResRep;
  64. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  65. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  66. private readonly DelegationEnDataRepository _delegationEnDataRep;
  67. private readonly DelegationVisaRepository _delegationVisaRep;
  68. private readonly VisaPriceRepository _visaPriceRep;
  69. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  70. private readonly HotelPriceRepository _hotelPriceRep;
  71. private readonly CustomersRepository _customersRep;
  72. private readonly MessageRepository _message;
  73. private readonly SqlSugarClient _sqlSugar;
  74. private readonly TourClientListRepository _tourClientListRep;
  75. private readonly TeamRateRepository _teamRateRep;
  76. #region 成本相关
  77. private readonly CheckBoxsRepository _checkBoxs;
  78. private readonly GroupCostRepository _GroupCostRepository;
  79. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  80. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  81. #endregion
  82. private readonly SetDataRepository _setDataRep;
  83. private string url;
  84. private string path;
  85. private readonly EnterExitCostRepository _enterExitCostRep;
  86. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  87. private readonly UsersRepository _usersRep;
  88. private readonly IJuHeApiService _juHeApi;
  89. private readonly InvertedListRepository _invertedListRep;
  90. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  91. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  92. private readonly ThreeCodeRepository _threeCodeRepository;
  93. private readonly HotelInquiryRepository _hotelInquiryRep;
  94. private readonly FeeAuditRepository _feeAuditRep;
  95. private readonly VisaCommissionRepository _visaCommissionRep;
  96. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  97. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  98. private readonly List<CurrencyInfo> _currencyInit;
  99. private readonly List<int> _portTypeData;
  100. private readonly TableOperationRecordRepository _tableorRep;
  101. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  102. private readonly RestaurantRepository _restaurantRep;
  103. /// <summary>
  104. /// 构造函数
  105. /// </summary>
  106. /// <param name="logger"></param>
  107. /// <param name="mapper"></param>
  108. /// <param name="hubContext"></param>
  109. /// <param name="sqlSugar"></param>
  110. /// <param name="grpScheduleRep"></param>
  111. /// <param name="groupRepository"></param>
  112. /// <param name="taskAssignmentRep"></param>
  113. /// <param name="airTicketResRep"></param>
  114. /// <param name="decreasePaymentsRep"></param>
  115. /// <param name="InvitationOfficialActivitiesRep"></param>
  116. /// <param name="delegationEnDataRep"></param>
  117. /// <param name="enterExitCostRep"></param>
  118. /// <param name="delegationVisaRep"></param>
  119. /// <param name="message"></param>
  120. /// <param name="visaPriceRep"></param>
  121. /// <param name="carTouristGuideGroundRep"></param>
  122. /// <param name="checkBoxs"></param>
  123. /// <param name="GroupCostRepository"></param>
  124. /// <param name="CostTypeHotelNumberRepository"></param>
  125. /// <param name="GroupCostParameterRepository"></param>
  126. /// <param name="hotelPriceRep"></param>
  127. /// <param name="customersRep"></param>
  128. /// <param name="setDataRep"></param>
  129. /// <param name="tourClientListRep"></param>
  130. /// <param name="teamRateRep"></param>
  131. /// <param name="usersRep"></param>
  132. /// <param name="juHeApi"></param>
  133. /// <param name="invertedListRep"></param>
  134. /// <param name="visaFeeInfoRep"></param>
  135. /// <param name="ticketBlackCodeRep"></param>
  136. /// <param name="hotelInquiryRep"></param>
  137. /// <param name="threeCodeRepository"></param>
  138. /// <param name="feeAuditRep"></param>
  139. /// <param name="visaCommissionRep"></param>
  140. /// <param name="ffrRep"></param>
  141. /// <param name="opinionaireRep"></param>
  142. /// <param name="tableorRep"></param>
  143. /// <param name="enterExitCostDraftRep"></param>
  144. /// <param name="restaurantRep"></param>
  145. public GroupsController(
  146. ILogger<GroupsController> logger,
  147. IMapper mapper,
  148. IHubContext<ChatHub, IChatClient> hubContext,
  149. SqlSugarClient sqlSugar,
  150. GrpScheduleRepository grpScheduleRep,
  151. DelegationInfoRepository groupRepository,
  152. TaskAssignmentRepository taskAssignmentRep,
  153. AirTicketResRepository airTicketResRep,
  154. DecreasePaymentsRepository decreasePaymentsRep,
  155. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  156. DelegationEnDataRepository delegationEnDataRep,
  157. EnterExitCostRepository enterExitCostRep,
  158. DelegationVisaRepository delegationVisaRep,
  159. MessageRepository message,
  160. VisaPriceRepository visaPriceRep,
  161. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  162. CheckBoxsRepository checkBoxs,
  163. GroupCostRepository GroupCostRepository,
  164. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  165. GroupCostParameterRepository GroupCostParameterRepository,
  166. HotelPriceRepository hotelPriceRep,
  167. CustomersRepository customersRep,
  168. SetDataRepository setDataRep,
  169. TourClientListRepository tourClientListRep,
  170. TeamRateRepository teamRateRep,
  171. UsersRepository usersRep, IJuHeApiService juHeApi,
  172. InvertedListRepository invertedListRep,
  173. VisaFeeInfoRepository visaFeeInfoRep,
  174. TicketBlackCodeRepository ticketBlackCodeRep,
  175. HotelInquiryRepository hotelInquiryRep,
  176. ThreeCodeRepository threeCodeRepository,
  177. FeeAuditRepository feeAuditRep,
  178. VisaCommissionRepository visaCommissionRep,
  179. ForeignReceivablesRepository ffrRep,
  180. OpinionaireRepository opinionaireRep,
  181. TableOperationRecordRepository tableorRep,
  182. EnterExitCostDraftRepository enterExitCostDraftRep,
  183. RestaurantRepository restaurantRep
  184. )
  185. {
  186. _logger = logger;
  187. _mapper = mapper;
  188. _grpScheduleRep = grpScheduleRep;
  189. _groupRepository = groupRepository;
  190. _taskAssignmentRep = taskAssignmentRep;
  191. _airTicketResRep = airTicketResRep;
  192. _sqlSugar = sqlSugar;
  193. url = AppSettingsHelper.Get("ExcelBaseUrl");
  194. path = AppSettingsHelper.Get("ExcelBasePath");
  195. if (!System.IO.Directory.Exists(path))
  196. {
  197. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  198. }
  199. _decreasePaymentsRep = decreasePaymentsRep;
  200. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  201. _delegationEnDataRep = delegationEnDataRep;
  202. _enterExitCostRep = enterExitCostRep;
  203. _delegationVisaRep = delegationVisaRep;
  204. _message = message;
  205. _visaPriceRep = visaPriceRep;
  206. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  207. _checkBoxs = checkBoxs;
  208. _GroupCostRepository = GroupCostRepository;
  209. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  210. _GroupCostParameterRepository = GroupCostParameterRepository;
  211. _hotelPriceRep = hotelPriceRep;
  212. _customersRep = customersRep;
  213. _setDataRep = setDataRep;
  214. _tourClientListRep = tourClientListRep;
  215. _teamRateRep = teamRateRep;
  216. _hubContext = hubContext;
  217. _usersRep = usersRep;
  218. _juHeApi = juHeApi;
  219. _invertedListRep = invertedListRep;
  220. _visaFeeInfoRep = visaFeeInfoRep;
  221. _ticketBlackCodeRep = ticketBlackCodeRep;
  222. _hotelInquiryRep = hotelInquiryRep;
  223. _threeCodeRepository = threeCodeRepository;
  224. _feeAuditRep = feeAuditRep;
  225. _visaCommissionRep = visaCommissionRep;
  226. _ffrRep = ffrRep;
  227. _opinionaireRep = opinionaireRep;
  228. _currencyInit = new List<CurrencyInfo>()
  229. {
  230. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  231. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  232. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  233. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  234. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  235. };
  236. _portTypeData = new List<int>() { 2, 3 };
  237. _tableorRep = tableorRep;
  238. _enterExitCostDraftRep = enterExitCostDraftRep;
  239. _restaurantRep = restaurantRep;
  240. }
  241. #region 流程管控
  242. /// <summary>
  243. /// 获取团组流程管控信息
  244. /// </summary>
  245. /// <param name="paras">参数Json字符串</param>
  246. /// <returns></returns>
  247. [HttpPost]
  248. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  249. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  250. {
  251. if (string.IsNullOrEmpty(_jsonDto.Paras))
  252. {
  253. return Ok(JsonView(false, "参数为空"));
  254. }
  255. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  256. if (_ScheduleDto != null)
  257. {
  258. if (_ScheduleDto.SearchType == 2)//获取列表
  259. {
  260. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  261. return Ok(JsonView(_grpScheduleViewList));
  262. }
  263. else//获取对象
  264. {
  265. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  266. if (_grpScheduleView != null)
  267. {
  268. return Ok(JsonView(_grpScheduleView));
  269. }
  270. }
  271. }
  272. else
  273. {
  274. return Ok(JsonView(false, "参数反序列化失败"));
  275. }
  276. return Ok(JsonView(false, "暂无数据!"));
  277. }
  278. /// <summary>
  279. /// 修改团组流程管控详细表数据
  280. /// </summary>
  281. /// <param name="paras"></param>
  282. /// <returns></returns>
  283. [HttpPost]
  284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  285. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  286. {
  287. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  288. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  289. .SetColumns(it => it.Duty == _detail.Duty)
  290. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  291. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  292. .SetColumns(it => it.JobContent == _detail.JobContent)
  293. .SetColumns(it => it.Remark == _detail.Remark)
  294. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  295. .Where(s => s.Id == dto.Id)
  296. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  297. .ExecuteCommandAsync();
  298. if (result > 0)
  299. {
  300. return Ok(JsonView(true, "保存成功!"));
  301. }
  302. return Ok(JsonView(false, "保存失败!"));
  303. }
  304. /// <summary>
  305. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  306. /// </summary>
  307. /// <param name="dto"></param>
  308. /// <returns></returns>
  309. [HttpPost]
  310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  311. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  312. {
  313. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  314. _detail.IsDel = 1;
  315. _detail.DeleteUserId = dto.Duty;
  316. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  317. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  318. .SetColumns(it => it.IsDel == _detail.IsDel)
  319. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  320. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  321. .Where(it => it.Id == dto.Id)
  322. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  323. //.WhereColumns(s => s.Id == dto.Id)
  324. .ExecuteCommandAsync();
  325. if (result > 0)
  326. {
  327. return Ok(JsonView(true, "删除成功!"));
  328. }
  329. return Ok(JsonView(false, "删除失败!"));
  330. }
  331. /// <summary>
  332. /// 增加团组流程管控详细表数据
  333. /// </summary>
  334. /// <param name="dto"></param>
  335. /// <returns></returns>
  336. [HttpPost]
  337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  338. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  339. {
  340. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  341. if (DateTime.Now < _detail.ExpectBeginDt)
  342. {
  343. _detail.StepStatus = 0;
  344. }
  345. else
  346. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  347. _detail.StepStatus = 1;
  348. }
  349. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  350. if (result > 0)
  351. {
  352. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  353. return Ok(JsonView(true, "添加成功!", _result));
  354. }
  355. return Ok(JsonView(false, "添加失败!"));
  356. }
  357. #endregion
  358. #region 团组基本信息
  359. /// <summary>
  360. /// 接团信息列表
  361. /// </summary>
  362. /// <param name="dto">团组列表请求dto</param>
  363. /// <returns></returns>
  364. [HttpPost]
  365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  366. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  367. {
  368. var groupData = await _groupRepository.GetGroupList(dto);
  369. if (groupData.Code != 0)
  370. {
  371. return Ok(JsonView(false, groupData.Msg));
  372. }
  373. return Ok(JsonView(groupData.Data));
  374. }
  375. /// <summary>
  376. /// 分页查询团组列表
  377. /// </summary>
  378. /// <param name="dto"></param>
  379. /// <returns></returns>
  380. [HttpPost]
  381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  382. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  383. {
  384. var watch = new Stopwatch();
  385. watch.Start();
  386. RefAsync<int> total = 0;
  387. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  388. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  389. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  390. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  391. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  392. .Distinct()
  393. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  394. watch.Stop();
  395. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  396. }
  397. /// <summary>
  398. /// 接团信息列表 Page
  399. /// </summary>
  400. /// <param name="dto">团组列表请求dto</param>
  401. /// <returns></returns>
  402. [HttpPost]
  403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  404. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  405. {
  406. #region 参数验证
  407. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  408. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  409. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  410. #region 页面操作权限验证
  411. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  412. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  413. #endregion
  414. #endregion
  415. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  416. {
  417. string sqlWhere = string.Empty;
  418. if (dto.IsSure == 0) //未完成
  419. {
  420. sqlWhere += string.Format(@" And IsSure = 0");
  421. }
  422. else if (dto.IsSure == 1) //已完成
  423. {
  424. sqlWhere += string.Format(@" And IsSure = 1");
  425. }
  426. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  427. {
  428. string tj = dto.SearchCriteria;
  429. 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}%')",
  430. tj, tj, tj, tj, tj);
  431. }
  432. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  433. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  434. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  435. JietuanOperator,IsSure,CreateTime,IsBid
  436. From (
  437. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  438. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  439. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  440. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  441. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  442. From Grp_DelegationInfo gdi
  443. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  444. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  445. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  446. Where gdi.IsDel = 0 {0}
  447. ) temp", sqlWhere);
  448. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  449. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  450. #region 处理所属部门
  451. /*
  452. * 1.sq 和 gyy 等显示 市场部
  453. * 2.王鸽和主管及张总还有管理员号统一国交部
  454. * 2-1. 4 管理员 ,21 张海麟
  455. */
  456. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  457. List<int> userIds1 = new List<int>() { 4, 21 };
  458. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  459. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  460. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  461. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  462. .ToList();
  463. foreach (var item in _DelegationList)
  464. {
  465. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  466. }
  467. #endregion
  468. var _view = new
  469. {
  470. PageFuncAuth = pageFunAuthView,
  471. Data = _DelegationList
  472. };
  473. return Ok(JsonView(true, "查询成功!", _view, total));
  474. }
  475. else
  476. {
  477. return Ok(JsonView(false, "查询失败"));
  478. }
  479. }
  480. /// <summary>
  481. /// 团组列表
  482. /// </summary>
  483. /// <returns></returns>
  484. [HttpPost]
  485. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  486. {
  487. #region 参数验证
  488. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  489. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  490. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  491. #region 页面操作权限验证
  492. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  493. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  494. #endregion
  495. #endregion
  496. if (dto.PortType != 1 && dto.PortType != 2)
  497. {
  498. return Ok(JsonView(false, "查询失败!"));
  499. }
  500. string orderbyStr = "order by gdi.CreateTime Desc";
  501. string sqlWhere = string.Empty;
  502. if (dto.IsSure == 0) //未完成
  503. {
  504. sqlWhere += string.Format(@" And IsSure = 0");
  505. }
  506. else if (dto.IsSure == 1) //已完成
  507. {
  508. sqlWhere += string.Format(@" And IsSure = 1");
  509. }
  510. //团组类型
  511. if (dto.TeamDid > 0)
  512. {
  513. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  514. }
  515. //团组名称
  516. if (!string.IsNullOrEmpty(dto.TeamName))
  517. {
  518. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  519. }
  520. //客户名称
  521. if (!string.IsNullOrEmpty(dto.ClientName))
  522. {
  523. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  524. }
  525. //客户单位
  526. if (!string.IsNullOrEmpty(dto.ClientUnit))
  527. {
  528. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  529. }
  530. //出访时间
  531. if (!string.IsNullOrEmpty(dto.visitDataTime))
  532. {
  533. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  534. orderbyStr = "order by gdi.VisitDate";
  535. }
  536. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  537. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  538. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  539. JietuanOperator,IsSure,CreateTime
  540. From (
  541. Select row_number() over({0}) as Row_Number,
  542. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  543. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  544. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  545. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  546. From Grp_DelegationInfo gdi
  547. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  548. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  549. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  550. Where gdi.IsDel = 0 {1}
  551. ) temp ", orderbyStr, sqlWhere);
  552. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  553. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  554. #region 处理所属部门
  555. /*
  556. * 1.sq 和 gyy 等显示 市场部
  557. * 2.王鸽和主管及张总还有管理员号统一国交部
  558. * 2-1. 4 管理员 ,21 张海麟
  559. */
  560. List<int> userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  561. List<int> userIds1 = new List<int>() { 4, 21 };
  562. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  563. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  564. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  565. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  566. .ToList();
  567. foreach (var item in _DelegationList)
  568. {
  569. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  570. }
  571. #endregion
  572. var _view = new
  573. {
  574. PageFuncAuth = pageFunAuthView,
  575. Data = _DelegationList
  576. };
  577. return Ok(JsonView(true, "查询成功!", _view, total));
  578. }
  579. /// <summary>
  580. /// 接团信息详情
  581. /// </summary>
  582. /// <param name="dto">团组info请求dto</param>
  583. /// <returns></returns>
  584. [HttpPost]
  585. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  586. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  587. {
  588. var groupData = await _groupRepository.GetGroupInfo(dto);
  589. if (groupData.Code != 0)
  590. {
  591. return Ok(JsonView(false, groupData.Msg));
  592. }
  593. return Ok(JsonView(groupData.Data));
  594. }
  595. /// <summary>
  596. /// 接团信息 编辑添加
  597. /// 基础信息数据源
  598. /// </summary>
  599. /// <param name="dto"></param>
  600. /// <returns></returns>
  601. [HttpPost]
  602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  603. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  604. {
  605. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  606. if (groupData.Code != 0)
  607. {
  608. return Ok(JsonView(false, groupData.Msg));
  609. }
  610. return Ok(JsonView(groupData.Data));
  611. }
  612. /// <summary>
  613. /// 接团信息 操作(增改)
  614. /// </summary>
  615. /// <param name="dto"></param>
  616. /// <returns></returns>
  617. [HttpPost]
  618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  619. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  620. {
  621. // 创建 Stopwatch 实例
  622. Stopwatch stopwatch = Stopwatch.StartNew();
  623. decimal ffrPrice = 0.00M;
  624. DateTime? visitDt = null;
  625. if (dto.Status == 2)
  626. {
  627. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  628. if (groupInfo != null)
  629. {
  630. ffrPrice = groupInfo.PaymentMoney;
  631. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  632. }
  633. }
  634. var groupData = await _groupRepository.GroupOperation(dto);
  635. if (groupData.Code != 0)
  636. {
  637. return Ok(JsonView(false, groupData.Msg));
  638. }
  639. int diId = 0;
  640. try
  641. {
  642. //添加时 默认加入团组汇率
  643. if (dto.Status == 1) //添加
  644. {
  645. diId = groupData.Data;
  646. //添加默认币种
  647. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  648. //默认分配权限
  649. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  650. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  651. var _managerIds = new List<int>() { 22, 32, 21 };
  652. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  653. if (userIds.Count > 0)
  654. {
  655. userIds.Add(208);
  656. //创建团组管控
  657. GroupStepForDelegation.CreateWorkStep(diId);
  658. //发送消息
  659. string groupName = dto.TeamName;
  660. string createGroupUser = string.Empty;
  661. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  662. if (userInfo != null) createGroupUser = userInfo.CnName;
  663. string title = $"系统通知";
  664. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  665. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  666. }
  667. //默认创建倒推表
  668. await _invertedListRep._Create(dto.UserId, diId);
  669. }
  670. else if (dto.Status == 2)
  671. {
  672. diId = dto.Id;
  673. }
  674. #region 签证人员团组时间通知
  675. #region 计算出访起止时间
  676. var startTime = new DateTime();
  677. var endTime = new DateTime();
  678. if (DateTime.TryParse(dto.VisitDate, out startTime))
  679. {
  680. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  681. }
  682. #endregion
  683. #endregion
  684. #region 团组操作默认添加/修改收款账单
  685. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  686. {
  687. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  688. .Where(x => x.IsDel == 0 &&
  689. x.Diid == diId &&
  690. x.Remark.Equals("预付款")
  691. )
  692. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  693. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  694. .FirstAsync();
  695. ffrInfo = new Fin_ForeignReceivables()
  696. {
  697. Diid = diId,
  698. PriceName = dto.ClientUnit,
  699. Price = dto.PaymentMoney,
  700. Count = 1,
  701. Unit = $"元",
  702. ItemSumPrice = dto.PaymentMoney,
  703. Rate = 1.0000M,
  704. Currency = 836,
  705. AddingWay = 0,
  706. CreateUserId = dto.UserId,
  707. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  708. Remark = $"预付款"
  709. };
  710. if (ffrInfo == null) //Add
  711. {
  712. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  713. }
  714. else //修改
  715. {
  716. await _sqlSugar.Updateable(ffrInfo)
  717. .UpdateColumns(x => new
  718. {
  719. x.PriceName,
  720. x.Price,
  721. x.ItemSumPrice,
  722. x.CreateTime,
  723. x.CreateUserId
  724. })
  725. .WhereColumns(x => x.Id)
  726. .ExecuteCommandAsync();
  727. }
  728. }
  729. #endregion
  730. if (diId > 0)
  731. {
  732. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  733. }
  734. // 停止计时
  735. stopwatch.Stop();
  736. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  737. }
  738. catch (Exception ex)
  739. {
  740. // 停止计时
  741. stopwatch.Stop();
  742. Logs("[response]" + JsonConvert.SerializeObject(dto));
  743. Logs(ex.Message);
  744. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  745. }
  746. // 停止计时
  747. stopwatch.Stop();
  748. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  749. }
  750. /// <summary>
  751. /// 接团流程操作(增改)
  752. /// 安卓端使用 建团时添加客户名单
  753. /// </summary>
  754. /// <param name="dto"></param>
  755. /// <returns></returns>
  756. [HttpPost]
  757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  758. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  759. {
  760. #region 参数验证
  761. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  762. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  763. #region 页面操作权限验证
  764. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  765. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  766. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  767. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  768. #endregion
  769. #endregion
  770. try
  771. {
  772. //_sqlSugar.BeginTran();
  773. decimal ffrPrice = 0.00M;
  774. DateTime? visitDt = null;
  775. if (dto.Status == 2)
  776. {
  777. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  778. if (groupInfo != null)
  779. {
  780. ffrPrice = groupInfo.PaymentMoney;
  781. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  782. }
  783. }
  784. var _dto = new GroupOperationDto();
  785. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  786. var groupData = await _groupRepository.GroupOperation(_dto);
  787. if (groupData.Code != 0)
  788. {
  789. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  790. }
  791. int diId = 0;
  792. //添加时 默认加入团组汇率
  793. if (dto.Status == 1) //添加
  794. {
  795. diId = groupData.Data;
  796. //添加默认币种
  797. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  798. //默认分配权限
  799. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  800. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  801. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  802. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  803. if (userIds.Count > 0)
  804. {
  805. userIds.Add(208);
  806. //创建团组管控
  807. GroupStepForDelegation.CreateWorkStep(diId);
  808. //发送消息
  809. string groupName = dto.TeamName;
  810. string createGroupUser = string.Empty;
  811. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  812. if (userInfo != null) createGroupUser = userInfo.CnName;
  813. string title = $"系统通知";
  814. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  815. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  816. }
  817. #region 应用推送
  818. try
  819. {
  820. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  821. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  822. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  823. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  824. {
  825. List<string> userList = new List<string>() { users.QiyeChatUserId };
  826. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  827. }
  828. }
  829. catch (Exception ex)
  830. {
  831. }
  832. #endregion
  833. //默认创建倒推表
  834. await _invertedListRep._Create(dto.UserId, diId);
  835. }
  836. if (dto.Status == 2)
  837. {
  838. diId = dto.Id;
  839. if (diId == 0)
  840. {
  841. //_sqlSugar.RollbackTran();
  842. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  843. }
  844. }
  845. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  846. if (viewData.Code != 0)
  847. {
  848. //_sqlSugar.RollbackTran();
  849. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  850. }
  851. #region 团组操作默认添加/修改收款账单
  852. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  853. {
  854. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  855. .Where(x => x.IsDel == 0 &&
  856. x.Diid == diId &&
  857. x.Remark.Equals("预付款")
  858. )
  859. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  860. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  861. .FirstAsync();
  862. ffrInfo = new Fin_ForeignReceivables()
  863. {
  864. Diid = diId,
  865. PriceName = dto.ClientUnit,
  866. Price = dto.PaymentMoney,
  867. Count = 1,
  868. Unit = $"元",
  869. ItemSumPrice = dto.PaymentMoney,
  870. Rate = 1.0000M,
  871. Currency = 836,
  872. AddingWay = 0,
  873. CreateUserId = dto.UserId,
  874. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  875. Remark = $"预付款"
  876. };
  877. if (ffrInfo == null) //Add
  878. {
  879. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  880. }
  881. else //修改
  882. {
  883. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  884. .UpdateColumns(x => new
  885. {
  886. x.PriceName,
  887. x.Price,
  888. x.ItemSumPrice,
  889. x.CreateTime,
  890. x.CreateUserId
  891. })
  892. .WhereColumns(x => x.Id)
  893. .ExecuteCommandAsync();
  894. }
  895. }
  896. #endregion
  897. #region 签证人员团组时间通知
  898. #region 计算出访起止时间
  899. var startTime = new DateTime();
  900. var endTime = new DateTime();
  901. if (DateTime.TryParse(dto.VisitDate, out startTime))
  902. {
  903. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  904. }
  905. #endregion
  906. if (diId > 0)
  907. {
  908. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  909. }
  910. #endregion
  911. //_sqlSugar.CommitTran();
  912. return Ok(JsonView(true, "添加成功"));
  913. }
  914. catch (Exception ex)
  915. {
  916. _sqlSugar.RollbackTran();
  917. return Ok(JsonView(false, ex.Message));
  918. }
  919. }
  920. /// <summary>
  921. /// 接团流程操作(增改)
  922. /// 安卓端使用 建团时添加客户名单
  923. /// </summary>
  924. /// <param name="dto"></param>
  925. /// <returns></returns>
  926. [HttpPost]
  927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  928. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  929. {
  930. #region 参数验证
  931. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  932. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  933. #region 页面操作权限验证
  934. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  935. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  936. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  937. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  938. #endregion
  939. #endregion
  940. _sqlSugar.BeginTran();
  941. decimal ffrPrice = 0.00M;
  942. DateTime? visitDt = null;
  943. if (dto.Status == 2)
  944. {
  945. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  946. if (groupInfo != null)
  947. {
  948. ffrPrice = groupInfo.PaymentMoney;
  949. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  950. }
  951. }
  952. var _dto = new GroupOperationDto();
  953. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  954. var groupData = await _groupRepository.GroupOperation(_dto);
  955. if (groupData.Code != 0)
  956. {
  957. _sqlSugar.RollbackTran();
  958. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  959. }
  960. try
  961. {
  962. int diId = 0;
  963. //添加时 默认加入团组汇率
  964. if (dto.Status == 1) //添加
  965. {
  966. diId = groupData.Data;
  967. //添加默认币种
  968. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  969. //默认分配权限
  970. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  971. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  972. List<int> _managerIds = new List<int>() { 21, 22, 32 };
  973. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  974. if (userIds.Count > 0)
  975. {
  976. userIds.Add(208);
  977. //创建团组管控
  978. GroupStepForDelegation.CreateWorkStep(diId);
  979. //发送消息
  980. string groupName = dto.TeamName;
  981. string createGroupUser = string.Empty;
  982. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  983. if (userInfo != null) createGroupUser = userInfo.CnName;
  984. string title = $"系统通知";
  985. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  986. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  987. }
  988. #region 应用推送
  989. try
  990. {
  991. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  992. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  993. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  994. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  995. {
  996. List<string> userList = new List<string>() { users.QiyeChatUserId };
  997. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  998. }
  999. }
  1000. catch (Exception ex)
  1001. {
  1002. _sqlSugar.CommitTran();
  1003. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1004. }
  1005. #endregion
  1006. //默认创建倒推表
  1007. await _invertedListRep._Create(dto.UserId, diId);
  1008. }
  1009. else if (dto.Status == 2)
  1010. {
  1011. diId = dto.Id;
  1012. if (diId == 0)
  1013. {
  1014. _sqlSugar.RollbackTran();
  1015. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1016. }
  1017. }
  1018. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1019. if (viewData.Code != 0)
  1020. {
  1021. _sqlSugar.RollbackTran();
  1022. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1023. }
  1024. #region 团组操作默认添加/修改收款账单
  1025. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1026. {
  1027. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1028. .Where(x => x.IsDel == 0 &&
  1029. x.Diid == diId &&
  1030. x.Remark.Equals("预付款")
  1031. )
  1032. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1033. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1034. .FirstAsync();
  1035. ffrInfo = new Fin_ForeignReceivables()
  1036. {
  1037. Diid = diId,
  1038. PriceName = dto.ClientUnit,
  1039. Price = dto.PaymentMoney,
  1040. Count = 1,
  1041. Unit = $"元",
  1042. ItemSumPrice = dto.PaymentMoney,
  1043. Rate = 1.0000M,
  1044. Currency = 836,
  1045. AddingWay = 0,
  1046. CreateUserId = dto.UserId,
  1047. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1048. Remark = $"预付款"
  1049. };
  1050. if (ffrInfo == null) //Add
  1051. {
  1052. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1053. }
  1054. else //修改
  1055. {
  1056. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1057. .UpdateColumns(x => new
  1058. {
  1059. x.PriceName,
  1060. x.Price,
  1061. x.ItemSumPrice,
  1062. x.CreateTime,
  1063. x.CreateUserId
  1064. })
  1065. .WhereColumns(x => x.Id)
  1066. .ExecuteCommandAsync();
  1067. }
  1068. }
  1069. #endregion
  1070. #region 签证人员团组时间通知
  1071. #region 计算出访起止时间
  1072. var startTime = new DateTime();
  1073. var endTime = new DateTime();
  1074. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1075. {
  1076. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1077. }
  1078. #endregion
  1079. if (diId > 0)
  1080. {
  1081. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1082. }
  1083. #endregion
  1084. _sqlSugar.CommitTran();
  1085. return Ok(JsonView(true));
  1086. }
  1087. catch (Exception ex)
  1088. {
  1089. _sqlSugar.RollbackTran();
  1090. return Ok(JsonView(false, ex.Message));
  1091. }
  1092. }
  1093. /// <summary>
  1094. /// 接团信息 操作(删除)
  1095. /// </summary>
  1096. /// <param name="dto"></param>
  1097. /// <returns></returns>
  1098. [HttpPost]
  1099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1100. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1101. {
  1102. var diId = dto.Id;
  1103. if (diId < 1) return Ok(JsonView(false,MsgTips.Id));
  1104. #region 删除 验证 (费用录入、出入境费用、收款账单)
  1105. //var feeCount = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1106. //var eccCount = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1107. //var frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1108. //if (feeCount > 0 || feeCount > 0 || feeCount > 0) return Ok(JsonView(false, "该团组存在费用不可删除!"));
  1109. #endregion
  1110. var groupData = await _groupRepository.GroupDel(dto);
  1111. if (groupData.Code != 0)
  1112. {
  1113. return Ok(JsonView(false, groupData.Msg));
  1114. }
  1115. return Ok(JsonView(true));
  1116. }
  1117. /// <summary>
  1118. /// 获取团组销售报价号
  1119. /// 团组添加时 使用
  1120. /// </summary>
  1121. /// <returns></returns>
  1122. [HttpPost]
  1123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1124. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1125. {
  1126. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1127. if (groupData.Code != 0)
  1128. {
  1129. return Ok(JsonView(false, groupData.Msg));
  1130. }
  1131. object salesQuoteNo = new
  1132. {
  1133. SalesQuoteNo = groupData.Data
  1134. };
  1135. return Ok(JsonView(salesQuoteNo));
  1136. }
  1137. /// <summary>
  1138. /// 设置确认出团
  1139. /// </summary>
  1140. /// <param name="dto"></param>
  1141. /// <returns></returns>
  1142. [HttpPost]
  1143. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1144. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1145. {
  1146. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1147. if (groupData.Code != 0)
  1148. {
  1149. return Ok(JsonView(false, groupData.Msg));
  1150. }
  1151. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1152. #region OA消息推送
  1153. try
  1154. {
  1155. string groupName = groupInfo.TeamName;
  1156. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1157. string title = $"系统通知";
  1158. string content = $"团组[{groupName}]已确认出团!";
  1159. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1160. }
  1161. catch (Exception ex)
  1162. {
  1163. }
  1164. #endregion
  1165. #region 应用推送
  1166. try
  1167. {
  1168. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1169. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1170. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1171. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1172. {
  1173. List<string> userList = new List<string>() { users.QiyeChatUserId };
  1174. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1175. }
  1176. }
  1177. catch (Exception ex)
  1178. {
  1179. }
  1180. #endregion
  1181. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1182. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1183. }
  1184. /// <summary>
  1185. /// 获取团组名称data And 签证国别Data
  1186. /// </summary>
  1187. /// <param name="dto"></param>
  1188. /// <returns></returns>
  1189. [HttpPost]
  1190. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1191. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1192. {
  1193. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1194. if (groupData.Code != 0)
  1195. {
  1196. return Ok(JsonView(false, groupData.Msg));
  1197. }
  1198. return Ok(JsonView(groupData.Data));
  1199. }
  1200. /// <summary>
  1201. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1202. /// </summary>
  1203. /// <returns></returns>
  1204. [HttpPost]
  1205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1206. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1207. {
  1208. try
  1209. {
  1210. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1211. if (groupData.Code != 0)
  1212. {
  1213. return Ok(JsonView(false, groupData.Msg));
  1214. }
  1215. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1216. }
  1217. catch (Exception ex)
  1218. {
  1219. return Ok(JsonView(false, "程序错误!"));
  1220. throw;
  1221. }
  1222. }
  1223. /// <summary>
  1224. /// 团组清单 Excel
  1225. /// </summary>
  1226. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1227. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1228. /// <returns></returns>
  1229. [HttpGet]
  1230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1231. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1232. {
  1233. DateTime _beginDt, _endDt;
  1234. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out _beginDt),
  1235. endBool = DateTime.TryParse($"{endDt} 23:59:59", out _endDt);
  1236. if (!beginBool && !endBool)
  1237. {
  1238. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1239. }
  1240. string sql = string.Format(@"
  1241. SELECT
  1242. ROW_NUMBER,
  1243. Id,
  1244. SalesQuoteNo,
  1245. TourCode,
  1246. TeamTypeId,
  1247. TeamType,
  1248. TeamLevId,
  1249. TeamLev,
  1250. TeamName,
  1251. ClientName,
  1252. ClientUnit,
  1253. VisitDate,
  1254. VisitDays,
  1255. VisitPNumber,
  1256. JietuanOperatorId,
  1257. JietuanOperator,
  1258. IsSure,
  1259. CreateUserName,
  1260. IsBid
  1261. FROM
  1262. (
  1263. SELECT
  1264. ROW_NUMBER() OVER(
  1265. ORDER BY
  1266. gdi.CreateTime Desc
  1267. ) AS ROW_NUMBER,
  1268. gdi.Id,
  1269. SalesQuoteNo,
  1270. TourCode,
  1271. ssd.Id TeamTypeId,
  1272. ssd.Name TeamType,
  1273. ssd1.Id TeamLevId,
  1274. ssd1.Name TeamLev,
  1275. TeamName,
  1276. ClientName,
  1277. ClientUnit,
  1278. VisitDate,
  1279. VisitDays,
  1280. VisitPNumber,
  1281. JietuanOperator JietuanOperatorId,
  1282. su.CnName JietuanOperator,
  1283. IsSure,
  1284. gdi.CreateTime,
  1285. su1.CnName As CreateUserName,
  1286. gdi.IsBid
  1287. FROM
  1288. Grp_DelegationInfo gdi
  1289. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1290. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1291. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1292. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1293. WHERE
  1294. gdi.IsDel = 0
  1295. AND gdi.IsBid = 0
  1296. AND gdi.CreateTime BETWEEN '{0}' AND '{1}'
  1297. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1298. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1299. #region 处理所属部门
  1300. /*
  1301. * 1.sq 和 gyy 等显示 市场部
  1302. * 2.王鸽和主管及张总还有管理员号统一国交部
  1303. * 2-1. 4 管理员 ,21 张海麟
  1304. */
  1305. List<int> userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1306. List<int> userIds1 = new List<int>() { 4, 21 };
  1307. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1308. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1309. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1310. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1311. .ToListAsync();
  1312. var droupIds = groupList.Select(it => it.Id).ToList();
  1313. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1314. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1315. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1316. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1317. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1318. {
  1319. DiId = tcl.DiId,
  1320. LastName = dc.LastName,
  1321. FirstName = dc.FirstName,
  1322. Sex = dc.Sex,
  1323. Birthday = dc.BirthDay,
  1324. Company = cc.CompanyFullName,
  1325. Job = dc.Job,
  1326. CreateTime = tcl.CreateTime,
  1327. })
  1328. .ToList();
  1329. foreach (var item in groupList)
  1330. {
  1331. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1332. string groupFirstName = "";
  1333. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  1334. if (currDatas.Any())
  1335. {
  1336. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  1337. }
  1338. item.GroupFirst = groupFirstName;
  1339. }
  1340. #endregion
  1341. #region Excel
  1342. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  1343. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  1344. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  1345. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  1346. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  1347. //载入模板
  1348. WorkbookDesigner designer = new WorkbookDesigner();
  1349. designer.Workbook = new Workbook($"{tempPath}团组清单模板.xlsx");
  1350. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  1351. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  1352. dt.TableName = "GroupList";
  1353. designer.SetDataSource(dt);
  1354. designer.Process();
  1355. if (!Directory.Exists(savePath))
  1356. {
  1357. Directory.CreateDirectory(savePath);
  1358. }
  1359. string serverPath = $"{savePath}{fileName}";
  1360. designer.Workbook.Save(serverPath);
  1361. string rst = $"{servicePath}{ftpPath}{fileName}";
  1362. #endregion
  1363. return Ok(JsonView(true, "操作成功!", rst));
  1364. }
  1365. #endregion
  1366. #region 团组&签证
  1367. /// <summary>
  1368. /// 根据团组Id获取签证客户信息List
  1369. /// </summary>
  1370. /// <param name="dto">请求dto</param>
  1371. /// <returns></returns>
  1372. [HttpPost]
  1373. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1374. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  1375. {
  1376. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  1377. if (groupData.Code != 0)
  1378. {
  1379. return Ok(JsonView(false, groupData.Msg));
  1380. }
  1381. return Ok(JsonView(groupData.Data));
  1382. }
  1383. /// <summary>
  1384. /// IOS获取团组签证拍照上传进度01(团组列表)
  1385. /// </summary>
  1386. /// <param name="dto">请求dto</param>
  1387. /// <returns></returns>
  1388. [HttpPost]
  1389. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1390. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  1391. {
  1392. if (dto == null)
  1393. {
  1394. return Ok(JsonView(false, "参数为空"));
  1395. }
  1396. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  1397. return Ok(JsonView(visaList));
  1398. }
  1399. /// <summary>
  1400. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  1401. /// </summary>
  1402. /// <returns></returns>
  1403. [HttpPost]
  1404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1405. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  1406. {
  1407. if (dto == null)
  1408. {
  1409. return Ok(JsonView(false, "请求错误:"));
  1410. }
  1411. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  1412. return Ok(JsonView(list));
  1413. }
  1414. /// <summary>
  1415. /// IOS获取团组签证拍照上传进度03(相册)
  1416. /// </summary>
  1417. /// <returns></returns>
  1418. [HttpPost]
  1419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1420. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  1421. {
  1422. if (dto == null)
  1423. {
  1424. return Ok(JsonView(false, "请求错误:"));
  1425. }
  1426. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  1427. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  1428. list.ForEach(s => s.url = url);
  1429. return Ok(JsonView(list));
  1430. }
  1431. /// <summary>
  1432. /// IOS获取团组签证拍照上传进度04(图片上传)
  1433. /// </summary>
  1434. /// <param name="dto"></param>
  1435. /// <returns></returns>
  1436. [HttpPost]
  1437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1438. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  1439. {
  1440. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  1441. //if (!string.IsNullOrEmpty(result))
  1442. //{
  1443. //}
  1444. //else {
  1445. // return Ok(JsonView(false, "上传失败"));
  1446. //}
  1447. DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1448. int sucNum = 0;
  1449. try
  1450. {
  1451. foreach (var item in dto.base64DataList)
  1452. {
  1453. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  1454. string result = decodeBase64ToImage(item, imageName);
  1455. if (!string.IsNullOrEmpty(result))
  1456. {
  1457. Grp_VisaProgressCustomerPicture pic = new Grp_VisaProgressCustomerPicture();
  1458. pic.CreateUserId = dto.CreateUserId;
  1459. pic.PicName = imageName;
  1460. pic.PicPath = result;
  1461. pic.VisaProgressCustomerId = dto.visaProgressCustomerId;
  1462. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  1463. if (insertResult > 0)
  1464. {
  1465. sucNum++;
  1466. }
  1467. }
  1468. }
  1469. }
  1470. catch (Exception ex)
  1471. {
  1472. return Ok(JsonView(false, ex.Message));
  1473. }
  1474. string msg = string.Format(@"成功上传{0}张", sucNum);
  1475. return Ok(JsonView(true, msg));
  1476. }
  1477. private string decodeBase64ToImage(string base64DataURL, string imgName)
  1478. {
  1479. string filename = "";//声明一个string类型的相对路径
  1480. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  1481. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  1482. try//会有异常抛出,try,catch一下
  1483. {
  1484. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  1485. System.IO.MemoryStream ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  1486. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  1487. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  1488. //文件名称
  1489. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  1490. //上传的文件的路径
  1491. string filePath = "";
  1492. if (!Directory.Exists(fileDir))
  1493. {
  1494. Directory.CreateDirectory(fileDir);
  1495. }
  1496. //上传的文件的路径
  1497. filePath = fileDir + filename;
  1498. //string url = HttpRuntime.AppDomainAppPath.ToString();
  1499. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  1500. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  1501. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  1502. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  1503. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  1504. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  1505. ms.Close();//关闭当前流,并释放所有与之关联的资源
  1506. bitmap.Dispose();
  1507. }
  1508. catch (Exception e)
  1509. {
  1510. string massage = e.Message;
  1511. Logs("IOS图片上传Error:" + massage);
  1512. //filename = e.Message;
  1513. }
  1514. return filename;//返回相对路径
  1515. }
  1516. /// <summary>
  1517. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  1518. /// </summary>
  1519. /// <param name="dto"></param>
  1520. /// <returns></returns>
  1521. [HttpPost]
  1522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1523. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  1524. {
  1525. if (dto == null)
  1526. {
  1527. return Ok(JsonView(false, "请求错误:"));
  1528. }
  1529. string msg = "参数错误";
  1530. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  1531. {
  1532. try
  1533. {
  1534. //_delegationVisaRep.BeginTran();
  1535. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  1536. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  1537. .Where(s => s.Id == dto.visaProgressCustomerId)
  1538. .ExecuteCommandAsync();
  1539. if (updCount > 0 && dto.publishCode == 1)
  1540. {
  1541. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  1542. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  1543. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  1544. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  1545. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  1546. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  1547. if (groupData == null)
  1548. {
  1549. _delegationVisaRep.RollbackTran();
  1550. }
  1551. string title = string.Format(@"[签证进度更新]");
  1552. string content = string.Format(@"测试文本");
  1553. bool rst = await _message.AddMsg(new MessageDto()
  1554. {
  1555. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  1556. IssuerId = dto.publisher,
  1557. Title = title,
  1558. Content = content,
  1559. ReleaseTime = DateTime.Now,
  1560. UIdList = new List<int> {
  1561. 234
  1562. }
  1563. });
  1564. if (rst)
  1565. {
  1566. return Ok(JsonView(true, "发送通知成功"));
  1567. }
  1568. }
  1569. //_delegationVisaRep.CommitTran();
  1570. }
  1571. catch (Exception)
  1572. {
  1573. //_delegationVisaRep.RollbackTran();
  1574. }
  1575. }
  1576. return Ok(JsonView(true, msg));
  1577. }
  1578. #endregion
  1579. #region 团组任务分配
  1580. /// <summary>
  1581. /// 团组任务分配初始化
  1582. /// </summary>
  1583. /// <param name="dto"></param>
  1584. /// <returns></returns>
  1585. [HttpPost]
  1586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1587. public async Task<IActionResult> GetTaskAssignmen()
  1588. {
  1589. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  1590. if (groupData.Code != 0)
  1591. {
  1592. return Ok(JsonView(false, groupData.Msg));
  1593. }
  1594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1595. }
  1596. /// <summary>
  1597. /// 团组任务分配查询
  1598. /// </summary>
  1599. /// <param name="dto"></param>
  1600. /// <returns></returns>
  1601. [HttpPost]
  1602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1603. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  1604. {
  1605. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  1606. if (groupData.Code != 0)
  1607. {
  1608. return Ok(JsonView(false, groupData.Msg));
  1609. }
  1610. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1611. }
  1612. /// <summary>
  1613. /// 团组任务分配操作
  1614. /// </summary>
  1615. /// <param name="dto"></param>
  1616. /// <returns></returns>
  1617. [HttpPost]
  1618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1619. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  1620. {
  1621. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  1622. if (groupData.Code != 0)
  1623. {
  1624. return Ok(JsonView(false, groupData.Msg));
  1625. }
  1626. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1627. }
  1628. /// <summary>
  1629. /// 团组任务分配
  1630. /// 批量分配
  1631. /// 查询团组
  1632. /// </summary>
  1633. /// <param name="dto"></param>
  1634. /// <returns></returns>
  1635. [HttpPost]
  1636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1637. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  1638. {
  1639. //参数验证
  1640. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  1641. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  1642. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  1643. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  1644. }
  1645. /// <summary>
  1646. /// 团组任务分配
  1647. /// 批量分配
  1648. /// </summary>
  1649. /// <param name="dto"></param>
  1650. /// <returns></returns>
  1651. [HttpPost]
  1652. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1653. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  1654. {
  1655. //参数验证
  1656. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  1657. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  1658. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  1659. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  1660. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  1661. }
  1662. #endregion
  1663. #region 团组费用审核
  1664. /// <summary>
  1665. /// 费用审核
  1666. /// 团组列表 Page
  1667. /// </summary>
  1668. /// <param name="_dto">团组列表请求dto</param>
  1669. /// <returns></returns>
  1670. [HttpPost]
  1671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1672. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  1673. {
  1674. #region 参数验证
  1675. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1676. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1677. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  1678. #region 页面操作权限验证
  1679. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1680. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1681. #endregion
  1682. #endregion
  1683. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  1684. {
  1685. string sqlWhere = string.Empty;
  1686. if (_dto.IsSure == 0) //未完成
  1687. {
  1688. sqlWhere += string.Format(@" And IsSure = 0");
  1689. }
  1690. else if (_dto.IsSure == 1) //已完成
  1691. {
  1692. sqlWhere += string.Format(@" And IsSure = 1");
  1693. }
  1694. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  1695. {
  1696. string tj = _dto.SearchCriteria;
  1697. 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}%')",
  1698. tj, tj, tj, tj, tj);
  1699. }
  1700. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1701. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  1702. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  1703. From (
  1704. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  1705. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  1706. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  1707. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1708. From Grp_DelegationInfo gdi
  1709. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1710. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1711. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1712. Where gdi.IsDel = 0 {0}
  1713. ) temp ", sqlWhere);
  1714. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1715. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  1716. var _view = new
  1717. {
  1718. PageFuncAuth = pageFunAuthView,
  1719. Data = _DelegationList
  1720. };
  1721. return Ok(JsonView(true, "查询成功!", _view, total));
  1722. }
  1723. else
  1724. {
  1725. return Ok(JsonView(false, "查询失败"));
  1726. }
  1727. }
  1728. /// <summary>
  1729. /// 获取团组费用审核
  1730. /// </summary>
  1731. /// <param name="paras">参数Json字符串</param>
  1732. /// <returns></returns>
  1733. [HttpPost]
  1734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1735. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  1736. {
  1737. try
  1738. {
  1739. #region 参数验证
  1740. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1741. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1742. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  1743. #region 页面操作权限验证
  1744. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  1745. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1746. #endregion
  1747. #endregion
  1748. var _view = new Grp_CreditCardPaymentView();
  1749. var clientNameList = getSimplClientList(_dto.DiId);
  1750. #region 费用清单
  1751. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  1752. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  1753. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  1754. var entityList = _groupRepository .Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  1755. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  1756. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  1757. /*
  1758. * 76://酒店预订
  1759. */
  1760. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1761. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1762. /*
  1763. * 79://车/导游地接
  1764. */
  1765. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1766. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1767. /*
  1768. * 80: //签证
  1769. */
  1770. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1771. /*
  1772. *81: //邀请/公务活动
  1773. */
  1774. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1775. /*
  1776. * 82: //团组客户保险
  1777. */
  1778. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1779. /*
  1780. * Lable = 85 机票预订
  1781. */
  1782. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1783. /*
  1784. * 85 机票预定
  1785. */
  1786. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1787. /*
  1788. * 98 其他款项
  1789. */
  1790. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1791. /*
  1792. * 285:收款退还
  1793. */
  1794. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1795. /*
  1796. * 1015: //超支费用
  1797. */
  1798. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  1799. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  1800. /*
  1801. * 币种信息
  1802. */
  1803. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  1804. /*
  1805. * 车/导游地接 费用类型
  1806. */
  1807. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  1808. /*
  1809. * 车/导游地接 费用类型
  1810. */
  1811. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  1812. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  1813. /*
  1814. * 用户信息
  1815. */
  1816. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  1817. /*
  1818. * 费用模块
  1819. */
  1820. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  1821. string priceModule = string.Empty;
  1822. if (sdPriceName != null)
  1823. {
  1824. priceModule = sdPriceName.Name;
  1825. }
  1826. /*
  1827. * 成本信息
  1828. */
  1829. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  1830. decimal _groupRate = 0.0000M;
  1831. string _groupCurrencyCode = "-";
  1832. if (groupCost != null)
  1833. {
  1834. _groupRate = groupCost.Rate;
  1835. if (int.TryParse(groupCost.Currency, out int _currency))
  1836. {
  1837. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  1838. }
  1839. else _groupCurrencyCode = groupCost.Currency;
  1840. }
  1841. string costContentSql = $"Select * From Grp_GroupCost";
  1842. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  1843. //处理日期为空的天数
  1844. for (int i = 0; i < groupCostDetails.Count; i++)
  1845. if (i != 0)
  1846. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  1847. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  1848. /*
  1849. * 处理详情数据
  1850. */
  1851. foreach (var entity in entityList)
  1852. {
  1853. var _detail = new Grp_CreditCardPaymentDetailView();
  1854. _detail.Id = entity.Id;
  1855. _detail.PriceName = priceModule;
  1856. _detail.PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-";
  1857. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  1858. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  1859. //处理金额
  1860. if (entity.CTable == 1015)
  1861. {
  1862. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  1863. if (czInfo != null)
  1864. {
  1865. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  1866. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  1867. }
  1868. }
  1869. /*
  1870. * 应付款金额
  1871. */
  1872. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  1873. string PaymentCurrency_WaitPay = "Unknown";
  1874. string hotelCurrncyCode = "Unknown";
  1875. string hotelCurrncyName = "Unknown";
  1876. if (sdPaymentCurrency_WaitPay != null)
  1877. {
  1878. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  1879. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  1880. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  1881. if (hotelCurrncyCode.Equals("CNY"))
  1882. {
  1883. entity.DayRate = 1.0000M;
  1884. }
  1885. }
  1886. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1887. /*
  1888. * 此次付款金额
  1889. */
  1890. decimal CurrPayStr = 0.00M,
  1891. OriginalCurrPay = 0.00M;
  1892. if (entity.PayPercentage == 0)
  1893. {
  1894. if (entity.PayThenMoney != 0)
  1895. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  1896. }
  1897. else
  1898. {
  1899. if (entity.PayMoney != 0)
  1900. {
  1901. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  1902. }
  1903. }
  1904. //if (_dto.Label == 79)
  1905. //{
  1906. // string original = string.Empty;
  1907. // if (hotelCurrncyCode.Equals("CNY"))
  1908. // {
  1909. // OriginalCurrPay = CurrPayStr;
  1910. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1911. // }
  1912. // else
  1913. // {
  1914. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1915. // //760 EUR(7600.00 CNY)
  1916. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1917. // }
  1918. //}
  1919. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1920. string original = string.Empty;
  1921. if (hotelCurrncyCode.Equals("CNY"))
  1922. {
  1923. OriginalCurrPay = CurrPayStr;
  1924. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  1925. }
  1926. else
  1927. {
  1928. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  1929. //760 EUR(7600.00 CNY)
  1930. _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  1931. }
  1932. /*
  1933. * 剩余尾款
  1934. */
  1935. decimal BalanceStr = 0;
  1936. if (CurrPayStr != 0)
  1937. {
  1938. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  1939. BalanceStr = 0;
  1940. else
  1941. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  1942. }
  1943. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  1944. /*
  1945. * Bus名称
  1946. */
  1947. _detail.BusName = "待增加";
  1948. /*
  1949. *费用所属
  1950. */
  1951. switch (entity.CTable)
  1952. {
  1953. case 76://酒店预订
  1954. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  1955. if (hotelReservations != null)
  1956. {
  1957. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  1958. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  1959. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  1960. string roomFeeStr = "", roomFeestr1 = "";
  1961. //是否比较房型价格
  1962. bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  1963. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  1964. roomFeeStr += $"<br/>";
  1965. var roomTotal = 0.00M;
  1966. if (hotelReservations.SingleRoomPrice > 0)
  1967. {
  1968. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * (int)hotel_days;
  1969. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice.ToString("#0.00")} * {hotelReservations.SingleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1970. __isSingle = true;
  1971. roomTotal += fee;
  1972. }
  1973. if (hotelReservations.DoubleRoomPrice > 0)
  1974. {
  1975. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * (int)hotel_days;
  1976. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice.ToString("#0.00")} * {hotelReservations.DoubleRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1977. __isDouble = true;
  1978. roomTotal += fee;
  1979. }
  1980. if (hotelReservations.SuiteRoomPrice > 0)
  1981. {
  1982. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * (int)hotel_days;
  1983. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice.ToString("#0.00")} * {hotelReservations.SuiteRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1984. __isSuite = true;
  1985. roomTotal += fee;
  1986. }
  1987. if (hotelReservations.OtherRoomPrice > 0)
  1988. {
  1989. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * (int)hotel_days;
  1990. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice.ToString("#0.00")} * {hotelReservations.OtherRoomCount}间 * {(int)hotel_days}晚 = {fee.ToString("#0.00")}<br/>";
  1991. __isOther = true;
  1992. roomTotal += fee;
  1993. }
  1994. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal.ToString("#0.00")}";
  1995. else roomFeeStr += " 0.00 * 0";
  1996. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  1997. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  1998. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  1999. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  2000. /*
  2001. * 费用类型
  2002. * 1:房费
  2003. * 2:早餐
  2004. * 3:地税
  2005. * 4:城市税
  2006. * </summary>
  2007. */
  2008. //地税
  2009. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  2010. if (governmentRentData != null)
  2011. {
  2012. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  2013. governmentRentFee = governmentRentData.Price;
  2014. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  2015. if (governmentRentCurrData != null)
  2016. {
  2017. governmentRentCode = governmentRentCurrData.Name;
  2018. governmentRentName = $"({governmentRentCurrData.Remark})";
  2019. }
  2020. }
  2021. //城市税
  2022. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  2023. if (cityTaxData != null)
  2024. {
  2025. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  2026. cityTaxFee = cityTaxData.Price;
  2027. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  2028. if (cityTaxCurrData != null)
  2029. {
  2030. cityTaxCode = cityTaxCurrData.Name;
  2031. cityTaxName = $"({cityTaxCurrData.Remark})";
  2032. }
  2033. }
  2034. //酒店早餐
  2035. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  2036. if (breakfastData != null)
  2037. {
  2038. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  2039. breakfastFee = breakfastData.Price;
  2040. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  2041. if (breakfastCurrData != null)
  2042. {
  2043. breakfastCode = breakfastCurrData.Name;
  2044. breakfastName = $"({breakfastCurrData.Remark})";
  2045. }
  2046. }
  2047. //房间费用
  2048. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  2049. if (roomData != null)
  2050. {
  2051. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  2052. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  2053. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  2054. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  2055. roomFee = roomData.Price;
  2056. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  2057. if (roomCurrData != null)
  2058. {
  2059. roomCode = roomCurrData.Name;
  2060. roomName = $"({roomCurrData.Remark})";
  2061. }
  2062. }
  2063. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  2064. string hotelCostStr = "";
  2065. decimal hotelCsotTotal = 0.00M;
  2066. if (groupCost != null)
  2067. {
  2068. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  2069. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate.ToString("#0.0000")})<br/>";
  2070. }
  2071. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  2072. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  2073. string hotelCost_day = "";
  2074. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  2075. foreach (var item in hotelCostDetails1)
  2076. {
  2077. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  2078. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  2079. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee).ToString("#0.00")}";
  2080. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  2081. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee).ToString("#0.00")}";
  2082. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  2083. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee).ToString("#0.00")}";
  2084. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  2085. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee).ToString("#0.00")}";
  2086. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  2087. hotelCost_day += @$"<br/>";
  2088. }
  2089. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  2090. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee.ToString("#0.00")} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  2091. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee.ToString("#0.00")} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  2092. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee.ToString("#0.00")} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate.ToString("#0.0000")} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  2093. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  2094. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  2095. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  2096. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  2097. $"房间说明: {hotelReservations.Remark} <br/>" +
  2098. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  2099. $"{hotelBreakfastStr}" +
  2100. $"{hotelGovernmentRentStr}" +
  2101. $"{hotelCityTaxStr}";
  2102. _detail.PriceNameContent = hotelReservations.HotelName;
  2103. }
  2104. break;
  2105. case 79://车/导游地接
  2106. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2107. if (touristGuideGroundReservations != null)
  2108. {
  2109. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  2110. {
  2111. _detail.BusName = touristGuideGroundReservations.BusName;
  2112. }
  2113. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  2114. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  2115. //if (isInt)
  2116. //{
  2117. // var cityInfo = cityData.Find(it => it.Id == cityId);
  2118. // if (cityInfo != null)
  2119. // {
  2120. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  2121. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  2122. // if (carFeeItem != null)
  2123. // {
  2124. // nameContent += $@"({carFeeItem.Name})";
  2125. // }
  2126. // _detail.PriceNameContent = nameContent;
  2127. // }
  2128. //}
  2129. //else
  2130. //{
  2131. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  2132. //}
  2133. var touristGuideGroundReservationsContents =
  2134. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  2135. string priceMsg = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  2136. foreach (var item in touristGuideGroundReservationsContents)
  2137. {
  2138. string typeName = "Unknown";
  2139. string carCurrencyCode = "Unknown";
  2140. string carCurrencyName = "Unknown";
  2141. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  2142. if (carTypeData != null) typeName = carTypeData.Name;
  2143. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  2144. if (currencyData != null)
  2145. {
  2146. carCurrencyCode = currencyData.Name;
  2147. carCurrencyName = currencyData.Remark;
  2148. }
  2149. //op、成本 币种是否一致
  2150. bool IsCurrencyAgreement = false;
  2151. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  2152. string opCostStr = string.Empty;
  2153. decimal opCostTypePrice = 0.00M;
  2154. #region 处理成本各项费用
  2155. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  2156. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  2157. if (opCost.Count > 0)
  2158. {
  2159. switch (item.SId)
  2160. {
  2161. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  2162. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  2163. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  2164. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  2165. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  2166. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  2167. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  2168. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  2169. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  2170. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  2171. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  2172. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  2173. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  2174. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  2175. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  2176. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  2177. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  2178. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  2179. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  2180. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  2181. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  2182. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  2183. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  2184. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  2185. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  2186. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  2187. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  2188. }
  2189. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice.ToString("#0.00")} {_groupCurrencyCode}(汇率:{_groupRate.ToString("#0.0000")})";
  2190. if (!IsCurrencyAgreement) opCostStr += $" ≈ {(opCostTypePrice * _groupRate).ToString("#0.00")} CNY";
  2191. }
  2192. #endregion
  2193. string opTypeStr = $"{typeName}:{item.Price.ToString("#0.00")} {carCurrencyCode}(汇率:{entity.DayRate.ToString("#0.0000")})";
  2194. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {(item.Price * entity.DayRate).ToString("#0.00")} CNY";
  2195. priceMsg += $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  2196. $"{opTypeStr} {opCostStr}<br/>" +
  2197. $"明细:{item.PriceContent ?? "-"}<br/>" +
  2198. $"备注:{item.Remark ?? "-"}<br/><br/>";
  2199. }
  2200. _detail.PriceMsgContent = priceMsg;
  2201. }
  2202. break;
  2203. case 80: //签证
  2204. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  2205. if (visaInfo != null)
  2206. {
  2207. string visaName = getClientNameStr1(clientNameList, visaInfo.VisaClient);
  2208. _detail.PriceNameContent = visaInfo.VisaDescription;
  2209. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  2210. }
  2211. break;
  2212. case 81: //邀请/公务活动
  2213. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  2214. if (_ioa != null)
  2215. {
  2216. string inviteCurrName = "Unknown", //邀请费用币种 Name
  2217. inviteCurrCode = "Unknown", //邀请费用币种 Code
  2218. sendCurrName = "Unknown", //快递费用币种 Name
  2219. sendCurrCode = "Unknown", //快递费用币种 Code
  2220. eventsCurrName = "Unknown", //公务活动费币种 Name
  2221. eventsCurrCode = "Unknown", //公务活动费币种 Code
  2222. translateCurrName = "Unknown", //公务翻译费 Name
  2223. translateCurrCode = "Unknown"; //公务翻译费 Code
  2224. #region 处理费用币种
  2225. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  2226. if (inviteCurrData != null)
  2227. {
  2228. inviteCurrName = inviteCurrData.Remark;
  2229. inviteCurrCode = inviteCurrData.Name;
  2230. }
  2231. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  2232. if (sendCurrData != null)
  2233. {
  2234. sendCurrName = sendCurrData.Remark;
  2235. sendCurrCode = sendCurrData.Name;
  2236. }
  2237. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  2238. if (eventsCurrData != null)
  2239. {
  2240. eventsCurrName = eventsCurrData.Remark;
  2241. eventsCurrCode = eventsCurrData.Name;
  2242. }
  2243. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  2244. if (translateCurrData != null)
  2245. {
  2246. translateCurrName = translateCurrData.Remark;
  2247. translateCurrCode = translateCurrData.Name;
  2248. }
  2249. #endregion
  2250. _detail.PriceNameContent = _ioa.InviterArea;
  2251. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost.ToString("#0.00")} {inviteCurrCode}({inviteCurrName})<br/>" +
  2252. $@"快递费用:{_ioa.SendCost.ToString("#0.00")} {sendCurrCode}({sendCurrName})<br/>" +
  2253. $@"公务活动费:{_ioa.EventsCost.ToString("#0.00")} {eventsCurrCode}({eventsCurrName})<br/>" +
  2254. $@"公务翻译费:{_ioa.TranslateCost.ToString("#0.00")} {translateCurrCode}({translateCurrName})<br/>" +
  2255. $@"备注:" + _ioa.Remark + "<br/>";
  2256. }
  2257. break;
  2258. case 82: //团组客户保险
  2259. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  2260. if (customers != null)
  2261. {
  2262. _detail.PriceNameContent = getClientNameStr(clientNameList, customers.ClientName);
  2263. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  2264. }
  2265. break;
  2266. case 85: //机票预订
  2267. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  2268. if (jpRes != null)
  2269. {
  2270. string FlightsDescription = jpRes.FlightsDescription;
  2271. string PriceDescription = jpRes.PriceDescription;
  2272. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  2273. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  2274. }
  2275. break;
  2276. case 98://其他款项
  2277. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  2278. if (gdpRes != null)
  2279. {
  2280. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  2281. _detail.PriceNameContent = gdpRes.PriceName;
  2282. }
  2283. break;
  2284. case 285://收款退还
  2285. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  2286. if (refundAndOtherMoney != null)
  2287. {
  2288. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  2289. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  2290. }
  2291. break;
  2292. case 751://酒店早餐
  2293. break;
  2294. case 1015://超支费用
  2295. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  2296. if (groupExtraCost != null)
  2297. {
  2298. _detail.PriceNameContent = groupExtraCost.PriceName;
  2299. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  2300. }
  2301. break;
  2302. default:
  2303. break;
  2304. }
  2305. /*
  2306. * 申请人
  2307. */
  2308. string operatorName = " - ";
  2309. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  2310. if (_opUser != null)
  2311. {
  2312. operatorName = _opUser.CnName;
  2313. }
  2314. _detail.OperatorName = operatorName;
  2315. /*
  2316. * 审核人
  2317. */
  2318. string auditOperatorName = "Unknown";
  2319. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  2320. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  2321. else
  2322. {
  2323. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  2324. if (_adUser != null)
  2325. {
  2326. auditOperatorName = _adUser.CnName;
  2327. }
  2328. }
  2329. _detail.AuditOperatorName = auditOperatorName;
  2330. /*
  2331. * 超预算比例
  2332. */
  2333. string overBudgetStr = "";
  2334. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  2335. else if (entity.ExceedBudget == 0)
  2336. {
  2337. if (entity.CTable == 76 || entity.CTable == 79)
  2338. {
  2339. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  2340. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  2341. }
  2342. else
  2343. {
  2344. overBudgetStr = "未超预算";
  2345. }
  2346. }
  2347. else overBudgetStr = entity.ExceedBudget.ToString("P");
  2348. _detail.OverBudget = overBudgetStr;
  2349. decimal auditFee = 0.00M; //已审核金额 人名币
  2350. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  2351. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  2352. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  2353. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  2354. {
  2355. auditedFeeOriginal = entity.PayMoney;
  2356. auditFee = CurrPayStr;
  2357. }
  2358. else if (entity.IsAuditGM == 0)
  2359. {
  2360. unAuditFeeCNY = CurrPayStr;
  2361. unAuditFeeOriginal = OriginalCurrPay;
  2362. OriginalCurrPay = 0.00M;
  2363. }
  2364. /*
  2365. * 费用总计
  2366. */
  2367. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  2368. {
  2369. CurrencyId = entity.PaymentCurrency,
  2370. CurrencyName = PaymentCurrency_WaitPay,
  2371. AmountPayable = entity.PayMoney,
  2372. ThisPayment = OriginalCurrPay,
  2373. BalancePayment = BalanceStr,
  2374. AuditedFunds = auditFee,
  2375. AuditedFundsOriginal = auditedFeeOriginal,
  2376. UnAuditFundsCNY = unAuditFeeCNY,
  2377. UnAuditFundsOriginal = unAuditFeeOriginal
  2378. });
  2379. _detail.IsAuditGM = entity.IsAuditGM;
  2380. detailList.Add(_detail);
  2381. }
  2382. #endregion
  2383. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  2384. /*
  2385. * 下方描述处理
  2386. */
  2387. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  2388. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  2389. if (ccpCurrencyPrice != null)
  2390. {
  2391. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  2392. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  2393. }
  2394. else
  2395. {
  2396. nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  2397. }
  2398. string amountPayableStr = string.Format(@"应付款总金额: ");
  2399. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  2400. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  2401. string auditedFundsStr = string.Format(@"已审费用总额: ");
  2402. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  2403. foreach (var item in nonDuplicat)
  2404. {
  2405. var currencyName = item.CurrencyName;
  2406. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  2407. if (strs.Count > 0)
  2408. {
  2409. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  2410. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  2411. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  2412. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  2413. //单独处理此次付款金额
  2414. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2415. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  2416. //单独处理已审核费用
  2417. //if (item.CurrencyId == 836) //人民币
  2418. //{
  2419. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  2420. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  2421. //}
  2422. //else
  2423. //{
  2424. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  2425. //}
  2426. if (currencyName.Equals("CNY"))
  2427. {
  2428. //已审核费用
  2429. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  2430. //未审核费用
  2431. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  2432. }
  2433. else
  2434. {
  2435. //已审核费用
  2436. 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"));
  2437. //未审核费用
  2438. 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"));
  2439. }
  2440. }
  2441. }
  2442. _view.TotalStr1 = amountPayableStr.Substring(0, amountPayableStr.Length - 1);
  2443. _view.TotalStr2 = thisPaymentStr.Substring(0, thisPaymentStr.Length - 1);
  2444. _view.TotalStr3 = balancePaymentStr.Substring(0, balancePaymentStr.Length - 1);
  2445. _view.TotalStr4 = $"{auditedFundsStr.Substring(0, auditedFundsStr.Length - 1)}<br/>{unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1)}";
  2446. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  2447. var _view1 = new
  2448. {
  2449. PageFuncAuth = pageFunAuthView,
  2450. Data = _view
  2451. };
  2452. return Ok(JsonView(_view1));
  2453. }
  2454. catch (Exception ex)
  2455. {
  2456. return Ok(JsonView(false, ex.Message));
  2457. }
  2458. }
  2459. /// <summary>
  2460. /// 费用审核
  2461. /// 修改团组费用审核状态
  2462. /// </summary>
  2463. /// <param name="_dto">参数Json字符串</param>
  2464. /// <returns></returns>
  2465. [HttpPost]
  2466. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2467. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  2468. {
  2469. #region 参数验证
  2470. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  2471. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  2472. #endregion
  2473. #region 页面操作权限验证
  2474. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  2475. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  2476. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  2477. #endregion
  2478. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  2479. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  2480. DateTime dtNow = DateTime.Now;
  2481. _groupRepository.BeginTran();
  2482. int rst = 0;
  2483. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  2484. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  2485. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  2486. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  2487. List<dynamic> msgDatas = new List<dynamic>();
  2488. Dictionary<int, int> dic_ccp_user = new Dictionary<int, int>() { };
  2489. foreach (var item in idList)
  2490. {
  2491. int CreditId = int.Parse(item);
  2492. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  2493. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  2494. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  2495. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  2496. .Where(s => s.Id == CreditId)
  2497. .ExecuteCommandAsync();
  2498. if (result < 1)
  2499. {
  2500. rst = -1;
  2501. _groupRepository.RollbackTran();
  2502. return Ok(JsonView(false, "操作失败并回滚!"));
  2503. }
  2504. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  2505. if (creditData != null)
  2506. {
  2507. #region 应用通知配置
  2508. try
  2509. {
  2510. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  2511. }
  2512. catch (Exception ex)
  2513. {
  2514. }
  2515. #endregion
  2516. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  2517. string groupNameStr = string.Empty;
  2518. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  2519. if (groupData != null) groupNameStr = groupData.TeamName;
  2520. string creditTypeStr = string.Empty;
  2521. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  2522. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  2523. string creditCurrency = string.Empty;
  2524. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  2525. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  2526. if (creditCurrency.Equals("CNY"))
  2527. {
  2528. creditData.DayRate = 1.0000M;
  2529. }
  2530. if (creditData.PayPercentage == 0.00M)
  2531. {
  2532. creditData.PayPercentage = 100M;
  2533. }
  2534. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  2535. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  2536. string msgContent = "";
  2537. if (creditCurrency.Equals("CNY"))
  2538. {
  2539. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY) {auditStr}!";
  2540. }
  2541. else
  2542. {
  2543. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice.ToString("0.00")} CNY({creditData.PayMoney.ToString("0.00")} {creditCurrency})) {auditStr}!";
  2544. }
  2545. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  2546. }
  2547. }
  2548. if (rst == 0)
  2549. {
  2550. _groupRepository.CommitTran();
  2551. foreach (var item in msgDatas)
  2552. {
  2553. //发送消息
  2554. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  2555. }
  2556. #region 应用推送
  2557. try
  2558. {
  2559. foreach (var ccpId in dic_ccp_user.Keys)
  2560. {
  2561. List<string> templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  2562. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  2563. }
  2564. }
  2565. catch (Exception)
  2566. {
  2567. }
  2568. #endregion
  2569. return Ok(JsonView(true, "操作成功!"));
  2570. }
  2571. return Ok(JsonView(false, "操作失败!"));
  2572. }
  2573. #endregion
  2574. #region 机票费用录入
  2575. /// <summary>
  2576. /// 机票录入当前登录人可操作团组
  2577. /// </summary>
  2578. /// <param name="dto"></param>
  2579. /// <returns></returns>
  2580. [HttpPost]
  2581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2582. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  2583. {
  2584. try
  2585. {
  2586. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  2587. if (groupData.Code != 0)
  2588. {
  2589. return Ok(JsonView(false, groupData.Msg));
  2590. }
  2591. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2592. }
  2593. catch (Exception ex)
  2594. {
  2595. return Ok(JsonView(false, "程序错误!"));
  2596. throw;
  2597. }
  2598. }
  2599. /// <summary>
  2600. /// 机票费用录入列表
  2601. /// </summary>
  2602. /// <param name="dto"></param>
  2603. /// <returns></returns>
  2604. [HttpPost]
  2605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2606. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  2607. {
  2608. try
  2609. {
  2610. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  2611. if (groupData.Code != 0)
  2612. {
  2613. return Ok(JsonView(false, groupData.Msg));
  2614. }
  2615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2616. }
  2617. catch (Exception ex)
  2618. {
  2619. return Ok(JsonView(false, ex.Message));
  2620. throw;
  2621. }
  2622. }
  2623. /// <summary>
  2624. /// 根据id查询费用录入信息
  2625. /// </summary>
  2626. /// <param name="dto"></param>
  2627. /// <returns></returns>
  2628. [HttpPost]
  2629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2630. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  2631. {
  2632. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  2633. if (groupData.Code != 0)
  2634. {
  2635. return Ok(JsonView(false, groupData.Msg));
  2636. }
  2637. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2638. }
  2639. /// <summary>
  2640. /// 机票费用录入操作(Status:1.新增,2.修改)
  2641. /// </summary>
  2642. /// <param name="dto"></param>
  2643. /// <returns></returns>
  2644. [HttpPost]
  2645. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2646. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  2647. {
  2648. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  2649. if (groupData.Code != 0)
  2650. {
  2651. return Ok(JsonView(false, groupData.Msg));
  2652. }
  2653. #region 应用推送
  2654. try
  2655. {
  2656. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  2657. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  2658. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  2659. //2024-10-21 新增LZ UID
  2660. var userIds = new List<int>() { 21 };
  2661. string title = $"系统通知";
  2662. string content = "";
  2663. var diId = dto.AirTicketResOpData.DiId;
  2664. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  2665. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  2666. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2667. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  2668. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  2669. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  2670. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  2671. }
  2672. catch (Exception ex)
  2673. {
  2674. }
  2675. #endregion
  2676. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2677. }
  2678. /// <summary>
  2679. /// 根据舱位类型查询接团客户名单信息
  2680. /// </summary>
  2681. /// <param name="dto"></param>
  2682. /// <returns></returns>
  2683. [HttpPost]
  2684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2685. public async Task<IActionResult> tankType(AirTicketResByIdDto dto)
  2686. {
  2687. try
  2688. {
  2689. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  2690. if (crm_Groups.Count != 0)
  2691. {
  2692. List<dynamic> Customer = new List<dynamic>();
  2693. foreach (var item in crm_Groups)
  2694. {
  2695. var data = new
  2696. {
  2697. Id = item.Id,
  2698. Pinyin = item.Pinyin,
  2699. Name = item.LastName + item.FirstName
  2700. };
  2701. Customer.Add(data);
  2702. }
  2703. return Ok(JsonView(true, "查询成功!", Customer));
  2704. }
  2705. return Ok(JsonView(true, "暂无数据", crm_Groups));
  2706. }
  2707. catch (Exception ex)
  2708. {
  2709. return Ok(JsonView(false, "程序错误!"));
  2710. throw;
  2711. }
  2712. }
  2713. /// <summary>
  2714. /// 根据团号获取客户信息
  2715. /// </summary>
  2716. /// <param name="dto"></param>
  2717. /// <returns></returns>
  2718. [HttpPost]
  2719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2720. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  2721. {
  2722. var jw = JsonView(false);
  2723. if (dto.DIID < 1)
  2724. {
  2725. jw.Msg += "请输入正确的diid";
  2726. return Ok(jw);
  2727. }
  2728. var arr = getSimplClientList(dto.DIID);
  2729. jw = JsonView(true, "获取成功!", arr);
  2730. return Ok(jw);
  2731. }
  2732. private List<SimplClientInfo> getSimplClientList(int diId)
  2733. {
  2734. 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);
  2735. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  2736. foreach (var item in arr)
  2737. {
  2738. EncryptionProcessor.DecryptProperties(item);
  2739. }
  2740. return arr;
  2741. }
  2742. private string getClientNameStr(List<SimplClientInfo> list, string origin)
  2743. {
  2744. string result = origin;
  2745. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2746. {
  2747. string[] temparr = origin.Split(',');
  2748. string fistrStr = temparr[0];
  2749. int count = temparr.Count();
  2750. int tempId;
  2751. bool success = int.TryParse(fistrStr, out tempId);
  2752. if (success)
  2753. {
  2754. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2755. if (tempInfo != null)
  2756. {
  2757. if (count > 1)
  2758. {
  2759. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  2760. }
  2761. else
  2762. {
  2763. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  2764. }
  2765. }
  2766. }
  2767. }
  2768. return result;
  2769. }
  2770. private string getClientNameStr1(List<SimplClientInfo> list, string origin)
  2771. {
  2772. string result = origin;
  2773. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  2774. {
  2775. string[] temparr = origin.Split(',');
  2776. result = "";
  2777. foreach (var item in temparr)
  2778. {
  2779. int tempId;
  2780. bool success = int.TryParse(item, out tempId);
  2781. if (success)
  2782. {
  2783. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  2784. if (tempInfo != null)
  2785. {
  2786. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  2787. }
  2788. }
  2789. }
  2790. }
  2791. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  2792. return result;
  2793. }
  2794. /// <summary>
  2795. /// 机票费用录入,删除
  2796. /// </summary>
  2797. /// <param name="dto"></param>
  2798. /// <returns></returns>
  2799. [HttpPost]
  2800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2801. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  2802. {
  2803. try
  2804. {
  2805. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  2806. if (res)
  2807. {
  2808. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  2809. {
  2810. IsDel = 1,
  2811. DeleteUserId = dto.DeleteUserId,
  2812. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  2813. }).ExecuteCommandAsync();
  2814. return Ok(JsonView(true, "删除成功!"));
  2815. }
  2816. return Ok(JsonView(false, "删除失败!"));
  2817. }
  2818. catch (Exception ex)
  2819. {
  2820. return Ok(JsonView(false, "程序错误!"));
  2821. throw;
  2822. }
  2823. }
  2824. /// <summary>
  2825. /// 导出机票录入报表
  2826. /// </summary>
  2827. /// <param name="dto"></param>
  2828. /// <returns></returns>
  2829. [HttpPost]
  2830. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2831. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  2832. {
  2833. try
  2834. {
  2835. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  2836. if (groupData.Code != 0)
  2837. {
  2838. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2839. }
  2840. else
  2841. {
  2842. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  2843. if (AirTicketReservations.Count != 0)
  2844. {
  2845. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  2846. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  2847. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  2848. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  2849. WorkbookDesigner designer = new WorkbookDesigner();
  2850. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx");
  2851. decimal countCost = 0;
  2852. foreach (var item in AirTicketReservations)
  2853. {
  2854. #region 处理客人姓名
  2855. string clientNames = _tourClientListRep._ResolveCustomerName(item.ClientName);
  2856. item.ClientName = clientNames;
  2857. #endregion
  2858. if (item.BankType == "其他")
  2859. {
  2860. item.BankNo = "--";
  2861. }
  2862. else
  2863. {
  2864. if (!string.IsNullOrEmpty(item.BankType))
  2865. {
  2866. item.BankNo = item.BankType + ":" + item.BankNo?.Substring(0, 3);
  2867. }
  2868. }
  2869. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  2870. item.Price = System.Decimal.Round(item.Price, 2);
  2871. countCost += Convert.ToDecimal(item.Price);
  2872. }
  2873. designer.SetDataSource("Export", AirTicketReservations);
  2874. designer.SetDataSource("ExportDiCode", diCode);
  2875. designer.SetDataSource("ExportDiName", diName);
  2876. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  2877. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  2878. designer.Process();
  2879. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  2880. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  2881. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  2882. return Ok(JsonView(true, "成功", url = rst));
  2883. }
  2884. else
  2885. {
  2886. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  2887. }
  2888. }
  2889. }
  2890. catch (Exception ex)
  2891. {
  2892. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  2893. throw;
  2894. }
  2895. }
  2896. Dictionary<string, string> transDic = new Dictionary<string, string>();
  2897. /// <summary>
  2898. /// 行程单导出
  2899. /// </summary>
  2900. /// <param name="dto"></param>
  2901. /// <returns></returns>
  2902. [HttpPost]
  2903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2904. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  2905. {
  2906. try
  2907. {
  2908. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  2909. if (groupData.Code != 0)
  2910. {
  2911. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  2912. }
  2913. else
  2914. {
  2915. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  2916. if (dto.Language == "CN")
  2917. {
  2918. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  2919. DocumentBuilder builder = new DocumentBuilder(doc);
  2920. int tableIndex = 0;//表格索引
  2921. //得到文档中的第一个表格
  2922. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  2923. foreach (var item in _AirTicketReservations)
  2924. {
  2925. #region 处理固定数据
  2926. string[] FlightsCode = item.FlightsCode.Split('/');
  2927. if (FlightsCode.Length != 0)
  2928. {
  2929. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  2930. if (_AirCompany != null)
  2931. {
  2932. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  2933. }
  2934. else
  2935. {
  2936. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  2937. }
  2938. }
  2939. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  2940. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  2941. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  2942. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  2943. string name = "";
  2944. foreach (string clientName in nameArray)
  2945. {
  2946. if (!name.Contains(clientName))
  2947. {
  2948. name += clientName + ",";
  2949. }
  2950. }
  2951. if (!string.IsNullOrWhiteSpace(name))
  2952. {
  2953. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  2954. }
  2955. else
  2956. {
  2957. table.Range.Bookmarks["ClientName"].Text = "--";
  2958. }
  2959. table.Range.Bookmarks["TicketNumber"].Text = "--";
  2960. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  2961. table.Range.Bookmarks["JointTicket"].Text = "--";
  2962. table.Range.Bookmarks["TimeIssue"].Text = "--";
  2963. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  2964. table.Range.Bookmarks["NavigationCode"].Text = "--";
  2965. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  2966. table.Range.Bookmarks["AgentPhone"].Text = "--";
  2967. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  2968. #endregion
  2969. #region 循环数据处理
  2970. List<AirInfo> airs = new List<AirInfo>();
  2971. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  2972. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  2973. for (int i = 0; i < FlightsCode.Length; i++)
  2974. {
  2975. AirInfo air = new AirInfo();
  2976. string[] tempstr = DayArray[i]
  2977. .Replace("\r\n", string.Empty)
  2978. .Replace("\\r\\n", string.Empty)
  2979. .TrimStart().TrimEnd()
  2980. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  2981. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  2982. string starCity = "";
  2983. if (star_Three != null)
  2984. {
  2985. starCity = star_Three.AirPort;
  2986. }
  2987. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  2988. string EndCity = "";
  2989. if (End_Three != null)
  2990. {
  2991. EndCity = End_Three.AirPort;
  2992. }
  2993. air.Destination = starCity + "/" + EndCity;
  2994. air.Flight = FlightsCode[i];
  2995. air.SeatingClass = item.CTypeName;
  2996. string dateTime = tempstr[2];
  2997. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  2998. air.FlightDate = DateTemp;
  2999. air.DepartureTime = tempstr[5];
  3000. air.LandingTime = tempstr[6];
  3001. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3002. air.TicketStatus = "--";
  3003. air.Luggage = "--";
  3004. air.DepartureTerminal = "--";
  3005. air.LandingTerminal = "--";
  3006. airs.Add(air);
  3007. }
  3008. int row = 13;
  3009. for (int i = 0; i < airs.Count; i++)
  3010. {
  3011. if (airs.Count > 2)
  3012. {
  3013. for (int j = 0; j < airs.Count - 2; j++)
  3014. {
  3015. var CopyRow = table.Rows[12].Clone(true);
  3016. table.Rows.Add(CopyRow);
  3017. }
  3018. }
  3019. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3020. int index = 0;
  3021. foreach (PropertyInfo property in properties)
  3022. {
  3023. string value = property.GetValue(airs[i]).ToString();
  3024. Cell ishcel0 = table.Rows[row].Cells[index];
  3025. Paragraph p = new Paragraph(doc);
  3026. string s = value;
  3027. p.AppendChild(new Run(doc, s));
  3028. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3029. ishcel0.AppendChild(p);
  3030. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3031. index++;
  3032. }
  3033. row++;
  3034. }
  3035. #endregion
  3036. Paragraph lastParagraph = new Paragraph(doc);
  3037. //第一个表格末尾加段落
  3038. table.ParentNode.InsertAfter(lastParagraph, table);
  3039. //复制第一个表格
  3040. Table cloneTable = (Table)table.Clone(true);
  3041. //在文档末尾段落后面加入复制的表格
  3042. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3043. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3044. {
  3045. int rownewsIndex = 13;
  3046. for (int i = 0; i < 2; i++)
  3047. {
  3048. var CopyRow = table.Rows[12].Clone(true);
  3049. table.Rows.RemoveAt(13);
  3050. table.Rows.Add(CopyRow);
  3051. rownewsIndex++;
  3052. }
  3053. }
  3054. else
  3055. {
  3056. table.Rows.RemoveAt(12);
  3057. }
  3058. cloneTable.Rows.RemoveAt(12);
  3059. }
  3060. if (_AirTicketReservations.Count != 0)
  3061. {
  3062. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3063. if (FlightsCode.Length != 0)
  3064. {
  3065. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3066. if (_AirCompany != null)
  3067. {
  3068. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  3069. }
  3070. else
  3071. {
  3072. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3073. }
  3074. }
  3075. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3076. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3077. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3078. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3079. string name = "";
  3080. foreach (string clientName in nameArray)
  3081. {
  3082. if (!name.Contains(clientName))
  3083. {
  3084. name += clientName + ",";
  3085. }
  3086. }
  3087. if (!string.IsNullOrWhiteSpace(name))
  3088. {
  3089. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  3090. }
  3091. else
  3092. {
  3093. table.Range.Bookmarks["ClientName"].Text = "--";
  3094. }
  3095. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3096. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3097. table.Range.Bookmarks["JointTicket"].Text = "--";
  3098. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3099. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3100. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3101. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3102. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3103. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3104. }
  3105. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3106. //保存合并后的文档
  3107. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  3108. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3109. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3110. return Ok(JsonView(true, "成功!", rst));
  3111. }
  3112. else
  3113. {
  3114. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  3115. DocumentBuilder builder = new DocumentBuilder(doc);
  3116. int tableIndex = 0;//表格索引
  3117. //得到文档中的第一个表格
  3118. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  3119. List<string> texts = new List<string>();
  3120. foreach (var item in _AirTicketReservations)
  3121. {
  3122. string[] FlightsCode = item.FlightsCode.Split('/');
  3123. if (FlightsCode.Length != 0)
  3124. {
  3125. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3126. if (_AirCompany != null)
  3127. {
  3128. if (!transDic.ContainsKey(_AirCompany.CnName))
  3129. {
  3130. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  3131. }
  3132. }
  3133. else
  3134. {
  3135. if (!transDic.ContainsKey("--"))
  3136. {
  3137. transDic.Add("--", "--");
  3138. }
  3139. }
  3140. }
  3141. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3142. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3143. string name = "";
  3144. foreach (string clientName in nameArray)
  3145. {
  3146. name += clientName + ",";
  3147. }
  3148. if (!texts.Contains(name))
  3149. {
  3150. texts.Add(name);
  3151. }
  3152. List<AirInfo> airs = new List<AirInfo>();
  3153. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3154. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3155. for (int i = 0; i < FlightsCode.Length; i++)
  3156. {
  3157. AirInfo air = new AirInfo();
  3158. string[] tempstr = DayArray[i]
  3159. .Replace("\r\n", string.Empty)
  3160. .Replace("\\r\\n", string.Empty)
  3161. .TrimStart().TrimEnd()
  3162. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3163. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3164. if (star_Three != null)
  3165. {
  3166. if (!transDic.ContainsKey(star_Three.AirPort))
  3167. {
  3168. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  3169. }
  3170. }
  3171. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3172. if (End_Three != null)
  3173. {
  3174. if (!transDic.ContainsKey(End_Three.AirPort))
  3175. {
  3176. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  3177. }
  3178. }
  3179. if (!texts.Contains(item.CTypeName))
  3180. {
  3181. texts.Add(item.CTypeName);
  3182. }
  3183. }
  3184. }
  3185. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  3186. if (transData.Count > 0)
  3187. {
  3188. foreach (TranslateResult item in transData)
  3189. {
  3190. if (!transDic.ContainsKey(item.Query))
  3191. {
  3192. transDic.Add(item.Query, item.Translation);
  3193. }
  3194. }
  3195. }
  3196. foreach (var item in _AirTicketReservations)
  3197. {
  3198. #region 处理固定数据
  3199. string[] FlightsCode = item.FlightsCode.Split('/');
  3200. if (FlightsCode.Length != 0)
  3201. {
  3202. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3203. if (_AirCompany != null)
  3204. {
  3205. string str = "--";
  3206. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3207. if (!string.IsNullOrEmpty(translateResult))
  3208. {
  3209. str = translateResult;
  3210. str = _airTicketResRep.Processing(str);
  3211. }
  3212. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3213. }
  3214. else
  3215. {
  3216. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3217. }
  3218. }
  3219. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3220. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3221. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3222. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3223. string names = "";
  3224. foreach (string clientName in nameArray)
  3225. {
  3226. names += clientName + ",";
  3227. }
  3228. if (!string.IsNullOrWhiteSpace(names))
  3229. {
  3230. string str = "--";
  3231. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3232. if (!string.IsNullOrEmpty(translateResult))
  3233. {
  3234. str = translateResult;
  3235. str = _airTicketResRep.Processing(str);
  3236. }
  3237. table.Range.Bookmarks["ClientName"].Text = str;
  3238. }
  3239. else
  3240. {
  3241. table.Range.Bookmarks["ClientName"].Text = "--";
  3242. }
  3243. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3244. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3245. table.Range.Bookmarks["JointTicket"].Text = "--";
  3246. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3247. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3248. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3249. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3250. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3251. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3252. #endregion
  3253. #region 循环数据处理
  3254. List<AirInfo> airs = new List<AirInfo>();
  3255. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  3256. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  3257. for (int i = 0; i < FlightsCode.Length; i++)
  3258. {
  3259. AirInfo air = new AirInfo();
  3260. string[] tempstr = DayArray[i]
  3261. .Replace("\r\n", string.Empty)
  3262. .Replace("\\r\\n", string.Empty)
  3263. .TrimStart().TrimEnd()
  3264. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  3265. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  3266. string starCity = "";
  3267. if (star_Three != null)
  3268. {
  3269. string str2 = "--";
  3270. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  3271. if (!string.IsNullOrEmpty(translateResult2))
  3272. {
  3273. str2 = translateResult2;
  3274. str2 = _airTicketResRep.Processing(str2);
  3275. }
  3276. starCity = str2;
  3277. }
  3278. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  3279. string EndCity = "";
  3280. if (End_Three != null)
  3281. {
  3282. string str1 = "--";
  3283. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  3284. if (!string.IsNullOrEmpty(translateResult1))
  3285. {
  3286. str1 = translateResult1;
  3287. str1 = _airTicketResRep.Processing(str1);
  3288. }
  3289. EndCity = str1;
  3290. }
  3291. air.Destination = starCity + "/" + EndCity;
  3292. air.Flight = FlightsCode[i];
  3293. string str = "--";
  3294. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  3295. if (!string.IsNullOrEmpty(translateResult))
  3296. {
  3297. str = translateResult;
  3298. str = _airTicketResRep.Processing(str);
  3299. }
  3300. air.SeatingClass = str;
  3301. string dateTime = tempstr[2];
  3302. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  3303. air.FlightDate = DateTemp;
  3304. air.DepartureTime = tempstr[5];
  3305. air.LandingTime = tempstr[6];
  3306. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  3307. air.TicketStatus = "--";
  3308. air.Luggage = "--";
  3309. air.DepartureTerminal = "--";
  3310. air.LandingTerminal = "--";
  3311. airs.Add(air);
  3312. }
  3313. int row = 13;
  3314. for (int i = 0; i < airs.Count; i++)
  3315. {
  3316. if (airs.Count > 2)
  3317. {
  3318. for (int j = 0; j < airs.Count - 2; j++)
  3319. {
  3320. var CopyRow = table.Rows[12].Clone(true);
  3321. table.Rows.Add(CopyRow);
  3322. }
  3323. }
  3324. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  3325. int index = 0;
  3326. foreach (PropertyInfo property in properties)
  3327. {
  3328. string value = property.GetValue(airs[i]).ToString();
  3329. Cell ishcel0 = table.Rows[row].Cells[index];
  3330. Paragraph p = new Paragraph(doc);
  3331. string s = value;
  3332. p.AppendChild(new Run(doc, s));
  3333. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  3334. ishcel0.AppendChild(p);
  3335. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  3336. //ishcel0.CellFormat.VerticalAlignment=
  3337. index++;
  3338. }
  3339. row++;
  3340. }
  3341. #endregion
  3342. Paragraph lastParagraph = new Paragraph(doc);
  3343. //第一个表格末尾加段落
  3344. table.ParentNode.InsertAfter(lastParagraph, table);
  3345. //复制第一个表格
  3346. Table cloneTable = (Table)table.Clone(true);
  3347. //在文档末尾段落后面加入复制的表格
  3348. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  3349. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  3350. {
  3351. int rownewsIndex = 13;
  3352. for (int i = 0; i < 2; i++)
  3353. {
  3354. var CopyRow = table.Rows[12].Clone(true);
  3355. table.Rows.RemoveAt(13);
  3356. table.Rows.Add(CopyRow);
  3357. rownewsIndex++;
  3358. }
  3359. }
  3360. else
  3361. {
  3362. table.Rows.RemoveAt(12);
  3363. }
  3364. cloneTable.Rows.RemoveAt(12);
  3365. }
  3366. if (_AirTicketReservations.Count != 0)
  3367. {
  3368. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  3369. if (FlightsCode.Length != 0)
  3370. {
  3371. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  3372. if (_AirCompany != null)
  3373. {
  3374. string str = "--";
  3375. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  3376. if (!string.IsNullOrEmpty(translateResult))
  3377. {
  3378. str = translateResult;
  3379. str = _airTicketResRep.Processing(str);
  3380. }
  3381. table.Range.Bookmarks["AirlineCompany"].Text = str;
  3382. }
  3383. else
  3384. {
  3385. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  3386. }
  3387. }
  3388. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  3389. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  3390. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  3391. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  3392. string names = "";
  3393. foreach (string clientName in nameArray)
  3394. {
  3395. names += clientName + ",";
  3396. }
  3397. if (!string.IsNullOrWhiteSpace(names))
  3398. {
  3399. string str = "--";
  3400. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  3401. if (!string.IsNullOrEmpty(translateResult))
  3402. {
  3403. str = translateResult;
  3404. str = _airTicketResRep.Processing(str);
  3405. }
  3406. table.Range.Bookmarks["ClientName"].Text = str;
  3407. }
  3408. else
  3409. {
  3410. table.Range.Bookmarks["ClientName"].Text = "--";
  3411. }
  3412. table.Range.Bookmarks["TicketNumber"].Text = "--";
  3413. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  3414. table.Range.Bookmarks["JointTicket"].Text = "--";
  3415. table.Range.Bookmarks["TimeIssue"].Text = "--";
  3416. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  3417. table.Range.Bookmarks["NavigationCode"].Text = "--";
  3418. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  3419. table.Range.Bookmarks["AgentPhone"].Text = "--";
  3420. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  3421. }
  3422. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  3423. //保存合并后的文档
  3424. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  3425. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  3426. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  3427. return Ok(JsonView(true, "成功!", rst));
  3428. }
  3429. }
  3430. }
  3431. catch (Exception ex)
  3432. {
  3433. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  3434. throw;
  3435. }
  3436. }
  3437. #endregion
  3438. #region 团组增减款项 --> 其他款项
  3439. /// <summary>
  3440. /// 团组增减款项下拉框绑定
  3441. /// </summary>
  3442. /// <param name="dto"></param>
  3443. /// <returns></returns>
  3444. [HttpPost]
  3445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3446. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  3447. {
  3448. #region 参数验证
  3449. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3450. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  3451. #endregion
  3452. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  3453. }
  3454. /// <summary>
  3455. /// 根据团组Id查询团组增减款项
  3456. /// </summary>
  3457. /// <param name="dto"></param>
  3458. /// <returns></returns>
  3459. [HttpPost]
  3460. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3461. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  3462. {
  3463. #region 参数验证
  3464. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  3465. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  3466. #endregion
  3467. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  3468. }
  3469. /// <summary>
  3470. /// 团组增减款项操作(Status:1.新增,2.修改)
  3471. /// </summary>
  3472. /// <param name="dto"></param>
  3473. /// <returns></returns>
  3474. [HttpPost]
  3475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3476. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  3477. {
  3478. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  3479. if (groupData.Code != 200)
  3480. {
  3481. return Ok(JsonView(false, groupData.Msg));
  3482. }
  3483. #region 应用推送
  3484. int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  3485. int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  3486. int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  3487. //自动审核
  3488. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  3489. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  3490. //2024-10-21 新增LZ UID
  3491. var userIds = new List<int>() { 21 };
  3492. string title = $"系统通知";
  3493. string content = "";
  3494. var diId = dto.DiId;
  3495. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  3496. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  3497. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3498. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  3499. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  3500. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  3501. #endregion
  3502. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3503. }
  3504. /// <summary>
  3505. /// 团组增减款项操作 删除
  3506. /// </summary>
  3507. /// <param name="dto"></param>
  3508. /// <returns></returns>
  3509. [HttpPost]
  3510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3511. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  3512. {
  3513. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  3514. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  3515. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  3516. if (res.Code == 0)
  3517. {
  3518. return Ok(JsonView(true, "删除成功!"));
  3519. }
  3520. return Ok(JsonView(false, "删除失败!"));
  3521. }
  3522. /// <summary>
  3523. /// 根据团组增减款项Id查询
  3524. /// </summary>
  3525. /// <param name="dto"></param>
  3526. /// <returns></returns>
  3527. [HttpPost]
  3528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3529. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  3530. {
  3531. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  3532. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  3533. }
  3534. /// <summary>
  3535. /// 查询供应商名称
  3536. /// </summary>
  3537. /// <param name="dto"></param>
  3538. /// <returns></returns>
  3539. [HttpPost]
  3540. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  3541. {
  3542. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  3543. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  3544. ?? new List<Grp_DecreasePayments>();
  3545. dbResult = dbResult.Distinct(new
  3546. ProductComparer()).ToList();
  3547. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  3548. {
  3549. x.Id,
  3550. x.SupplierAddress,
  3551. x.SupplierArea,
  3552. x.SupplierContact,
  3553. x.SupplierContactNumber,
  3554. x.SupplierEmail,
  3555. x.SupplierName,
  3556. x.SupplierSocialAccount,
  3557. x.SupplierTypeId,
  3558. }).ToList());
  3559. return Ok(jw);
  3560. }
  3561. /// <summary>
  3562. /// 团组增减款项 OTA匹配
  3563. /// </summary>
  3564. /// <param name="file"></param>
  3565. /// <returns></returns>
  3566. [HttpPost]
  3567. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  3568. {
  3569. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  3570. string fileName = file.FileName;
  3571. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  3572. {
  3573. return Ok(JsonView(false, "请上传Excel文件!"));
  3574. }
  3575. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  3576. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  3577. if (!Directory.Exists(path))
  3578. {
  3579. Directory.CreateDirectory(path);
  3580. }
  3581. var filePath = @$"{path}/{fileName}";
  3582. //保存文件
  3583. using (FileStream fs = System.IO.File.Create(filePath))
  3584. {
  3585. file.CopyTo(fs);
  3586. fs.Flush();
  3587. }
  3588. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  3589. //读取ExcelFile
  3590. DataTable dt = ConvertExcelToDataTable(filePath);
  3591. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  3592. dt.TableName = "TB";
  3593. //修改table列名
  3594. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  3595. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  3596. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  3597. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  3598. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  3599. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  3600. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  3601. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  3602. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  3603. dt.Columns[9].ColumnName = "Quantity"; // 台数
  3604. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  3605. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  3606. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  3607. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  3608. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  3609. var otaOrderNos = new List<string>();
  3610. foreach (DataRow item in dt.Rows)
  3611. {
  3612. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  3613. }
  3614. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  3615. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  3616. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  3617. .Select((dp, di) => new
  3618. {
  3619. dp.PriceName,
  3620. dp.OTAOrderNo,
  3621. dp.FeeTotal,
  3622. di.TeamName,
  3623. })
  3624. .ToListAsync();
  3625. foreach (DataRow item in dt.Rows)
  3626. {
  3627. var otaOrderNo = item["OTAOrderNo"].ToString();
  3628. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  3629. if (oaData == null) continue;
  3630. item["GroupName"] = oaData.TeamName;
  3631. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  3632. }
  3633. string fileName1 = $"OTA_WIFI费用{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  3634. Dictionary<string, object> pairs = new Dictionary<string, object>();
  3635. List<DataTable> datas = new List<DataTable>();
  3636. datas.Add(dt);
  3637. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  3638. return Ok(JsonView(true, "操作成功", new { url = url }));
  3639. }
  3640. #region
  3641. private DataTable ConvertExcelToDataTable(string excelFilePath)
  3642. {
  3643. // 创建Workbook对象
  3644. Workbook workbook = new Workbook(excelFilePath);
  3645. // 获取第一个工作表
  3646. Worksheet worksheet = workbook.Worksheets[0];
  3647. // 将工作表转换为DataTable
  3648. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  3649. return dataTable;
  3650. }
  3651. #endregion
  3652. #endregion
  3653. #region 文件上传、删除
  3654. /// <summary>
  3655. /// region 文件上传 可以带参数
  3656. /// </summary>
  3657. /// <param name="file"></param>
  3658. /// <returns></returns>
  3659. [HttpPost]
  3660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3661. public async Task<IActionResult> UploadProject(IFormFile file)
  3662. {
  3663. //var TypeName = Request.Headers["TypeName"].ToString();
  3664. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  3665. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3666. ////文件名称
  3667. //string projectFileName = file.FileName;
  3668. ////上传的文件的路径
  3669. //string filePath = $"{fileDir}/{projectFileName}";
  3670. //if (TypeName == "A")//A代表团组增减款项
  3671. //{
  3672. // filePath = fileDir + $@"\团组增减款项相关文件";
  3673. // if (!Directory.Exists(filePath))
  3674. // {
  3675. // Directory.CreateDirectory(filePath);
  3676. // }
  3677. // //上传的文件的路径
  3678. // filePath += $@"\{projectFileName}";
  3679. //}
  3680. //else if (TypeName == "B")//B代表商邀相关文件
  3681. //{
  3682. // //上传的文件的路径
  3683. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3684. // if (!Directory.Exists(filePath))
  3685. // {
  3686. // Directory.CreateDirectory(filePath);
  3687. // }
  3688. // //上传的文件的路径
  3689. // filePath = $@"\{projectFileName}";
  3690. //}
  3691. //try
  3692. //{
  3693. // using (FileStream fs = System.IO.File.Create(filePath))
  3694. // {
  3695. // file.CopyTo(fs);
  3696. // fs.Flush();
  3697. // }
  3698. //}
  3699. //catch (Exception ex)
  3700. //{
  3701. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  3702. //}
  3703. //return Ok(JsonView(true, "上传成功!", projectFileName));
  3704. try
  3705. {
  3706. var TypeName = Request.Headers["TypeName"].ToString();
  3707. if (file != null)
  3708. {
  3709. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3710. //文件名称
  3711. string projectFileName = file.FileName;
  3712. //上传的文件的路径
  3713. string filePath = $"{fileDir}/{projectFileName}";
  3714. if (TypeName == "A")//A代表团组增减款项
  3715. {
  3716. if (!Directory.Exists(fileDir))
  3717. {
  3718. Directory.CreateDirectory(fileDir);
  3719. }
  3720. //上传的文件的路径
  3721. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3722. }
  3723. else if (TypeName == "B")//B代表商邀相关文件
  3724. {
  3725. if (!Directory.Exists(fileDir))
  3726. {
  3727. Directory.CreateDirectory(fileDir);
  3728. }
  3729. //上传的文件的路径
  3730. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3731. }
  3732. using (FileStream fs = System.IO.File.Create(filePath))
  3733. {
  3734. file.CopyTo(fs);
  3735. fs.Flush();
  3736. }
  3737. return Ok(JsonView(true, "上传成功!", projectFileName));
  3738. }
  3739. else
  3740. {
  3741. return Ok(JsonView(false, "上传失败!"));
  3742. }
  3743. }
  3744. catch (Exception ex)
  3745. {
  3746. return Ok(JsonView(false, "程序错误!"));
  3747. }
  3748. }
  3749. /// <summary>
  3750. /// 删除指定文件
  3751. /// </summary>
  3752. /// <param name="dto"></param>
  3753. /// <returns></returns>
  3754. [HttpPost]
  3755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3756. public async Task<IActionResult> DelFile(DelFileDto dto)
  3757. {
  3758. try
  3759. {
  3760. var TypeName = Request.Headers["TypeName"].ToString();
  3761. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3762. string filePath = "";
  3763. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3764. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  3765. int id = 0;
  3766. if (TypeName == "A")
  3767. {
  3768. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  3769. // 删除该文件
  3770. System.IO.File.Delete(filePath);
  3771. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  3772. .Where(a => a.Id == dto.Id)
  3773. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  3774. .ExecuteCommandAsync();
  3775. }
  3776. else if (TypeName == "B")
  3777. {
  3778. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  3779. // 删除该文件
  3780. System.IO.File.Delete(filePath);
  3781. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  3782. if (info != null)
  3783. {
  3784. string[] files = new string[] { };
  3785. if (!string.IsNullOrEmpty(info.Attachment))
  3786. {
  3787. try
  3788. {
  3789. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  3790. }
  3791. catch (Exception)
  3792. {
  3793. files = new List<string>() { info.Attachment }.ToArray();
  3794. }
  3795. }
  3796. if (files.Length > 0)
  3797. {
  3798. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  3799. string filePath2 = string.Empty;
  3800. if (files1.Length > 0)
  3801. {
  3802. filePath2 = JsonConvert.SerializeObject(files1);
  3803. }
  3804. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  3805. .Where(a => a.Id == dto.Id)
  3806. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  3807. .ExecuteCommandAsync();
  3808. }
  3809. }
  3810. }
  3811. if (id != 0)
  3812. {
  3813. return Ok(JsonView(true, "成功!"));
  3814. }
  3815. else
  3816. {
  3817. return Ok(JsonView(false, "失败!"));
  3818. }
  3819. }
  3820. catch (Exception ex)
  3821. {
  3822. return Ok(JsonView(false, "程序错误!"));
  3823. throw;
  3824. }
  3825. }
  3826. /// <summary>
  3827. /// 文件上传多个文件 可以带参数
  3828. /// </summary>
  3829. /// <param name="file"></param>
  3830. /// <returns></returns>
  3831. [HttpPost]
  3832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3833. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  3834. {
  3835. try
  3836. {
  3837. var TypeName = Request.Headers["TypeName"].ToString();
  3838. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  3839. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3840. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  3841. var filePahts = new List<string>();
  3842. foreach (var file in files)
  3843. {
  3844. //文件名称
  3845. string projectFileName = file.FileName;
  3846. //上传的文件的路径
  3847. string filePath = $"{fileDir}/{projectFileName}";
  3848. if (TypeName == "A")//A代表团组增减款项
  3849. {
  3850. if (!Directory.Exists(fileDir))
  3851. {
  3852. Directory.CreateDirectory(fileDir);
  3853. }
  3854. //上传的文件的路径
  3855. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  3856. }
  3857. else if (TypeName == "B")//B代表商邀相关文件
  3858. {
  3859. if (!Directory.Exists(fileDir))
  3860. {
  3861. Directory.CreateDirectory(fileDir);
  3862. }
  3863. //上传的文件的路径
  3864. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  3865. }
  3866. using (FileStream fs = System.IO.File.Create(filePath))
  3867. {
  3868. file.CopyTo(fs);
  3869. fs.Flush();
  3870. }
  3871. filePahts.Add(projectFileName);
  3872. }
  3873. return Ok(JsonView(true, "上传成功!", filePahts));
  3874. }
  3875. catch (Exception ex)
  3876. {
  3877. return Ok(JsonView(false, "程序错误!"));
  3878. }
  3879. }
  3880. #endregion
  3881. #region 商邀费用录入
  3882. /// <summary>
  3883. /// 根据团组Id查询商邀费用列表
  3884. /// </summary>
  3885. /// <param name="dto"></param>
  3886. /// <returns></returns>
  3887. [HttpPost]
  3888. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3889. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  3890. {
  3891. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  3892. if (groupData.Code != 0)
  3893. {
  3894. return Ok(JsonView(false, groupData.Msg));
  3895. }
  3896. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3897. }
  3898. /// <summary>
  3899. /// 商邀费用列表
  3900. /// 下载文件
  3901. /// </summary>
  3902. /// <param name="dto"></param>
  3903. /// <returns></returns>
  3904. [HttpGet("{id}")]
  3905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3906. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  3907. {
  3908. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  3909. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  3910. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  3911. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  3912. var filePaths = new List<string>();
  3913. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  3914. try
  3915. {
  3916. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  3917. }
  3918. catch (Exception ex)
  3919. {
  3920. filePaths.Add(info.Attachment);
  3921. }
  3922. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  3923. for (int i = 0; i < filePaths.Count; i++)
  3924. {
  3925. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  3926. }
  3927. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  3928. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  3929. using (FileStream zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  3930. {
  3931. using (ZipArchive zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  3932. {
  3933. foreach (string filePath in filePaths)
  3934. {
  3935. if (System.IO.File.Exists(filePath))
  3936. {
  3937. // 获取文件名
  3938. string fileName = Path.GetFileName(filePath);
  3939. // 将文件添加到ZIP归档中
  3940. zipArchive.CreateEntryFromFile(filePath, fileName);
  3941. }
  3942. }
  3943. }
  3944. }
  3945. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  3946. }
  3947. /// <summary>
  3948. /// 商邀费用 Info Page 基础数据源
  3949. /// </summary>
  3950. /// <param name="dto"></param>
  3951. /// <returns></returns>
  3952. [HttpPost]
  3953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3954. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  3955. {
  3956. try
  3957. {
  3958. Result groupData = await _InvitationOfficialActivitiesRep._InitBasicData();
  3959. if (groupData.Code != 0)
  3960. {
  3961. return Ok(JsonView(false, groupData.Msg));
  3962. }
  3963. return Ok(JsonView(true, "操作成功", groupData.Data));
  3964. }
  3965. catch (Exception ex)
  3966. {
  3967. return Ok(JsonView(false, ex.Message));
  3968. throw;
  3969. }
  3970. }
  3971. /// <summary>
  3972. /// 根据商邀费用ID查询C表和商邀费用数据
  3973. /// </summary>
  3974. /// <param name="dto"></param>
  3975. /// <returns></returns>
  3976. [HttpPost]
  3977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3978. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  3979. {
  3980. try
  3981. {
  3982. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  3983. if (groupData.Code != 0)
  3984. {
  3985. return Ok(JsonView(false, groupData.Msg));
  3986. }
  3987. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3988. }
  3989. catch (Exception ex)
  3990. {
  3991. return Ok(JsonView(false, ex.Message));
  3992. throw;
  3993. }
  3994. }
  3995. /// <summary>
  3996. /// 商邀费用录入操作(Status:1.新增,2.修改)
  3997. /// </summary>
  3998. /// <param name="dto"></param>
  3999. /// <returns></returns>
  4000. [HttpPost]
  4001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4002. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  4003. {
  4004. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  4005. if (groupData.Code != 0)
  4006. {
  4007. return Ok(JsonView(false, groupData.Msg));
  4008. }
  4009. #region 应用推送
  4010. try
  4011. {
  4012. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4013. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4014. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4015. //2024-10-21 新增LZ UID
  4016. var userIds = new List<int>() { 21 };
  4017. string title = $"系统通知";
  4018. string content = "";
  4019. var diId = dto.DiId;
  4020. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4021. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4022. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4023. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4024. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4025. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  4026. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4027. }
  4028. catch (Exception ex)
  4029. {
  4030. }
  4031. #endregion
  4032. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4033. }
  4034. /// <summary>
  4035. /// 商邀删除
  4036. /// </summary>
  4037. /// <param name="dto"></param>
  4038. /// <returns></returns>
  4039. [HttpPost]
  4040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4041. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  4042. {
  4043. try
  4044. {
  4045. _sqlSugar.BeginTran();
  4046. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  4047. .SetColumns(it => new Grp_InvitationOfficialActivities()
  4048. {
  4049. IsDel = 1,
  4050. DeleteUserId = dto.DeleteUserId,
  4051. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4052. })
  4053. .Where(it => it.Id == dto.Id)
  4054. .ExecuteCommand();
  4055. if (res1 > 0)
  4056. {
  4057. int _diId = 0;
  4058. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  4059. if (_ioaInfo != null)
  4060. {
  4061. _diId = _ioaInfo.DiId;
  4062. }
  4063. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  4064. .SetColumns(a => new Grp_CreditCardPayment()
  4065. {
  4066. IsDel = 1,
  4067. DeleteUserId = dto.DeleteUserId,
  4068. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  4069. })
  4070. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  4071. .ExecuteCommand();
  4072. if (res2 > 0)
  4073. {
  4074. _sqlSugar.CommitTran();
  4075. return Ok(JsonView(true, "删除成功!"));
  4076. }
  4077. }
  4078. _sqlSugar.RollbackTran();
  4079. return Ok(JsonView(false, "删除失败"));
  4080. }
  4081. catch (Exception ex)
  4082. {
  4083. _sqlSugar.RollbackTran();
  4084. return Ok(JsonView(false, ex.Message));
  4085. }
  4086. }
  4087. /// <summary>
  4088. /// 团组模块文件上传
  4089. /// </summary>
  4090. /// <param name="dto"></param>
  4091. /// <returns></returns>
  4092. [HttpPost]
  4093. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  4094. {
  4095. var jw = JsonView(false);
  4096. long M = 1024 * 1024;
  4097. if (dto.Files == null || dto.Files.Count == 0)
  4098. {
  4099. jw.Msg = "无文件信息!";
  4100. return Ok(jw);
  4101. }
  4102. if (dto.Files.Sum(x => x.Length) > 20 * M)
  4103. {
  4104. jw.Msg = "文件大小超过20M!";
  4105. return Ok(jw);
  4106. }
  4107. //var nameSp = dto.File.FileName.Split(".");
  4108. //if (nameSp.Length < 2)
  4109. //{
  4110. // jw.Msg = "拓展名称有误!";
  4111. // return Ok(jw);
  4112. //}
  4113. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  4114. //if (!existsName.Contains(nameSp[1].ToUpper()))
  4115. //{
  4116. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  4117. // return Ok(jw);
  4118. //}
  4119. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  4120. if (Ctable == null)
  4121. {
  4122. jw.Msg = "Ctable指向有误!";
  4123. return Ok(jw);
  4124. }
  4125. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  4126. if (groupInfo == null)
  4127. {
  4128. jw.Msg = "团组信息不存在!";
  4129. return Ok(jw);
  4130. }
  4131. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  4132. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4133. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4134. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4135. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  4136. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  4137. try
  4138. {
  4139. if (!Directory.Exists(fileBase))
  4140. {
  4141. Directory.CreateDirectory(fileBase);
  4142. }
  4143. List<Grp_GroupModelFile> saveArr = new List<Grp_GroupModelFile>();
  4144. foreach (var fileStream in dto.Files)
  4145. {
  4146. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  4147. Grp_GroupModelFile file = new Grp_GroupModelFile()
  4148. {
  4149. Cid = dto.Cid,
  4150. CreateTime = DateTime.Now,
  4151. CreateUserId = dto.Userid,
  4152. Ctable = dto.Ctable,
  4153. Diid = dto.Diid,
  4154. IsDel = 0,
  4155. FilePath = saveFilePath,
  4156. FileName = fileStream.FileName
  4157. };
  4158. using (FileStream fs = System.IO.File.Create(saveFilePath))
  4159. {
  4160. fileStream.CopyTo(fs);
  4161. fs.Flush();
  4162. }
  4163. saveArr.Add(file);
  4164. }
  4165. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  4166. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  4167. jw = JsonView(true, "保存成功!", new
  4168. {
  4169. count = addResult,
  4170. filesName = saveArr.Select(x => x.FileName)
  4171. });
  4172. }
  4173. catch (Exception ex)
  4174. {
  4175. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  4176. {
  4177. count = 0,
  4178. filesName = new string[0],
  4179. });
  4180. }
  4181. return Ok(jw);
  4182. }
  4183. /// <summary>
  4184. /// 查询各模块已保存文件
  4185. /// </summary>
  4186. /// <param name="dto"></param>
  4187. /// <returns></returns>
  4188. [HttpPost]
  4189. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  4190. {
  4191. var expression = Expressionable.Create<Grp_GroupModelFile>()
  4192. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  4193. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  4194. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  4195. {
  4196. expression = Expressionable.Create<Grp_GroupModelFile>()
  4197. .And(x => visaIds.Contains(x.CreateUserId));
  4198. }
  4199. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  4200. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  4201. .Where(expression.ToExpression())
  4202. .ToList();
  4203. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  4204. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  4205. {
  4206. x.FileName,
  4207. x.Id,
  4208. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  4209. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  4210. })));
  4211. }
  4212. /// <summary>
  4213. /// 下载该团组下的所有文件
  4214. /// </summary>
  4215. /// <param name="dto"></param>
  4216. /// <returns></returns>
  4217. [HttpPost]
  4218. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  4219. {
  4220. var jw = JsonView(false);
  4221. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4222. if (groupInfo == null)
  4223. {
  4224. jw.Msg = "团组信息不存在!";
  4225. return Ok(jw);
  4226. }
  4227. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  4228. var isModule = Convert.ToBoolean(dto.isModule);
  4229. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4230. IOOperatorHelper io = new IOOperatorHelper();
  4231. if (isModule)
  4232. {
  4233. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  4234. foreach (var moduleArr in moduleGroup)
  4235. {
  4236. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  4237. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4238. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4239. Dictionary<string, Stream> chiZips = new Dictionary<string, Stream>();
  4240. foreach (var item in moduleArr)
  4241. {
  4242. if (System.IO.File.Exists(item.FilePath))
  4243. {
  4244. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4245. {
  4246. byte[] bytes = new byte[fileStream.Length];
  4247. fileStream.Read(bytes, 0, bytes.Length);
  4248. fileStream.Close();
  4249. Stream stream = new MemoryStream(bytes);
  4250. chiZips.Add(item.FileName, stream);
  4251. }
  4252. }
  4253. }
  4254. if (chiZips.Count > 0)
  4255. {
  4256. var byts = io.ConvertZipStream(chiZips);
  4257. Stream stream = new MemoryStream(byts);
  4258. Zips.Add(key.Name + "_.zip", stream);
  4259. }
  4260. }
  4261. }
  4262. else
  4263. {
  4264. foreach (var item in dbQuery)
  4265. {
  4266. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4267. {
  4268. byte[] bytes = new byte[fileStream.Length];
  4269. fileStream.Read(bytes, 0, bytes.Length);
  4270. fileStream.Close();
  4271. Stream stream = new MemoryStream(bytes);
  4272. while (Zips.Keys.Contains(item.FileName))
  4273. {
  4274. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4275. }
  4276. Zips.Add(item.FileName, stream);
  4277. }
  4278. }
  4279. }
  4280. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4281. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4282. if (Zips.Count > 0)
  4283. {
  4284. var byts = io.ConvertZipStream(Zips);
  4285. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4286. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  4287. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  4288. }
  4289. else
  4290. {
  4291. jw.Msg = "暂无生成文件!";
  4292. }
  4293. return Ok(jw);
  4294. }
  4295. /// <summary>
  4296. /// 下载该团组下此模块的所有文件
  4297. /// </summary>
  4298. /// <param name="dto"></param>
  4299. /// <returns></returns>
  4300. [HttpPost]
  4301. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  4302. {
  4303. var jw = JsonView(false);
  4304. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  4305. if (groupInfo == null)
  4306. {
  4307. jw.Msg = "团组信息不存在!";
  4308. return Ok(jw);
  4309. }
  4310. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  4311. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  4312. && x.IsDel == 0);
  4313. if (key == null)
  4314. {
  4315. jw.Msg = "Ctable指向错误!";
  4316. return Ok(jw);
  4317. }
  4318. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  4319. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4320. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  4321. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  4322. IOOperatorHelper io = new IOOperatorHelper();
  4323. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  4324. foreach (var item in dbQuery)
  4325. {
  4326. if (System.IO.File.Exists(item.FilePath))
  4327. {
  4328. using (FileStream fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  4329. {
  4330. byte[] bytes = new byte[fileStream.Length];
  4331. fileStream.Read(bytes, 0, bytes.Length);
  4332. fileStream.Close();
  4333. Stream stream = new MemoryStream(bytes);
  4334. while (Zips.Keys.Contains(item.FileName))
  4335. {
  4336. item.FileName = new Random().Next(100) + "_" + item.FileName;
  4337. }
  4338. Zips.Add(item.FileName, stream);
  4339. }
  4340. }
  4341. }
  4342. if (Zips.Count > 0)
  4343. {
  4344. var byts = io.ConvertZipStream(Zips);
  4345. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  4346. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  4347. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  4348. }
  4349. else
  4350. {
  4351. jw.Msg = "暂无生成文件!";
  4352. }
  4353. return Ok(jw);
  4354. }
  4355. /// <summary>
  4356. /// 删除该团组下的指定文件
  4357. /// </summary>
  4358. /// <param name="dto"></param>
  4359. /// <returns></returns>
  4360. [HttpPost]
  4361. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  4362. {
  4363. var jw = JsonView(false);
  4364. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  4365. if (sing == null)
  4366. {
  4367. jw.Msg = "暂无";
  4368. return Ok(jw);
  4369. }
  4370. if (System.IO.File.Exists(sing.FilePath))
  4371. {
  4372. try
  4373. {
  4374. System.IO.File.Delete(sing.FilePath);
  4375. }
  4376. catch (Exception ex)
  4377. {
  4378. jw.Msg = "删除失败!" + ex.Message;
  4379. return Ok(jw);
  4380. }
  4381. }
  4382. sing.IsDel = 1;
  4383. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  4384. sing.DeleteUserId = dto.UserId;
  4385. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  4386. jw = JsonView(true, "删除成功!");
  4387. return Ok(jw);
  4388. }
  4389. #endregion
  4390. #region 团组英文资料
  4391. /// <summary>
  4392. /// 查询团组英文所有资料
  4393. /// </summary>
  4394. /// <param name="dto"></param>
  4395. /// <returns></returns>
  4396. [HttpPost]
  4397. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4398. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  4399. {
  4400. try
  4401. {
  4402. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  4403. if (groupData.Code != 0)
  4404. {
  4405. return Ok(JsonView(false, groupData.Msg));
  4406. }
  4407. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4408. }
  4409. catch (Exception ex)
  4410. {
  4411. return Ok(JsonView(false, "程序错误!"));
  4412. throw;
  4413. }
  4414. }
  4415. /// <summary>
  4416. /// 团组英文资料操作(Status:1.新增,2.修改)
  4417. /// </summary>
  4418. /// <param name="dto"></param>
  4419. /// <returns></returns>
  4420. [HttpPost]
  4421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4422. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  4423. {
  4424. try
  4425. {
  4426. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  4427. if (groupData.Code != 0)
  4428. {
  4429. return Ok(JsonView(false, groupData.Msg));
  4430. }
  4431. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4432. }
  4433. catch (Exception ex)
  4434. {
  4435. return Ok(JsonView(false, "程序错误!"));
  4436. throw;
  4437. }
  4438. }
  4439. /// <summary>
  4440. /// 团组英文资料Id查询数据
  4441. /// </summary>
  4442. /// <param name="dto"></param>
  4443. /// <returns></returns>
  4444. [HttpPost]
  4445. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4446. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  4447. {
  4448. try
  4449. {
  4450. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  4451. if (_DelegationEnData != null)
  4452. {
  4453. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  4454. }
  4455. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  4456. }
  4457. catch (Exception ex)
  4458. {
  4459. return Ok(JsonView(false, "程序错误!"));
  4460. throw;
  4461. }
  4462. }
  4463. /// <summary>
  4464. /// 团组英文资料删除
  4465. /// </summary>
  4466. /// <param name="dto"></param>
  4467. /// <returns></returns>
  4468. [HttpPost]
  4469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4470. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  4471. {
  4472. try
  4473. {
  4474. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  4475. if (!res)
  4476. {
  4477. return Ok(JsonView(false, "删除失败"));
  4478. }
  4479. return Ok(JsonView(true, "删除成功!"));
  4480. }
  4481. catch (Exception ex)
  4482. {
  4483. return Ok(JsonView(false, "程序错误!"));
  4484. throw;
  4485. }
  4486. }
  4487. #endregion
  4488. #region 导出邀请函
  4489. /// <summary>
  4490. /// 导出邀请函页面初始化
  4491. /// </summary>
  4492. /// <param name="dto"></param>
  4493. /// <returns></returns>
  4494. [HttpPost]
  4495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4496. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  4497. {
  4498. try
  4499. {
  4500. List<Grp_DelegationInfo> grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.Id, OrderByType.Desc).ToList();
  4501. List<Crm_DeleClient> crm_Deles = new List<Crm_DeleClient>();
  4502. if (dto.DiId == 0)
  4503. {
  4504. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  4505. }
  4506. else
  4507. {
  4508. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  4509. }
  4510. return Ok(JsonView(true, "查询成功!", new
  4511. {
  4512. deleClient = crm_Deles,
  4513. delegations = grp_Delegations
  4514. }));
  4515. }
  4516. catch (Exception ex)
  4517. {
  4518. return Ok(JsonView(false, "程序错误!"));
  4519. throw;
  4520. }
  4521. }
  4522. /// <summary>
  4523. /// 导出邀请函
  4524. /// </summary>
  4525. /// <param name="dto"></param>
  4526. /// <returns></returns>
  4527. [HttpPost]
  4528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4529. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  4530. {
  4531. #region 参数验证
  4532. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  4533. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  4534. #endregion
  4535. try
  4536. {
  4537. Dictionary<string, string> transDic = new Dictionary<string, string>();
  4538. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  4539. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  4540. From Grp_TourClientList tcl
  4541. Left Join
  4542. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  4543. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  4544. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  4545. From Crm_DeleClient dc
  4546. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  4547. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  4548. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  4549. Where dc.IsDel = 0) temp
  4550. On temp.DcId =tcl.ClientId
  4551. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  4552. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  4553. List<string> texts = new List<string>();
  4554. if (datas.Count != 0)
  4555. {
  4556. foreach (TourClientListDetailsView item in datas)
  4557. {
  4558. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  4559. {
  4560. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  4561. }
  4562. else
  4563. {
  4564. string name = item.LastName + item.FirstName;
  4565. texts.Add(name);
  4566. }
  4567. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  4568. {
  4569. if (!transDic.ContainsKey(item.Job))
  4570. {
  4571. texts.Add(item.Job);
  4572. }
  4573. }
  4574. if (!string.IsNullOrEmpty(item.CompanyFullName))
  4575. {
  4576. texts.Add(item.CompanyFullName);
  4577. }
  4578. }
  4579. List<TranslateResult> transData = _airTicketResRep.ReTransBatch(texts, "en");
  4580. if (transData.Count > 0)
  4581. {
  4582. foreach (TranslateResult item in transData)
  4583. {
  4584. if (!transDic.ContainsKey(item.Query))
  4585. {
  4586. transDic.Add(item.Query, item.Translation);
  4587. }
  4588. }
  4589. }
  4590. List<GuestList> list = new List<GuestList>();
  4591. foreach (TourClientListDetailsView dele in datas)
  4592. {
  4593. GuestList guestList = new GuestList();
  4594. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  4595. {
  4596. guestList.Name = dele.Pinyin;
  4597. }
  4598. else
  4599. {
  4600. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  4601. guestList.Name = Name;
  4602. }
  4603. if (dele.Sex == 0)
  4604. {
  4605. guestList.Sex = "Male";
  4606. }
  4607. else if (dele.Sex == 1)
  4608. {
  4609. guestList.Sex = "Female";
  4610. }
  4611. guestList.DOB = dele.BirthDay.Replace('-', '.');
  4612. if (!string.IsNullOrEmpty(dele.Job))
  4613. {
  4614. guestList.Job = dele.Job;
  4615. }
  4616. list.Add(guestList);
  4617. }
  4618. //载入模板
  4619. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  4620. DocumentBuilder builder = new DocumentBuilder(doc);
  4621. //获取word里所有表格
  4622. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  4623. //获取所填表格的序数
  4624. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  4625. var rowStart = tableOne.Rows[0]; //获取第1行
  4626. //循环赋值
  4627. for (int i = 0; i < list.Count; i++)
  4628. {
  4629. builder.MoveToCell(0, i + 1, 0, 0);
  4630. builder.Write(list[i].Name.ToString());
  4631. builder.MoveToCell(0, i + 1, 1, 0);
  4632. builder.Write(list[i].Sex.ToString());
  4633. builder.MoveToCell(0, i + 1, 2, 0);
  4634. builder.Write(list[i].DOB.ToString());
  4635. builder.MoveToCell(0, i + 1, 3, 0);
  4636. builder.Write(list[i].Job.ToString());
  4637. }
  4638. //删除多余行
  4639. while (tableOne.Rows.Count > list.Count + 1)
  4640. {
  4641. tableOne.Rows.RemoveAt(list.Count + 1);
  4642. }
  4643. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  4644. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  4645. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  4646. doc.Save(filePath);
  4647. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  4648. return Ok(JsonView(true, "操作成功!", Url));
  4649. }
  4650. else
  4651. {
  4652. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  4653. }
  4654. }
  4655. catch (Exception ex)
  4656. {
  4657. return Ok(JsonView(false, ex.Message));
  4658. throw;
  4659. }
  4660. }
  4661. #endregion
  4662. #region 团组经理模块 出入境费用
  4663. /// <summary>
  4664. /// 团组模块 - 出入境费用 - 子项 地区更改为 nationalTravelFee 的id
  4665. /// </summary>
  4666. /// <returns></returns>
  4667. [HttpPost]
  4668. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4669. public async Task<IActionResult> SetDayAndCostAreaChange()
  4670. {
  4671. try
  4672. {
  4673. var nationalTravelFee = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  4674. var dayAndCost = await _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0).ToListAsync();
  4675. var unite = dayAndCost.Where(a => nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //交集
  4676. var merge = dayAndCost.Where(a => !nationalTravelFee.Any(b => a.Place.Trim() == b.City)).ToList(); //差集
  4677. foreach (var item in unite) //处理交集数据
  4678. {
  4679. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault().Id;
  4680. }
  4681. foreach (var item in merge) //处理差集数据
  4682. {
  4683. int nationalTravelFeeId = 0;
  4684. var cityData = nationalTravelFee.Where(it => it.City.Trim() == item.Place.Trim()).FirstOrDefault();
  4685. if (cityData != null) nationalTravelFeeId = cityData.Id;
  4686. else
  4687. {
  4688. var countryData = nationalTravelFee.Where(it => it.Country.Trim() == item.Place.Trim()).FirstOrDefault();
  4689. if (countryData != null) nationalTravelFeeId = countryData.Id;
  4690. }
  4691. dayAndCost.Where(it => it.Id == item.Id).FirstOrDefault().NationalTravelFeeId = nationalTravelFeeId;
  4692. }
  4693. //只更新dayAndCost 的 nationalTravelFeeId;
  4694. var result = _sqlSugar.Updateable(dayAndCost).UpdateColumns(it => new { it.NationalTravelFeeId }).ExecuteCommand();
  4695. if (result > 0) return Ok(JsonView(true, "nationalTravelFeeId列更新成功!"));
  4696. else return Ok(JsonView(false, "nationalTravelFeeId列更新失败!"));
  4697. }
  4698. catch (Exception ex)
  4699. {
  4700. return Ok(JsonView(false, ex.Message));
  4701. throw;
  4702. }
  4703. }
  4704. /// <summary>
  4705. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  4706. /// </summary>
  4707. /// <returns></returns>
  4708. [HttpPost]
  4709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4710. public async Task<IActionResult> GetEnterExitCostDataSource(PortDtoBase dto)
  4711. {
  4712. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  4713. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  4714. //SetDataInfoView
  4715. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  4716. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  4717. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  4718. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  4719. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  4720. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  4721. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  4722. //默认币种显示
  4723. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  4724. {
  4725. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  4726. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  4727. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  4728. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  4729. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  4730. };
  4731. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4732. if (_currencyRate.Count > 0)
  4733. {
  4734. foreach (var item in _currencyInfos)
  4735. {
  4736. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4737. if (rateInfo != null)
  4738. {
  4739. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  4740. rate1 *= 1.035M;
  4741. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4742. }
  4743. }
  4744. }
  4745. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  4746. return Ok(JsonView(true, "查询成功!", new
  4747. {
  4748. GroupNameData = groupNameData.Data,
  4749. CurrencyData = _CurrencyData,
  4750. WordTypeData = _WordTypeData,
  4751. ExcelTypeData = _ExcelTypeData,
  4752. CurrencyInit = _currencyInfos,
  4753. ViewPermissionData = viewPermissionData
  4754. }));
  4755. }
  4756. /// <summary>
  4757. /// 团组模块 - 出入境费用
  4758. /// 实时汇率 tips
  4759. /// 签证费用 tips
  4760. /// 机票费用 tips
  4761. /// </summary>
  4762. /// <returns></returns>
  4763. [HttpPost]
  4764. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4765. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  4766. {
  4767. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  4768. //默认币种显示
  4769. var _currencyInfos = _currencyInit;
  4770. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  4771. List<dynamic> reteInfos = new List<dynamic>();
  4772. if (_currencyRate.Count > 0)
  4773. {
  4774. foreach (var item in _currencyInfos)
  4775. {
  4776. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  4777. if (rateInfo != null)
  4778. {
  4779. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  4780. decimal rate1 = item.Rate;
  4781. rate1 *= 1.03M;
  4782. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  4783. reteInfos.Add(new
  4784. {
  4785. currCode = item.CurrencyCode,
  4786. currName = item.CurrencyName,
  4787. rate = rate2,
  4788. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  4789. });
  4790. }
  4791. }
  4792. }
  4793. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  4794. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  4795. return Ok(JsonView(true, "查询成功!", new
  4796. {
  4797. //GroupNameData = groupNameData.Data,
  4798. visaData = visaData.Data,
  4799. airData = airData.Data,
  4800. reteInfos = reteInfos
  4801. }));
  4802. }
  4803. /// <summary>
  4804. /// 团组模块 - 出入境费用 - Info
  4805. /// </summary>
  4806. /// <returns></returns>
  4807. [HttpPost]
  4808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4809. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  4810. {
  4811. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4812. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  4813. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  4814. }
  4815. /// <summary>
  4816. /// 团组模块 - 出入境费用 - 设置view权限
  4817. /// </summary>
  4818. /// <returns></returns>
  4819. [HttpPost]
  4820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4821. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  4822. {
  4823. if (dto.CurrUserId < 1) return Ok(JsonView(false,MsgTips.UserId));
  4824. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  4825. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  4826. var permissions = new List<Grp_EnterExitCostPermission>();
  4827. foreach (var userId in dto.UserIds)
  4828. {
  4829. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  4830. }
  4831. if (permissions.Any())
  4832. {
  4833. _sqlSugar.BeginTran();
  4834. try
  4835. {
  4836. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  4837. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  4838. if (result < 1)
  4839. {
  4840. _sqlSugar.RollbackTran();
  4841. return Ok(JsonView(false));
  4842. }
  4843. }
  4844. catch (Exception ex)
  4845. {
  4846. _sqlSugar.RollbackTran();
  4847. return Ok(JsonView(false, ex.Message));
  4848. }
  4849. _sqlSugar.CommitTran();
  4850. return Ok(JsonView(true));
  4851. }
  4852. return Ok(JsonView(false));
  4853. }
  4854. /// <summary>
  4855. /// 团组模块 - 出入境费用 - Add And Update
  4856. /// </summary>
  4857. /// <returns></returns>
  4858. [HttpPost]
  4859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4860. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  4861. {
  4862. try
  4863. {
  4864. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  4865. if (dto.DayOtherPriceData.Any())
  4866. {
  4867. var inserList = dto.DayOtherPriceData
  4868. .Where(x => x.Id == 0)
  4869. .Select(x => new Grp_DayOtherPrice
  4870. {
  4871. Cost = x.Cost,
  4872. Id = x.Id,
  4873. CreateTime = DateTime.Now,
  4874. CreateUserId = dto.UserId,
  4875. Currency = x.Currency,
  4876. Diid = x.DiId,
  4877. Index = x.Index,
  4878. IsDel = 0,
  4879. SetDataId = x.SetDataId,
  4880. SubTotal = x.SubTotal,
  4881. Remark = x.Remark
  4882. })
  4883. .ToList();
  4884. var updateList = dto.DayOtherPriceData
  4885. .Where(x => x.Id != 0)
  4886. .Select(x => new Grp_DayOtherPrice
  4887. {
  4888. Cost = x.Cost,
  4889. Id = x.Id,
  4890. CreateTime = DateTime.Now,
  4891. CreateUserId = dto.UserId,
  4892. Currency = x.Currency,
  4893. Diid = x.DiId,
  4894. Index = x.Index,
  4895. IsDel = 0,
  4896. SetDataId = x.SetDataId,
  4897. SubTotal = x.SubTotal,
  4898. Remark = x.Remark
  4899. })
  4900. .ToList();
  4901. //添加
  4902. _sqlSugar.BeginTran();
  4903. if (inserList.Any())
  4904. {
  4905. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  4906. }
  4907. if (updateList.Any())
  4908. {
  4909. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  4910. }
  4911. _sqlSugar.CommitTran();
  4912. }
  4913. if (data.Code != 0)
  4914. {
  4915. return Ok(JsonView(false, data.Msg));
  4916. }
  4917. //生成默认文件pdf并且通知人员
  4918. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  4919. {
  4920. DiId = dto.DiId,
  4921. ExportType = 1,
  4922. SubTypeId = 1005
  4923. }, "pdf");
  4924. //发送通知
  4925. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  4926. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  4927. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  4928. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  4929. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  4930. //汇率信息记录
  4931. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  4932. return Ok(JsonView(true, data.Msg, data.Data));
  4933. }
  4934. catch (Exception ex)
  4935. {
  4936. return Ok(JsonView(false, ex.Message));
  4937. }
  4938. }
  4939. /// <summary>
  4940. /// 团组模块 - 出入境费用 - Confirm 费用
  4941. /// </summary>
  4942. /// <returns></returns>
  4943. [HttpPost]
  4944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4945. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  4946. {
  4947. //TODO:测试完毕需把对应的用户ID更改
  4948. //1、数据表添加字段
  4949. //2、更改字段接口()
  4950. var _view = await _enterExitCostRep.ConfirmCost(dto);
  4951. //3、确认成功 给财务发送消息
  4952. if (_view.Code == 200)
  4953. {
  4954. if (dto.Type == 1)
  4955. {
  4956. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  4957. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  4958. }
  4959. }
  4960. return Ok(_view);
  4961. }
  4962. /// <summary>
  4963. /// 团组模块 - 出入境费用 - File download
  4964. /// </summary>
  4965. /// <param name="dto"></param>
  4966. /// <returns></returns>
  4967. [HttpPost]
  4968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4969. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  4970. {
  4971. try
  4972. {
  4973. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  4974. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  4975. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  4976. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  4977. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  4978. 3 团组成员名单 1 团组成员名单", ""));
  4979. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  4980. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  4981. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  4982. //数据源
  4983. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  4984. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  4985. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  4986. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  4987. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  4988. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  4989. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  4990. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  4991. .Select((x, a, b) => new
  4992. {
  4993. x.Index,
  4994. itemName = a.Name,
  4995. CurrencyStr = b.Name,
  4996. x.Cost,
  4997. x.SubTotal,
  4998. x.Remark
  4999. })
  5000. .OrderBy((x) => x.Index)
  5001. .ToList(); //其他款项费用
  5002. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  5003. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  5004. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  5005. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  5006. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  5007. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  5008. .Select((tcl, dc, cc) => new ClientInfo
  5009. {
  5010. LastName = dc.LastName,
  5011. FirstName = dc.FirstName,
  5012. Sex = dc.Sex,
  5013. Birthday = dc.BirthDay,
  5014. Company = cc.CompanyFullName,
  5015. Job = dc.Job
  5016. })
  5017. .ToList();
  5018. foreach (var item in DeleClientList)
  5019. {
  5020. EncryptionProcessor.DecryptProperties(item);
  5021. }
  5022. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  5023. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  5024. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  5025. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  5026. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  5027. if (dto.ExportType == 1) //明细表
  5028. {
  5029. if (dto.SubTypeId == 1005) //1005(默认明细表)
  5030. {
  5031. //获取模板
  5032. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  5033. //载入模板
  5034. Document doc = new Document(tempPath);
  5035. DocumentBuilder builder = new DocumentBuilder(doc);
  5036. //利用键值对存放数据
  5037. Dictionary<string, string> dic = new Dictionary<string, string>();
  5038. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  5039. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  5040. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  5041. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  5042. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  5043. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  5044. //境内费用(其他费用)
  5045. if (_EnterExitCosts.ChoiceOne == 1)
  5046. {
  5047. string row1_1 = "";
  5048. if (_EnterExitCosts.Visa > 0)
  5049. {
  5050. //insidePayTotal += _EnterExitCosts.Visa;
  5051. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  5052. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  5053. {
  5054. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  5055. }
  5056. }
  5057. string row1_2 = "";
  5058. if (_EnterExitCosts.YiMiao > 0)
  5059. {
  5060. //insidePayTotal += _EnterExitCosts.YiMiao;
  5061. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  5062. }
  5063. if (_EnterExitCosts.HeSuan > 0)
  5064. {
  5065. //insidePayTotal += _EnterExitCosts.HeSuan;
  5066. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  5067. }
  5068. if (_EnterExitCosts.Service > 0)
  5069. {
  5070. //insidePayTotal += _EnterExitCosts.Service;
  5071. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  5072. }
  5073. string row1_3 = "";
  5074. if (_EnterExitCosts.Safe > 0)
  5075. {
  5076. //insidePayTotal += _EnterExitCosts.Safe;
  5077. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  5078. }
  5079. if (_EnterExitCosts.Ticket > 0)
  5080. {
  5081. //insidePayTotal += _EnterExitCosts.Ticket;
  5082. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  5083. }
  5084. string row1 = "";
  5085. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  5086. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  5087. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  5088. row1 += $"备注:{_EnterExitCosts.Remark}";
  5089. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  5090. dic.Add("Row1Str", row1);
  5091. }
  5092. string airTotalStr = string.Empty,
  5093. airPriceStr = string.Empty;
  5094. //经济舱
  5095. if (_EnterExitCosts.SumJJC == 1)
  5096. {
  5097. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  5098. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  5099. }
  5100. //公务舱
  5101. if (_EnterExitCosts.SumGWC == 1)
  5102. {
  5103. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  5104. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  5105. }
  5106. //头等舱
  5107. if (_EnterExitCosts.SumTDC == 1)
  5108. {
  5109. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  5110. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  5111. }
  5112. string twoItemRemark = "备注:";
  5113. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  5114. {
  5115. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  5116. }
  5117. dic.Add("AirTotalStr", airTotalStr);
  5118. dic.Add("AirPriceStr", airPriceStr);
  5119. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5120. dic.Add("TwoItemRemark", twoItemRemark);
  5121. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5122. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5123. int table1Row = 0,
  5124. table2Row = 0,
  5125. table3Row = 0,
  5126. table4Row = 0,
  5127. table5Row = 0;
  5128. //住宿费
  5129. if (_EnterExitCosts.ChoiceThree == 1)
  5130. {
  5131. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  5132. table1Row = dac1.Count;
  5133. #region 填充word表格内容
  5134. for (int i = 0; i < dac1.Count; i++)
  5135. {
  5136. Grp_DayAndCost dac = dac1[i];
  5137. if (dac == null) continue;
  5138. builder.MoveToCell(0, i, 0, 0);
  5139. builder.Write("第" + dac.Days.ToString() + "晚:");
  5140. builder.MoveToCell(0, i, 1, 0);
  5141. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  5142. //builder.Write(dac.Place == null ? "" : dac.Place);
  5143. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5144. builder.MoveToCell(0, i, 2, 0);
  5145. builder.Write("费用标准:");
  5146. string curr = "";
  5147. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5148. if (currData != null)
  5149. {
  5150. curr = currData.Name;
  5151. }
  5152. builder.MoveToCell(0, i, 3, 0);
  5153. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5154. builder.MoveToCell(0, i, 4, 0);
  5155. builder.Write("费用小计:");
  5156. builder.MoveToCell(0, i, 5, 0);
  5157. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5158. }
  5159. #endregion
  5160. }
  5161. else dic.Add("SubZS", "0.00");
  5162. //删除多余行
  5163. while (table1.Rows.Count > table1Row)
  5164. {
  5165. table1.Rows.RemoveAt(table1Row);
  5166. }
  5167. //伙食费
  5168. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  5169. if (_EnterExitCosts.ChoiceFour == 1)
  5170. {
  5171. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  5172. table2Row = dac2.Count;
  5173. #region 填充word表格内容
  5174. for (int i = 0; i < dac2.Count; i++)
  5175. {
  5176. Grp_DayAndCost dac = dac2[i];
  5177. if (dac == null) continue;
  5178. builder.MoveToCell(1, i, 0, 0);
  5179. builder.Write("第" + dac.Days.ToString() + "天:");
  5180. builder.MoveToCell(1, i, 1, 0);
  5181. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5182. builder.MoveToCell(1, i, 2, 0);
  5183. builder.Write("费用标准:");
  5184. string curr = "";
  5185. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5186. if (currData != null)
  5187. {
  5188. curr = currData.Name;
  5189. }
  5190. builder.MoveToCell(1, i, 3, 0);
  5191. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5192. builder.MoveToCell(1, i, 4, 0);
  5193. builder.Write("费用小计:");
  5194. builder.MoveToCell(1, i, 5, 0);
  5195. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5196. }
  5197. #endregion
  5198. }
  5199. else dic.Add("SubHS", "0.00");
  5200. //删除多余行
  5201. while (table2.Rows.Count > table2Row)
  5202. {
  5203. table2.Rows.RemoveAt(table2Row);
  5204. }
  5205. //公杂费
  5206. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  5207. if (_EnterExitCosts.ChoiceFive == 1)
  5208. {
  5209. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  5210. table3Row = dac3.Count;
  5211. #region 填充word表格内容
  5212. for (int i = 0; i < dac3.Count; i++)
  5213. {
  5214. Grp_DayAndCost dac = dac3[i];
  5215. if (dac == null) continue;
  5216. builder.MoveToCell(2, i, 0, 0);
  5217. builder.Write("第" + dac.Days.ToString() + "天:");
  5218. builder.MoveToCell(2, i, 1, 0);
  5219. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5220. builder.MoveToCell(2, i, 2, 0);
  5221. builder.Write("费用标准:");
  5222. string curr = "";
  5223. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5224. if (currData != null)
  5225. {
  5226. curr = currData.Name;
  5227. }
  5228. builder.MoveToCell(2, i, 3, 0);
  5229. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5230. builder.MoveToCell(2, i, 4, 0);
  5231. builder.Write("费用小计:");
  5232. builder.MoveToCell(2, i, 5, 0);
  5233. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5234. }
  5235. //删除多余行
  5236. while (table3.Rows.Count > table3Row)
  5237. {
  5238. table3.Rows.RemoveAt(table3Row);
  5239. }
  5240. #endregion
  5241. }
  5242. else dic.Add("SubGZF", "0.00");
  5243. //删除多余行
  5244. while (table3.Rows.Count > table3Row)
  5245. {
  5246. table3.Rows.RemoveAt(table3Row);
  5247. }
  5248. //培训费
  5249. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  5250. if (_EnterExitCosts.ChoiceSix == 1)
  5251. {
  5252. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  5253. dic.Add("SubPX", pxStr);
  5254. table4Row = dac4.Count;
  5255. #region 填充word表格内容
  5256. for (int i = 0; i < dac4.Count; i++)
  5257. {
  5258. Grp_DayAndCost dac = dac4[i];
  5259. if (dac == null) continue;
  5260. builder.MoveToCell(3, i, 0, 0);
  5261. builder.Write("第" + dac.Days.ToString() + "天:");
  5262. builder.MoveToCell(3, i, 1, 0);
  5263. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5264. builder.MoveToCell(3, i, 2, 0);
  5265. builder.Write("费用标准:");
  5266. string curr = "";
  5267. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  5268. if (currData != null)
  5269. {
  5270. curr = currData.Name;
  5271. }
  5272. builder.MoveToCell(3, i, 3, 0);
  5273. builder.Write(dac.Cost.ToString("#0.00") + curr);
  5274. builder.MoveToCell(3, i, 4, 0);
  5275. builder.Write("费用小计:");
  5276. builder.MoveToCell(3, i, 5, 0);
  5277. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5278. }
  5279. #endregion
  5280. }
  5281. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  5282. //删除多余行
  5283. while (table4.Rows.Count > table4Row)
  5284. {
  5285. table4.Rows.RemoveAt(table4Row);
  5286. }
  5287. //其他费用
  5288. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  5289. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  5290. {
  5291. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  5292. dic.Add("titleQi", qtStr);
  5293. table5Row = dac5.Count;
  5294. #region 填充word表格内容
  5295. for (int i = 0; i < dac5.Count; i++)
  5296. {
  5297. var dac = dac5[i];
  5298. if (dac == null) continue;
  5299. builder.MoveToCell(4, i, 0, 0);
  5300. builder.Write("第" + dac.Index.ToString() + "项:");
  5301. builder.MoveToCell(4, i, 1, 0);
  5302. builder.Write(dac.itemName);
  5303. builder.MoveToCell(4, i, 2, 0);
  5304. builder.Write("费用标准:");
  5305. builder.MoveToCell(4, i, 3, 0);
  5306. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  5307. builder.MoveToCell(4, i, 4, 0);
  5308. builder.Write("费用小计:");
  5309. builder.MoveToCell(4, i, 5, 0);
  5310. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  5311. builder.MoveToCell(4, i, 6, 0);
  5312. builder.Write("备注:");
  5313. builder.MoveToCell(4, i, 7, 0);
  5314. builder.Write(dac.Remark);
  5315. }
  5316. #endregion
  5317. }
  5318. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  5319. //删除多余行
  5320. while (table5.Rows.Count > table5Row)
  5321. {
  5322. table5.Rows.RemoveAt(table5Row);
  5323. }
  5324. //加上其他费用
  5325. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  5326. decimal subJJC = 0.00M,
  5327. subGWC = 0.00M,
  5328. subTDC = 0.00M;
  5329. //经济舱
  5330. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  5331. //公务舱
  5332. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  5333. //头等舱
  5334. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  5335. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  5336. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  5337. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  5338. #region 填充word模板书签内容
  5339. foreach (var key in dic.Keys)
  5340. {
  5341. Bookmark bookmark = doc.Range.Bookmarks[key];
  5342. if (bookmark != null)
  5343. {
  5344. builder.MoveToBookmark(key);
  5345. builder.Write(dic[key]);
  5346. }
  5347. }
  5348. #endregion
  5349. #region 设置页眉
  5350. string userLabel = string.Empty;
  5351. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  5352. if (currUserInfo != null)
  5353. {
  5354. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  5355. if (userInfo != null)
  5356. {
  5357. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  5358. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  5359. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  5360. }
  5361. }
  5362. //设置页脚
  5363. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  5364. #endregion
  5365. //文件名
  5366. string strFileName = $"{_DelegationInfo.TeamName}出入境费用{Guid.NewGuid().ToString()}.docx";
  5367. AsposeHelper.removewatermark_v2180();
  5368. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5369. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5370. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5371. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5372. }
  5373. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  5374. {
  5375. //获取模板
  5376. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  5377. //载入模板
  5378. Document doc = new Document(tempPath);
  5379. DocumentBuilder builder = new DocumentBuilder(doc);
  5380. Dictionary<string, string> dic = new Dictionary<string, string>();
  5381. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5382. {
  5383. List<string> list = new List<string>();
  5384. try
  5385. {
  5386. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5387. foreach (var item in spilitArr)
  5388. {
  5389. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5390. var depCode = spDotandEmpty[2].Substring(0, 3);
  5391. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5392. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5393. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5394. list.Add(depName);
  5395. list.Add(arrName);
  5396. }
  5397. list = list.Distinct().ToList();
  5398. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5399. }
  5400. catch (Exception)
  5401. {
  5402. dic.Add("ReturnCode", "行程录入不正确!");
  5403. }
  5404. }
  5405. else
  5406. {
  5407. dic.Add("ReturnCode", "未录入行程!");
  5408. }
  5409. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5410. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5411. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5412. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5413. {
  5414. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5415. dic.Add("Day", sp.Days.ToString());
  5416. }
  5417. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5418. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5419. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5420. //dic.Add("Names", Names);
  5421. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5422. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5423. decimal dac1totalPrice = 0.00M;
  5424. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  5425. foreach (var dac in dac1)
  5426. {
  5427. if (dac.SubTotal == 0.00M)
  5428. {
  5429. continue;
  5430. }
  5431. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  5432. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  5433. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  5434. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5435. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  5436. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5437. builder.Write(currency);//币种
  5438. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  5439. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5440. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  5441. builder.Write("");//人数
  5442. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  5443. builder.Write("");//天数
  5444. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  5445. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5446. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  5447. decimal rate = 0.00M;
  5448. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5449. builder.Write(rate.ToString("#0.0000"));//汇率
  5450. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  5451. decimal rbmPrice = dac.SubTotal;
  5452. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5453. accommodationStartIndex++;
  5454. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5455. }
  5456. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5457. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  5458. {
  5459. table1.Rows.RemoveAt(i - 1);
  5460. foodandotherStartIndex--;
  5461. }
  5462. if (dac2.Count == dac3.Count)//国家 币种 金额
  5463. {
  5464. for (int i = 0; i < dac2.Count; i++)
  5465. {
  5466. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5467. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5468. }
  5469. }
  5470. decimal dac2totalPrice = 0.00M;
  5471. foreach (var dac in dac2)
  5472. {
  5473. if (dac.SubTotal == 0)
  5474. {
  5475. continue;
  5476. }
  5477. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  5478. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  5479. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  5480. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  5481. builder.Write(currency);//币种
  5482. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  5483. builder.Write(dac.Cost.ToString("#0.00"));//标准
  5484. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  5485. builder.Write("");//人数
  5486. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  5487. builder.Write("");//天数
  5488. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  5489. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  5490. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  5491. decimal rate = 0.00M;
  5492. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  5493. builder.Write(rate.ToString("#0.0000"));//汇率
  5494. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  5495. decimal rbmPrice = dac.SubTotal;
  5496. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  5497. foodandotherStartIndex++;
  5498. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  5499. }
  5500. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  5501. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  5502. {
  5503. table1.Rows.RemoveAt(i - 1);
  5504. }
  5505. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  5506. string otherFeeStr = "";
  5507. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  5508. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  5509. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  5510. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  5511. foreach (var otherInfo in dac5)
  5512. {
  5513. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5514. }
  5515. #endregion
  5516. if (otherFeeStr.Length > 0)
  5517. {
  5518. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  5519. otherFeeStr = $"({otherFeeStr})";
  5520. dic.Add("OtherFeeStr", otherFeeStr);
  5521. }
  5522. //总计
  5523. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  5524. //国际旅费
  5525. string outsideAir = string.Empty;
  5526. string allPriceAir = string.Empty;
  5527. if (_EnterExitCosts.SumJJC == 1)
  5528. {
  5529. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5530. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  5531. }
  5532. if (_EnterExitCosts.SumGWC == 1)
  5533. {
  5534. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  5535. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5536. }
  5537. if (_EnterExitCosts.SumTDC == 1)
  5538. {
  5539. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  5540. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  5541. }
  5542. dic.Add("InTravelPrice", $"({outsideAir})");
  5543. dic.Add("FinalSumPrice", $"({allPriceAir})");
  5544. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  5545. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  5546. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  5547. foreach (var key in dic.Keys)
  5548. {
  5549. builder.MoveToBookmark(key);
  5550. builder.Write(dic[key]);
  5551. }
  5552. //模板文件名
  5553. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  5554. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5555. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5556. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5557. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5558. }
  5559. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  5560. {
  5561. //获取模板
  5562. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  5563. //载入模板
  5564. WorkbookDesigner designer = new WorkbookDesigner();
  5565. designer.Workbook = new Workbook(tempPath);
  5566. Dictionary<string, string> dic = new Dictionary<string, string>();
  5567. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5568. {
  5569. List<string> list = new List<string>();
  5570. try
  5571. {
  5572. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5573. foreach (var item in spilitArr)
  5574. {
  5575. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5576. var depCode = spDotandEmpty[2].Substring(0, 3);
  5577. var arrCode = spDotandEmpty[2].Substring(3, 3);
  5578. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  5579. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  5580. list.Add(depName);
  5581. list.Add(arrName);
  5582. }
  5583. list = list.Distinct().ToList();
  5584. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5585. }
  5586. catch (Exception)
  5587. {
  5588. dic.Add("ReturnCode", "行程录入不正确!");
  5589. }
  5590. }
  5591. else
  5592. {
  5593. dic.Add("ReturnCode", "未录入行程!");
  5594. }
  5595. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5596. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5597. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5598. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5599. {
  5600. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5601. dic.Add("Day", sp.Days.ToString());
  5602. }
  5603. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5604. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5605. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  5606. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  5607. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  5608. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  5609. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  5610. designer.SetDataSource("Name", Names);
  5611. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  5612. designer.SetDataSource("Day", dic["Day"] + "天");
  5613. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  5614. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  5615. int startIndex = 10;
  5616. const int startIndexcopy = 10;
  5617. if (dac2.Count == dac3.Count)//国家 币种 金额
  5618. {
  5619. for (int i = 0; i < dac2.Count; i++)
  5620. {
  5621. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  5622. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  5623. }
  5624. }
  5625. DataTable dtdac1 = new DataTable();
  5626. List<string> place = new List<string>();
  5627. dtdac1.Columns.AddRange(new DataColumn[] {
  5628. new DataColumn(){ ColumnName = "city"},
  5629. new DataColumn(){ ColumnName = "curr"},
  5630. new DataColumn(){ ColumnName = "criterion"},
  5631. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5632. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5633. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5634. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5635. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  5636. });
  5637. DataTable dtdac2 = new DataTable();
  5638. dtdac2.Columns.AddRange(new DataColumn[] {
  5639. new DataColumn(){ ColumnName = "city"},
  5640. new DataColumn(){ ColumnName = "curr"},
  5641. new DataColumn(){ ColumnName = "criterion"},
  5642. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  5643. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  5644. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  5645. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  5646. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  5647. });
  5648. dtdac1.TableName = "tb1";
  5649. dtdac2.TableName = "tb2";
  5650. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  5651. foreach (var item in dac1)
  5652. {
  5653. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5654. if (place.Contains(item.Place))
  5655. {
  5656. continue;
  5657. }
  5658. DataRow row = dtdac1.NewRow();
  5659. row["city"] = item.Place;
  5660. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5661. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5662. row["curr"] = currency;
  5663. row["rate"] = rate.ToString("#0.0000");
  5664. row["criterion"] = item.Cost.ToString("#0.00");
  5665. row["number"] = 1;
  5666. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5667. //row["costRMB"] = rbmPrice;
  5668. dtdac1.Rows.Add(row);
  5669. place.Add(item.Place);
  5670. }
  5671. place = new List<string>();
  5672. foreach (var item in dac2)
  5673. {
  5674. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  5675. if (place.Contains(item.Place))
  5676. {
  5677. continue;
  5678. }
  5679. DataRow row = dtdac2.NewRow();
  5680. row["city"] = item.Place;
  5681. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  5682. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  5683. row["curr"] = currency;
  5684. row["rate"] = rate.ToString("#0.0000");
  5685. row["criterion"] = item.Cost.ToString("#0.00");
  5686. row["number"] = 1;
  5687. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  5688. //row["cost"] = item.SubTotal;
  5689. //row["costRMB"] = rbmPrice;
  5690. dtdac2.Rows.Add(row);
  5691. place.Add(item.Place);
  5692. //dac2totalPrice += rbmPrice;
  5693. }
  5694. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  5695. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  5696. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  5697. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  5698. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  5699. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  5700. string cell4Str1 = string.Empty;
  5701. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  5702. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  5703. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  5704. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  5705. string cellStr = $" 5.其他费用(";
  5706. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  5707. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  5708. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  5709. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  5710. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  5711. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  5712. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  5713. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  5714. foreach (var otherInfo in dac5)
  5715. {
  5716. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  5717. }
  5718. #endregion
  5719. if (cellStr.Length > 8)
  5720. {
  5721. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  5722. }
  5723. cellStr += ")";
  5724. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  5725. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  5726. decimal pxFee = dac4.Sum(it => it.Cost);
  5727. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  5728. string celllastStr1 = "";
  5729. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  5730. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  5731. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  5732. celllastStr1 += $",国际旅费 元";
  5733. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  5734. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  5735. designer.SetDataSource("cell4Str", cell4Str);
  5736. designer.SetDataSource("cellStr", cellStr);
  5737. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  5738. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  5739. designer.SetDataSource("celllastStr", celllastStr);
  5740. Workbook wb = designer.Workbook;
  5741. var sheet = wb.Worksheets[0];
  5742. //绑定datatable数据集
  5743. designer.SetDataSource(dtdac1);
  5744. designer.SetDataSource(dtdac2);
  5745. designer.Process();
  5746. var rowStart = dtdac1.Rows.Count;
  5747. while (rowStart > 0)
  5748. {
  5749. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  5750. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5751. startIndex++;
  5752. rowStart--;
  5753. }
  5754. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  5755. startIndex += 1; //总计行
  5756. rowStart = dtdac2.Rows.Count;
  5757. while (rowStart > 0)
  5758. {
  5759. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  5760. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  5761. startIndex++;
  5762. rowStart--;
  5763. }
  5764. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  5765. wb.CalculateFormula(true);
  5766. //模板文件名
  5767. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  5768. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5769. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5770. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5771. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5772. }
  5773. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  5774. {
  5775. //获取模板
  5776. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  5777. //载入模板
  5778. Document doc = new Document(tempPath);
  5779. DocumentBuilder builder = new DocumentBuilder(doc);
  5780. Dictionary<string, string> dic = new Dictionary<string, string>();
  5781. dic.Add("GroupName", _DelegationInfo.TeamName);
  5782. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5783. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  5784. string missionLeaderJob = "";//负责人job
  5785. int groupNumber = 0; //团人数
  5786. if (DeleClientList.Count > 0)
  5787. {
  5788. missionLeader = DeleClientList[0]?.Name ?? "";
  5789. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  5790. }
  5791. dic.Add("MissionLeader", missionLeader); //团负责人
  5792. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  5793. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  5794. #region MyRegion
  5795. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  5796. //{
  5797. // List<string> list = new List<string>();
  5798. // try
  5799. // {
  5800. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  5801. // foreach (var item in spilitArr)
  5802. // {
  5803. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  5804. // var depCode = spDotandEmpty[2].Substring(0, 3);
  5805. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  5806. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  5807. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  5808. // list.Add(depName);
  5809. // list.Add(arrName);
  5810. // }
  5811. // list = list.Distinct().ToList();
  5812. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  5813. // }
  5814. // catch (Exception)
  5815. // {
  5816. // dic.Add("ReturnCode", "行程录入不正确!");
  5817. // }
  5818. //}
  5819. //else
  5820. //{
  5821. // dic.Add("ReturnCode", "未录入行程!");
  5822. //}
  5823. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  5824. dic.Add("ReturnCode", string.Join("、", countrys));
  5825. #endregion
  5826. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  5827. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5828. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5829. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  5830. //{
  5831. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5832. // dic.Add("Day", sp.Days.ToString());
  5833. //}
  5834. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  5835. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  5836. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5837. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5838. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5839. //培训人员名单
  5840. int cultivateRowIndex = 7;
  5841. foreach (var item in DeleClientList)
  5842. {
  5843. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  5844. builder.Write(item.Name);
  5845. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  5846. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  5847. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  5848. string birthDay = "";
  5849. if (item.Birthday != null)
  5850. {
  5851. DateTime dt = Convert.ToDateTime(item.Birthday);
  5852. birthDay = $"{dt.Year}.{dt.Month}";
  5853. }
  5854. builder.Write(birthDay);
  5855. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  5856. builder.Write(item.Company);
  5857. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  5858. builder.Write(item.Job);
  5859. cultivateRowIndex++;
  5860. }
  5861. //删除多余行
  5862. //cultivateRowIndex -= 2;
  5863. int delRows = 10 + 7 - cultivateRowIndex;
  5864. if (delRows > 0)
  5865. {
  5866. for (int i = 0; i < delRows; i++)
  5867. {
  5868. table1.Rows.RemoveAt(cultivateRowIndex);
  5869. //cultivateRowIndex++;
  5870. }
  5871. }
  5872. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  5873. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  5874. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  5875. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  5876. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  5877. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  5878. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  5879. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  5880. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  5881. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  5882. //其他费用
  5883. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  5884. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  5885. //其他费用合计
  5886. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  5887. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  5888. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  5889. //公务舱合计
  5890. //国际旅费
  5891. string outsideJJ = "";
  5892. string allPriceJJ = "";
  5893. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  5894. {
  5895. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  5896. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  5897. }
  5898. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  5899. {
  5900. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  5901. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  5902. }
  5903. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  5904. {
  5905. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  5906. dic.Add("AirFeeTotal", airFeeTotalStr);
  5907. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  5908. dic.Add("FeeTotal", feeTotalStr);
  5909. }
  5910. foreach (var key in dic.Keys)
  5911. {
  5912. builder.MoveToBookmark(key);
  5913. builder.Write(dic[key]);
  5914. }
  5915. //模板文件名
  5916. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  5917. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5918. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5919. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  5920. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  5921. }
  5922. }
  5923. else if (dto.ExportType == 2) //表格
  5924. {
  5925. //利用键值对存放数据
  5926. Dictionary<string, string> dic = new Dictionary<string, string>();
  5927. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  5928. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  5929. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  5930. dic.Add("Day", sp.Days.ToString());
  5931. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  5932. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  5933. {
  5934. //获取模板
  5935. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  5936. //载入模板
  5937. Document doc = new Document(tempPath);
  5938. DocumentBuilder builder = new DocumentBuilder(doc);
  5939. dic.Add("TeamName", _DelegationInfo.TeamName);
  5940. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  5941. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  5942. string missionLeaderName = "",
  5943. missionLeaderJob = "";
  5944. if (DeleClientList.Count > 0)
  5945. {
  5946. missionLeaderName = DeleClientList[0].Name;
  5947. missionLeaderJob = DeleClientList[0].Job;
  5948. }
  5949. dic.Add("MissionLeaderName", missionLeaderName);
  5950. dic.Add("MissionLeaderJob", missionLeaderJob);
  5951. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  5952. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  5953. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  5954. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  5955. int rowCount = 10;//总人数行
  5956. int startRowIndex = 7; //起始行
  5957. for (int i = 0; i < DeleClientList.Count; i++)
  5958. {
  5959. builder.MoveToCell(0, startRowIndex, 0, 0);
  5960. builder.Write(DeleClientList[i].Name); //出国人员姓名
  5961. builder.MoveToCell(0, startRowIndex, 1, 0);
  5962. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  5963. builder.Write(sex);//性别
  5964. builder.MoveToCell(0, startRowIndex, 2, 0);
  5965. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  5966. builder.MoveToCell(0, startRowIndex, 3, 0);
  5967. builder.Write(DeleClientList[i].Company);//工作单位
  5968. builder.MoveToCell(0, startRowIndex, 4, 0);
  5969. builder.Write(DeleClientList[i].Job);//职务及级别
  5970. builder.MoveToCell(0, startRowIndex, 5, 0);
  5971. builder.Write("");//人员属性
  5972. builder.MoveToCell(0, startRowIndex, 6, 0);
  5973. builder.Write("");//上次出国时间
  5974. startRowIndex++;
  5975. }
  5976. int nullRow = rowCount - DeleClientList.Count;//空行
  5977. for (int i = 0; i < nullRow; i++)
  5978. {
  5979. table1.Rows.Remove(table1.Rows[startRowIndex]);
  5980. }
  5981. foreach (var key in dic.Keys)
  5982. {
  5983. builder.MoveToBookmark(key);
  5984. builder.Write(dic[key]);
  5985. }
  5986. //模板文件名
  5987. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  5988. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  5989. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  5990. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  5991. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  5992. }
  5993. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  5994. {
  5995. //获取模板
  5996. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  5997. //载入模板
  5998. Document doc = new Document(tempPath);
  5999. DocumentBuilder builder = new DocumentBuilder(doc);
  6000. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  6001. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  6002. dic.Add("Names", Names);
  6003. int accommodationRows = 12, foodandotherRows = 12;
  6004. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6005. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  6006. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6007. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6008. int accommodationStartIndex = 6;
  6009. decimal dac1totalPrice = 0.00M;
  6010. foreach (var dac in dac1)
  6011. {
  6012. if (dac.SubTotal == 0)
  6013. {
  6014. continue;
  6015. }
  6016. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  6017. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  6018. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6019. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6020. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  6021. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6022. builder.Write(currency);//币种
  6023. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  6024. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6025. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  6026. builder.Write("");//人数
  6027. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  6028. builder.Write("");//天数
  6029. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  6030. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6031. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  6032. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6033. builder.Write(rate.ToString("#0.0000"));//汇率
  6034. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6035. decimal rbmPrice = rate * dac.SubTotal;
  6036. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6037. accommodationStartIndex++;
  6038. dac1totalPrice += rbmPrice;
  6039. }
  6040. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  6041. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  6042. builder.Write("小计");
  6043. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  6044. builder.Write(dac1totalPrice.ToString("#0.00"));
  6045. accommodationStartIndex++;
  6046. int nullRow = accommodationRows - dac1.Count;
  6047. //删除空行
  6048. //if (nullRow > 0)
  6049. //{
  6050. // int rowIndex = accommodationStartIndex;
  6051. // for (int i = 0; i < nullRow; i++)
  6052. // {
  6053. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  6054. // row.Remove();
  6055. // rowIndex++;
  6056. // }
  6057. //}
  6058. if (dac2.Count == dac3.Count)//国家 币种 金额
  6059. {
  6060. for (int i = 0; i < dac2.Count; i++)
  6061. {
  6062. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  6063. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  6064. }
  6065. }
  6066. int foodandotherStartIndex = 19;//
  6067. decimal dac2totalPrice = 0.00M;
  6068. foreach (var dac in dac2)
  6069. {
  6070. if (dac.SubTotal == 0)
  6071. {
  6072. continue;
  6073. }
  6074. //foodandotherStartIndex = 12;
  6075. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  6076. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  6077. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  6078. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  6079. builder.Write(currency);//币种
  6080. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  6081. builder.Write(dac.Cost.ToString("#0.00"));//标准
  6082. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  6083. builder.Write("");//人数
  6084. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  6085. builder.Write("");//天数
  6086. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  6087. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  6088. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  6089. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  6090. builder.Write(rate.ToString("#0.0000"));//汇率
  6091. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  6092. decimal rbmPrice = rate * dac.SubTotal;
  6093. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  6094. foodandotherStartIndex++;
  6095. dac2totalPrice += rbmPrice;
  6096. }
  6097. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  6098. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6099. //删除空行
  6100. //if (dac2.Count < foodandotherRows)
  6101. //{
  6102. // while (table2.Rows.Count > dac2.Count)
  6103. // {
  6104. // table2.Rows.RemoveAt(dac2.Count);
  6105. // }
  6106. //}
  6107. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6108. string otherFeeStr = "";
  6109. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  6110. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  6111. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  6112. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  6113. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  6114. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  6115. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  6116. foreach (var otherInfo in dac5)
  6117. {
  6118. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  6119. }
  6120. #endregion
  6121. if (otherFeeStr.Length > 0)
  6122. {
  6123. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  6124. otherFeeStr = $"({otherFeeStr})";
  6125. dic.Add("OtherFeeStr", otherFeeStr);
  6126. }
  6127. foreach (var key in dic.Keys)
  6128. {
  6129. builder.MoveToBookmark(key);
  6130. builder.Write(dic[key]);
  6131. }
  6132. //模板文件名
  6133. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  6134. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6135. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6136. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6137. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6138. }
  6139. }
  6140. else if (dto.ExportType == 3)
  6141. {
  6142. if (dto.SubTypeId == 1) //团组成员名单
  6143. {
  6144. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  6145. //获取模板
  6146. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  6147. //载入模板
  6148. Document doc = new Document(tempPath);
  6149. DocumentBuilder builder = new DocumentBuilder(doc);
  6150. //获取word里所有表格
  6151. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6152. //获取所填表格的序数
  6153. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  6154. var rowStart = tableOne.Rows[0]; //获取第1行
  6155. //循环赋值
  6156. for (int i = 0; i < DeleClientList.Count; i++)
  6157. {
  6158. builder.MoveToCell(0, i + 1, 0, 0);
  6159. builder.Write(DeleClientList[i].Name);
  6160. builder.MoveToCell(0, i + 1, 1, 0);
  6161. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  6162. builder.Write(sex);
  6163. builder.MoveToCell(0, i + 1, 2, 0);
  6164. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  6165. builder.MoveToCell(0, i + 1, 3, 0);
  6166. builder.Write(DeleClientList[i].Company);
  6167. builder.MoveToCell(0, i + 1, 4, 0);
  6168. builder.Write(DeleClientList[i].Job);
  6169. }
  6170. //删除多余行
  6171. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  6172. {
  6173. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  6174. }
  6175. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  6176. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  6177. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  6178. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  6179. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  6180. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  6181. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  6182. }
  6183. }
  6184. return Ok(JsonView(400, "操作失败!", ""));
  6185. }
  6186. catch (Exception ex)
  6187. {
  6188. return Ok(JsonView(400, ex.Message, ""));
  6189. }
  6190. }
  6191. /// <summary>
  6192. /// 获取三公费用标准city
  6193. /// </summary>
  6194. /// <param name="placeData"></param>
  6195. /// <param name="nationalTravelFeeId"></param>
  6196. /// <returns></returns>
  6197. private string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  6198. {
  6199. string _city = string.Empty;
  6200. if (placeData.Count < 1) return _city;
  6201. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  6202. if (data == null) return _city;
  6203. string country = data.Country;
  6204. string city = data.City;
  6205. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  6206. else _city = city;
  6207. return _city;
  6208. }
  6209. /// <summary>
  6210. /// 团组模块 - 出入境费用 - 明细表导出
  6211. /// </summary>
  6212. /// <returns></returns>
  6213. [HttpPost]
  6214. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6215. public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  6216. {
  6217. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  6218. if (data.Code != 0)
  6219. {
  6220. return Ok(JsonView(false, data.Msg));
  6221. }
  6222. return Ok(JsonView(true, data.Msg, data.Data));
  6223. }
  6224. /// <summary>
  6225. /// 团组模块 - 出入境费用 - 一键清空
  6226. /// </summary>
  6227. /// <returns></returns>
  6228. [HttpPost]
  6229. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6230. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  6231. {
  6232. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  6233. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  6234. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  6235. var _view = await _enterExitCostRep._OneClickClear(dto.Id, dto.DiId, dto.UserId);
  6236. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  6237. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  6238. .SetColumns(x => new Grp_DayOtherPrice
  6239. {
  6240. IsDel = 1,
  6241. DeleteUserId = dto.UserId,
  6242. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6243. })
  6244. .ExecuteCommandAsync();
  6245. if (_view.Code == 0)
  6246. {
  6247. return Ok(JsonView(true, "操作成功"));
  6248. }
  6249. return Ok(JsonView(false, "操作失败"));
  6250. }
  6251. /// <summary>
  6252. /// 团组模块 - 出入境费用 - 子项删除
  6253. /// </summary>
  6254. /// <returns></returns>
  6255. [HttpPost]
  6256. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6257. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  6258. {
  6259. try
  6260. {
  6261. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  6262. if (data.Code != 0)
  6263. {
  6264. return Ok(JsonView(false, data.Msg));
  6265. }
  6266. return Ok(JsonView(true, "操作成功!", data.Data));
  6267. }
  6268. catch (Exception ex)
  6269. {
  6270. return Ok(JsonView(false, ex.Message));
  6271. }
  6272. }
  6273. /// <summary>
  6274. /// 删除三公其他费用
  6275. /// </summary>
  6276. /// <param name="dto"></param>
  6277. /// <returns></returns>
  6278. [HttpPost]
  6279. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  6280. {
  6281. var jw = JsonView(false,"删除失败!");
  6282. var data = new Grp_DayOtherPrice()
  6283. {
  6284. Id = dto.Id,
  6285. IsDel = 1,
  6286. DeleteUserId = dto.DeleteUserId,
  6287. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  6288. };
  6289. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  6290. if (del > 0)
  6291. {
  6292. jw.Code = 200;
  6293. jw.Msg = "删除成功!";
  6294. }
  6295. return Ok(jw);
  6296. }
  6297. /// <summary>
  6298. /// 团组模块 - 出入境国家费用标准 List
  6299. /// </summary>
  6300. /// <returns></returns>
  6301. [HttpPost]
  6302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6303. public async Task<IActionResult> GetNationalTravelFeeData(PortDtoBase dto)
  6304. {
  6305. try
  6306. {
  6307. Stopwatch sw = new Stopwatch();
  6308. sw.Start();
  6309. string nationalTravelFeeSql = string.Format(@"Select ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.* From Grp_NationalTravelFee gntf
  6310. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6311. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6312. Where gntf.Isdel = 0");
  6313. var nationalTravelFeeData = _sqlSugar.SqlQueryable<NationalTravelFeeInfoView>(nationalTravelFeeSql).ToList();
  6314. //var nationalTravel = nationalTravelFeeData.GroupBy(it => it.Country).Select(it1 => it1.FirstOrDefault());
  6315. //List<dynamic> nationalTravelFeeData1 = new List<dynamic>();
  6316. //foreach (var item in nationalTravel)
  6317. //{
  6318. // var cityData = nationalTravelFeeData.Where(it => it.Country == item.Country).ToList();
  6319. // var otherData = cityData.Where(it => it.City.Contains("其他城市")).FirstOrDefault();
  6320. // if (otherData != null)
  6321. // {
  6322. // cityData.Remove(otherData);
  6323. // cityData.Add(otherData);
  6324. // }
  6325. // nationalTravelFeeData1.Add(new
  6326. // {
  6327. // Country = item.Country,
  6328. // CityData = cityData
  6329. // });
  6330. //}
  6331. sw.Stop();
  6332. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", nationalTravelFeeData));
  6333. }
  6334. catch (Exception ex)
  6335. {
  6336. return Ok(JsonView(false, ex.Message));
  6337. throw;
  6338. }
  6339. }
  6340. /// <summary>
  6341. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  6342. /// </summary>
  6343. /// <returns></returns>
  6344. [HttpPost]
  6345. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6346. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  6347. {
  6348. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  6349. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  6350. List<string> countryData = new List<string>();
  6351. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country).ToList());
  6352. countryData = countryData.Distinct().ToList();
  6353. List<dynamic> dataSource = new List<dynamic>();
  6354. foreach (var item in countryData)
  6355. {
  6356. List<string> cityData1 = new List<string>();
  6357. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City).ToList();
  6358. var countryData2 = new
  6359. {
  6360. CountryName = item,
  6361. CityData = cityData1
  6362. };
  6363. dataSource.Add(countryData2);
  6364. }
  6365. return Ok(JsonView(true, "查询成功!", dataSource));
  6366. }
  6367. /// <summary>
  6368. /// 团组模块 - 出入境国家费用标准 Page List
  6369. /// </summary>
  6370. /// <returns></returns>
  6371. [HttpPost]
  6372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6373. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  6374. {
  6375. int portId = dto.PortType;
  6376. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6377. if (dto.PageIndex == 0) return Ok(JsonView(false, "当前页码数不能为0!"));
  6378. if (dto.PageSize == 0) return Ok(JsonView(false, "每页条数不能0!"));
  6379. string whereSql = string.Empty;
  6380. if (!string.IsNullOrEmpty(dto.Country))
  6381. {
  6382. whereSql += string.Format(@" And gntf.Country ='{0}'", dto.Country);
  6383. }
  6384. if (!string.IsNullOrEmpty(dto.City))
  6385. {
  6386. whereSql += string.Format(@" And gntf.City='{0}'", dto.City);
  6387. }
  6388. string pageSql = string.Format(@"Select * From (
  6389. Select row_number() over(order by gntf.LastUpdateTime Desc) as RowNumber,
  6390. ssd.Name as CurrencyCode, ssd.Remark as CurrencyName,su.CnName as LastUpdateUserName,gntf.*
  6391. From Grp_NationalTravelFee gntf
  6392. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6393. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6394. Where gntf.Isdel = 0 {0} ) temp ", whereSql);
  6395. RefAsync<int> total = 0;
  6396. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeePageInfoView>(pageSql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  6397. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  6398. }
  6399. /// <summary>
  6400. /// 团组模块 - 出入境国家费用标准 根据城市查询
  6401. /// </summary>
  6402. /// <returns></returns>
  6403. [HttpPost]
  6404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6405. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  6406. {
  6407. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  6408. int portId = dto.PortType;
  6409. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  6410. string whereSql = string.Empty;
  6411. if (!string.IsNullOrEmpty(dto.Country))
  6412. {
  6413. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  6414. }
  6415. if (!string.IsNullOrEmpty(dto.City))
  6416. {
  6417. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  6418. }
  6419. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  6420. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,
  6421. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  6422. From Grp_NationalTravelFee gntf
  6423. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  6424. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  6425. Where gntf.Isdel = 0 {0} ", whereSql);
  6426. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  6427. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  6428. }
  6429. /// <summary>
  6430. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  6431. /// </summary>
  6432. /// <returns></returns>
  6433. [HttpPost]
  6434. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6435. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  6436. {
  6437. var data = await _enterExitCostRep.PostNationalTravelFeeOperate(dto);
  6438. if (data.Code != 0)
  6439. {
  6440. return Ok(JsonView(false, data.Msg));
  6441. }
  6442. return Ok(JsonView(true, "操作成功!", data.Data));
  6443. }
  6444. /// <summary>
  6445. /// 团组模块 - 出入境国家费用标准 - Del
  6446. /// </summary>
  6447. /// <returns></returns>
  6448. [HttpPost]
  6449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6450. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  6451. {
  6452. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  6453. {
  6454. Id = dto.Id,
  6455. DeleteUserId = dto.DeleteUserId,
  6456. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  6457. IsDel = 1
  6458. };
  6459. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  6460. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  6461. .WhereColumns(it => new { it.Id })
  6462. .ExecuteCommandAsync();
  6463. if (delStatus <= 0)
  6464. {
  6465. return Ok(JsonView(false, "删除失败!"));
  6466. }
  6467. return Ok(JsonView(true, "操作成功!"));
  6468. }
  6469. /// <summary>
  6470. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  6471. /// 注:Get 请求Headers 加 Token
  6472. /// </summary>
  6473. /// <param name="groupId"></param>
  6474. /// <returns></returns>
  6475. [HttpGet("{groupId}")]
  6476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6477. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  6478. {
  6479. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  6480. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  6481. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  6482. data.ForEach(x =>
  6483. {
  6484. x.CreateUserId = _currUserInfo.UserId;
  6485. });
  6486. if (data.Any())
  6487. {
  6488. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  6489. if (add > 0)
  6490. {
  6491. return Ok(JsonView(true, "操作成功!"));
  6492. }
  6493. }
  6494. return Ok(JsonView(false, "未操作!"));
  6495. }
  6496. #endregion
  6497. #region 团组经理模块 出入境费用-草稿
  6498. /// <summary>
  6499. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  6500. /// </summary>
  6501. /// <returns></returns>
  6502. [HttpPost]
  6503. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6504. public async Task<IActionResult> EnterExitCostDraftDataSource(PortDtoBase dto)
  6505. {
  6506. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  6507. .Where(x => x.IsDel == 0)
  6508. .OrderByDescending(x => x.CreateTime)
  6509. .Select(x => new { x.Id, x.DraftName })
  6510. .ToListAsync();
  6511. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  6512. //SetDataInfoView
  6513. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  6514. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  6515. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  6516. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  6517. var _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  6518. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  6519. var _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  6520. //默认币种显示
  6521. List<CurrencyInfo> _currencyInfos = new List<CurrencyInfo>()
  6522. {
  6523. new CurrencyInfo (){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  6524. new CurrencyInfo (){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  6525. new CurrencyInfo (){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  6526. new CurrencyInfo (){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  6527. new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  6528. };
  6529. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6530. if (_currencyRate.Count > 0)
  6531. {
  6532. foreach (var item in _currencyInfos)
  6533. {
  6534. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6535. if (rateInfo != null)
  6536. {
  6537. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  6538. rate1 *= 1.035M;
  6539. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6540. }
  6541. }
  6542. }
  6543. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  6544. return Ok(JsonView(true, "查询成功!", new
  6545. {
  6546. DraftNameDatas = draftNameDatas,
  6547. CurrencyData = _CurrencyData,
  6548. WordTypeData = _WordTypeData,
  6549. ExcelTypeData = _ExcelTypeData,
  6550. CurrencyInit = _currencyInfos,
  6551. ViewPermissionData = viewPermissionData
  6552. }));
  6553. }
  6554. /// <summary>
  6555. /// 团组模块 - 出入境费用-草稿
  6556. /// 实时汇率 tips
  6557. /// 签证费用 tips
  6558. /// 机票费用 tips
  6559. /// </summary>
  6560. /// <returns></returns>
  6561. [HttpPost]
  6562. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6563. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  6564. {
  6565. //var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  6566. //默认币种显示
  6567. var _currencyInfos = _currencyInit;
  6568. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  6569. List<dynamic> reteInfos = new List<dynamic>();
  6570. if (_currencyRate.Count > 0)
  6571. {
  6572. foreach (var item in _currencyInfos)
  6573. {
  6574. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  6575. if (rateInfo != null)
  6576. {
  6577. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  6578. decimal rate1 = item.Rate;
  6579. rate1 *= 1.03M;
  6580. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  6581. reteInfos.Add(new
  6582. {
  6583. currCode = item.CurrencyCode,
  6584. currName = item.CurrencyName,
  6585. rate = rate2,
  6586. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  6587. });
  6588. }
  6589. }
  6590. }
  6591. //var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
  6592. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  6593. return Ok(JsonView(true, "查询成功!", new
  6594. {
  6595. //GroupNameData = groupNameData.Data,
  6596. //visaData = visaData.Data,
  6597. //airData = airData.Data,
  6598. reteInfos = reteInfos
  6599. }));
  6600. }
  6601. /// <summary>
  6602. /// 团组模块 - 出入境费用-草稿 - Info
  6603. /// </summary>
  6604. /// <returns></returns>
  6605. [HttpPost]
  6606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6607. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  6608. {
  6609. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  6610. }
  6611. /// <summary>
  6612. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  6613. /// </summary>
  6614. /// <returns></returns>
  6615. [HttpPost]
  6616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6617. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  6618. {
  6619. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  6620. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  6621. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  6622. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  6623. foreach (var userId in dto.UserIds)
  6624. {
  6625. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  6626. }
  6627. if (permissions.Any())
  6628. {
  6629. _sqlSugar.BeginTran();
  6630. try
  6631. {
  6632. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  6633. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  6634. if (result < 1)
  6635. {
  6636. _sqlSugar.RollbackTran();
  6637. return Ok(JsonView(false));
  6638. }
  6639. }
  6640. catch (Exception ex)
  6641. {
  6642. _sqlSugar.RollbackTran();
  6643. return Ok(JsonView(false, ex.Message));
  6644. }
  6645. _sqlSugar.CommitTran();
  6646. return Ok(JsonView(true));
  6647. }
  6648. return Ok(JsonView(false));
  6649. }
  6650. /// <summary>
  6651. /// 团组模块 - 出入境费用-草稿 - Add And Update
  6652. /// </summary>
  6653. /// <returns></returns>
  6654. [HttpPost]
  6655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6656. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  6657. {
  6658. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  6659. if (data.Code != 0)
  6660. {
  6661. return Ok(JsonView(false, data.Msg));
  6662. }
  6663. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  6664. //汇率信息记录
  6665. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  6666. return Ok(JsonView(true, data.Msg, data.Data));
  6667. }
  6668. /// <summary>
  6669. /// 团组模块 - 出入境费用-草稿 - File downlaod
  6670. /// </summary>
  6671. /// <param name="dto"></param>
  6672. /// <returns></returns>
  6673. [HttpPost]
  6674. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6675. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  6676. {
  6677. try
  6678. {
  6679. var id = dto.Id;
  6680. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  6681. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  6682. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  6683. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  6684. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  6685. 3 团组成员名单 1 团组成员名单", ""));
  6686. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  6687. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  6688. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  6689. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  6690. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  6691. //数据源
  6692. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  6693. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  6694. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  6695. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  6696. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  6697. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  6698. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  6699. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  6700. .Select((x, a, b) => new
  6701. {
  6702. x.Index,
  6703. itemName = a.Name,
  6704. CurrencyStr = b.Name,
  6705. x.Cost,
  6706. x.SubTotal,
  6707. x.Remark
  6708. })
  6709. .OrderBy((x) => x.Index)
  6710. .ToList(); //其他款项费用
  6711. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6712. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  6713. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  6714. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  6715. if (dto.ExportType == 1) //明细表
  6716. {
  6717. if (dto.SubTypeId == 1005) //1005(默认明细表)
  6718. {
  6719. //获取模板
  6720. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  6721. //载入模板
  6722. Document doc = new Document(tempPath);
  6723. DocumentBuilder builder = new DocumentBuilder(doc);
  6724. //利用键值对存放数据
  6725. Dictionary<string, string> dic = new Dictionary<string, string>();
  6726. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  6727. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  6728. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  6729. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  6730. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  6731. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  6732. //境内费用(其他费用)
  6733. if (_EnterExitCosts.ChoiceOne == 1)
  6734. {
  6735. string row1_1 = "";
  6736. if (_EnterExitCosts.Visa > 0)
  6737. {
  6738. //insidePayTotal += _EnterExitCosts.Visa;
  6739. row1_1 = $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  6740. if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  6741. {
  6742. row1_1 += $"\t签证费用描述: : {_EnterExitCosts.VisaRemark} 人民币/人";
  6743. }
  6744. }
  6745. string row1_2 = "";
  6746. if (_EnterExitCosts.YiMiao > 0)
  6747. {
  6748. //insidePayTotal += _EnterExitCosts.YiMiao;
  6749. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  6750. }
  6751. if (_EnterExitCosts.HeSuan > 0)
  6752. {
  6753. //insidePayTotal += _EnterExitCosts.HeSuan;
  6754. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  6755. }
  6756. if (_EnterExitCosts.Service > 0)
  6757. {
  6758. //insidePayTotal += _EnterExitCosts.Service;
  6759. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  6760. }
  6761. string row1_3 = "";
  6762. if (_EnterExitCosts.Safe > 0)
  6763. {
  6764. //insidePayTotal += _EnterExitCosts.Safe;
  6765. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  6766. }
  6767. if (_EnterExitCosts.Ticket > 0)
  6768. {
  6769. //insidePayTotal += _EnterExitCosts.Ticket;
  6770. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  6771. }
  6772. string row1 = "";
  6773. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  6774. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  6775. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  6776. row1 += $"备注:{_EnterExitCosts.Remark}";
  6777. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  6778. dic.Add("Row1Str", row1);
  6779. }
  6780. string airTotalStr = string.Empty,
  6781. airPriceStr = string.Empty;
  6782. //经济舱
  6783. if (_EnterExitCosts.SumJJC == 1)
  6784. {
  6785. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  6786. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  6787. }
  6788. //公务舱
  6789. if (_EnterExitCosts.SumGWC == 1)
  6790. {
  6791. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  6792. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  6793. }
  6794. //头等舱
  6795. if (_EnterExitCosts.SumTDC == 1)
  6796. {
  6797. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  6798. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  6799. }
  6800. string twoItemRemark = "备注:";
  6801. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark))
  6802. {
  6803. twoItemRemark = _EnterExitCosts.TwoItemRemark;
  6804. }
  6805. dic.Add("AirTotalStr", airTotalStr);
  6806. dic.Add("AirPriceStr", airPriceStr);
  6807. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  6808. dic.Add("TwoItemRemark", twoItemRemark);
  6809. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  6810. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  6811. int table1Row = 0,
  6812. table2Row = 0,
  6813. table3Row = 0,
  6814. table4Row = 0,
  6815. table5Row = 0;
  6816. //住宿费
  6817. if (_EnterExitCosts.ChoiceThree == 1)
  6818. {
  6819. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  6820. table1Row = dac1.Count;
  6821. #region 填充word表格内容
  6822. for (int i = 0; i < dac1.Count; i++)
  6823. {
  6824. var dac = dac1[i];
  6825. if (dac == null) continue;
  6826. builder.MoveToCell(0, i, 0, 0);
  6827. builder.Write("第" + dac.Days.ToString() + "晚:");
  6828. builder.MoveToCell(0, i, 1, 0);
  6829. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  6830. //builder.Write(dac.Place == null ? "" : dac.Place);
  6831. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6832. builder.MoveToCell(0, i, 2, 0);
  6833. builder.Write("费用标准:");
  6834. string curr = "";
  6835. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6836. if (currData != null)
  6837. {
  6838. curr = currData.Name;
  6839. }
  6840. builder.MoveToCell(0, i, 3, 0);
  6841. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6842. builder.MoveToCell(0, i, 4, 0);
  6843. builder.Write("费用小计:");
  6844. builder.MoveToCell(0, i, 5, 0);
  6845. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6846. }
  6847. #endregion
  6848. }
  6849. else dic.Add("SubZS", "0.00");
  6850. //删除多余行
  6851. while (table1.Rows.Count > table1Row)
  6852. {
  6853. table1.Rows.RemoveAt(table1Row);
  6854. }
  6855. //伙食费
  6856. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  6857. if (_EnterExitCosts.ChoiceFour == 1)
  6858. {
  6859. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  6860. table2Row = dac2.Count;
  6861. #region 填充word表格内容
  6862. for (int i = 0; i < dac2.Count; i++)
  6863. {
  6864. var dac = dac2[i];
  6865. if (dac == null) continue;
  6866. builder.MoveToCell(1, i, 0, 0);
  6867. builder.Write("第" + dac.Days.ToString() + "天:");
  6868. builder.MoveToCell(1, i, 1, 0);
  6869. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6870. builder.MoveToCell(1, i, 2, 0);
  6871. builder.Write("费用标准:");
  6872. string curr = "";
  6873. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6874. if (currData != null)
  6875. {
  6876. curr = currData.Name;
  6877. }
  6878. builder.MoveToCell(1, i, 3, 0);
  6879. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6880. builder.MoveToCell(1, i, 4, 0);
  6881. builder.Write("费用小计:");
  6882. builder.MoveToCell(1, i, 5, 0);
  6883. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6884. }
  6885. #endregion
  6886. }
  6887. else dic.Add("SubHS", "0.00");
  6888. //删除多余行
  6889. while (table2.Rows.Count > table2Row)
  6890. {
  6891. table2.Rows.RemoveAt(table2Row);
  6892. }
  6893. //公杂费
  6894. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  6895. if (_EnterExitCosts.ChoiceFive == 1)
  6896. {
  6897. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  6898. table3Row = dac3.Count;
  6899. #region 填充word表格内容
  6900. for (int i = 0; i < dac3.Count; i++)
  6901. {
  6902. var dac = dac3[i];
  6903. if (dac == null) continue;
  6904. builder.MoveToCell(2, i, 0, 0);
  6905. builder.Write("第" + dac.Days.ToString() + "天:");
  6906. builder.MoveToCell(2, i, 1, 0);
  6907. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6908. builder.MoveToCell(2, i, 2, 0);
  6909. builder.Write("费用标准:");
  6910. string curr = "";
  6911. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6912. if (currData != null)
  6913. {
  6914. curr = currData.Name;
  6915. }
  6916. builder.MoveToCell(2, i, 3, 0);
  6917. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6918. builder.MoveToCell(2, i, 4, 0);
  6919. builder.Write("费用小计:");
  6920. builder.MoveToCell(2, i, 5, 0);
  6921. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6922. }
  6923. //删除多余行
  6924. while (table3.Rows.Count > table3Row)
  6925. {
  6926. table3.Rows.RemoveAt(table3Row);
  6927. }
  6928. #endregion
  6929. }
  6930. else dic.Add("SubGZF", "0.00");
  6931. //删除多余行
  6932. while (table3.Rows.Count > table3Row)
  6933. {
  6934. table3.Rows.RemoveAt(table3Row);
  6935. }
  6936. //培训费
  6937. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  6938. if (_EnterExitCosts.ChoiceSix == 1)
  6939. {
  6940. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  6941. dic.Add("SubPX", pxStr);
  6942. table4Row = dac4.Count;
  6943. #region 填充word表格内容
  6944. for (int i = 0; i < dac4.Count; i++)
  6945. {
  6946. var dac = dac4[i];
  6947. if (dac == null) continue;
  6948. builder.MoveToCell(3, i, 0, 0);
  6949. builder.Write("第" + dac.Days.ToString() + "天:");
  6950. builder.MoveToCell(3, i, 1, 0);
  6951. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  6952. builder.MoveToCell(3, i, 2, 0);
  6953. builder.Write("费用标准:");
  6954. string curr = "";
  6955. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  6956. if (currData != null)
  6957. {
  6958. curr = currData.Name;
  6959. }
  6960. builder.MoveToCell(3, i, 3, 0);
  6961. builder.Write(dac.Cost.ToString("#0.00") + curr);
  6962. builder.MoveToCell(3, i, 4, 0);
  6963. builder.Write("费用小计:");
  6964. builder.MoveToCell(3, i, 5, 0);
  6965. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6966. }
  6967. #endregion
  6968. }
  6969. else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  6970. //删除多余行
  6971. while (table4.Rows.Count > table4Row)
  6972. {
  6973. table4.Rows.RemoveAt(table4Row);
  6974. }
  6975. //其他费用
  6976. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  6977. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  6978. {
  6979. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  6980. dic.Add("titleQi", qtStr);
  6981. table5Row = dac5.Count;
  6982. #region 填充word表格内容
  6983. for (int i = 0; i < dac5.Count; i++)
  6984. {
  6985. var dac = dac5[i];
  6986. if (dac == null) continue;
  6987. builder.MoveToCell(4, i, 0, 0);
  6988. builder.Write("第" + dac.Index.ToString() + "项:");
  6989. builder.MoveToCell(4, i, 1, 0);
  6990. builder.Write(dac.itemName);
  6991. builder.MoveToCell(4, i, 2, 0);
  6992. builder.Write("费用标准:");
  6993. builder.MoveToCell(4, i, 3, 0);
  6994. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  6995. builder.MoveToCell(4, i, 4, 0);
  6996. builder.Write("费用小计:");
  6997. builder.MoveToCell(4, i, 5, 0);
  6998. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  6999. builder.MoveToCell(4, i, 6, 0);
  7000. builder.Write("备注:");
  7001. builder.MoveToCell(4, i, 7, 0);
  7002. builder.Write(dac.Remark);
  7003. }
  7004. #endregion
  7005. }
  7006. else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  7007. //删除多余行
  7008. while (table5.Rows.Count > table5Row)
  7009. {
  7010. table5.Rows.RemoveAt(table5Row);
  7011. }
  7012. //加上其他费用
  7013. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  7014. decimal subJJC = 0.00M,
  7015. subGWC = 0.00M,
  7016. subTDC = 0.00M;
  7017. //经济舱
  7018. if (_EnterExitCosts.SumJJC == 1) subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  7019. //公务舱
  7020. if (_EnterExitCosts.SumGWC == 1) subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  7021. //头等舱
  7022. if (_EnterExitCosts.SumTDC == 1) subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  7023. dic.Add("SubJJC", subJJC.ToString("#0.00"));
  7024. dic.Add("SubGWC", subGWC.ToString("#0.00"));
  7025. dic.Add("SubTDC", subTDC.ToString("#0.00"));
  7026. #region 填充word模板书签内容
  7027. foreach (var key in dic.Keys)
  7028. {
  7029. Bookmark bookmark = doc.Range.Bookmarks[key];
  7030. if (bookmark != null)
  7031. {
  7032. builder.MoveToBookmark(key);
  7033. builder.Write(dic[key]);
  7034. }
  7035. }
  7036. #endregion
  7037. //文件名
  7038. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  7039. strFileName = CommonFun.ValidFileName(strFileName);
  7040. AsposeHelper.removewatermark_v2180();
  7041. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7042. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7043. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7044. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7045. }
  7046. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  7047. {
  7048. //获取模板
  7049. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  7050. //载入模板
  7051. Document doc = new Document(tempPath);
  7052. DocumentBuilder builder = new DocumentBuilder(doc);
  7053. Dictionary<string, string> dic = new Dictionary<string, string>();
  7054. string returnCodeLabel = string.Empty;
  7055. if (nationalTravelFeeData.Any())
  7056. {
  7057. List<string> list = new List<string>();
  7058. foreach (var item in nationalTravelFeeData)
  7059. {
  7060. list.Add($"{item.Country}({item.City})");
  7061. }
  7062. list = list.Distinct().ToList();
  7063. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7064. }
  7065. var countryLabel = string.Empty;
  7066. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7067. if (countryData.Any())
  7068. {
  7069. countryLabel = string.Join("、", countryData);
  7070. }
  7071. dic.Add("ReturnCodeAir", returnCodeLabel);
  7072. dic.Add("VisitStartDate", "-");
  7073. dic.Add("VisitEndDate", "-");
  7074. dic.Add("Day", "-");
  7075. dic.Add("VisitCountry", countryLabel);
  7076. dic.Add("ClientUnit", "-");
  7077. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  7078. //dic.Add("Names", Names);
  7079. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7080. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7081. decimal dac1totalPrice = 0.00M;
  7082. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  7083. foreach (var dac in dac1)
  7084. {
  7085. if (dac.SubTotal == 0.00M)
  7086. {
  7087. continue;
  7088. }
  7089. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  7090. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  7091. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  7092. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7093. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  7094. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7095. builder.Write(currency);//币种
  7096. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  7097. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7098. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  7099. builder.Write("");//人数
  7100. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  7101. builder.Write("");//天数
  7102. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  7103. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7104. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  7105. decimal rate = 0.00M;
  7106. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7107. builder.Write(rate.ToString("#0.0000"));//汇率
  7108. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  7109. decimal rbmPrice = dac.SubTotal;
  7110. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7111. accommodationStartIndex++;
  7112. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7113. }
  7114. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7115. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  7116. {
  7117. table1.Rows.RemoveAt(i - 1);
  7118. foodandotherStartIndex--;
  7119. }
  7120. if (dac2.Count == dac3.Count)//国家 币种 金额
  7121. {
  7122. for (int i = 0; i < dac2.Count; i++)
  7123. {
  7124. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7125. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7126. }
  7127. }
  7128. decimal dac2totalPrice = 0.00M;
  7129. foreach (var dac in dac2)
  7130. {
  7131. if (dac.SubTotal == 0)
  7132. {
  7133. continue;
  7134. }
  7135. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  7136. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7137. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  7138. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  7139. builder.Write(currency);//币种
  7140. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  7141. builder.Write(dac.Cost.ToString("#0.00"));//标准
  7142. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  7143. builder.Write("");//人数
  7144. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  7145. builder.Write("");//天数
  7146. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  7147. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  7148. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  7149. decimal rate = 0.00M;
  7150. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  7151. builder.Write(rate.ToString("#0.0000"));//汇率
  7152. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  7153. decimal rbmPrice = dac.SubTotal;
  7154. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  7155. foodandotherStartIndex++;
  7156. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  7157. }
  7158. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  7159. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  7160. {
  7161. table1.Rows.RemoveAt(i - 1);
  7162. }
  7163. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7164. string otherFeeStr = "";
  7165. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费: {_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  7166. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费: {_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  7167. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费: {_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  7168. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  7169. foreach (var otherInfo in dac5)
  7170. {
  7171. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7172. }
  7173. #endregion
  7174. if (otherFeeStr.Length > 0)
  7175. {
  7176. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  7177. otherFeeStr = $"({otherFeeStr})";
  7178. dic.Add("OtherFeeStr", otherFeeStr);
  7179. }
  7180. //总计
  7181. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  7182. //国际旅费
  7183. string outsideAir = string.Empty;
  7184. string allPriceAir = string.Empty;
  7185. if (_EnterExitCosts.SumJJC == 1)
  7186. {
  7187. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7188. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  7189. }
  7190. if (_EnterExitCosts.SumGWC == 1)
  7191. {
  7192. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  7193. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7194. }
  7195. if (_EnterExitCosts.SumTDC == 1)
  7196. {
  7197. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  7198. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  7199. }
  7200. dic.Add("InTravelPrice", $"({outsideAir})");
  7201. dic.Add("FinalSumPrice", $"({allPriceAir})");
  7202. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  7203. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  7204. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  7205. foreach (var key in dic.Keys)
  7206. {
  7207. builder.MoveToBookmark(key);
  7208. builder.Write(dic[key]);
  7209. }
  7210. //模板文件名
  7211. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  7212. strFileName = CommonFun.ValidFileName(strFileName);
  7213. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7214. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7215. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7216. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7217. }
  7218. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  7219. {
  7220. //获取模板
  7221. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  7222. //载入模板
  7223. WorkbookDesigner designer = new WorkbookDesigner();
  7224. designer.Workbook = new Workbook(tempPath);
  7225. Dictionary<string, string> dic = new Dictionary<string, string>();
  7226. string returnCodeLabel = string.Empty;
  7227. if (nationalTravelFeeData.Any())
  7228. {
  7229. List<string> list = new List<string>();
  7230. foreach (var item in nationalTravelFeeData)
  7231. {
  7232. list.Add($"{item.Country}({item.City})");
  7233. }
  7234. list = list.Distinct().ToList();
  7235. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  7236. }
  7237. var countryLabel = string.Empty;
  7238. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  7239. if (countryData.Any())
  7240. {
  7241. countryLabel = string.Join("、", countryData);
  7242. }
  7243. dic.Add("ReturnCodeAir", returnCodeLabel);
  7244. dic.Add("VisitStartDate", "-");
  7245. dic.Add("VisitEndDate", "-");
  7246. dic.Add("Day", "0");
  7247. dic.Add("VisitCountry", countryLabel);
  7248. dic.Add("ClientUnit", "-");
  7249. designer.SetDataSource("ClientUnit", "-");
  7250. designer.SetDataSource("VisitCountry", countryLabel);
  7251. designer.SetDataSource("Group", "-");
  7252. designer.SetDataSource("ClientUnitTitle", "-");
  7253. designer.SetDataSource("Name", "-");
  7254. designer.SetDataSource("VisitStartDate", "-" );
  7255. designer.SetDataSource("Day", "0");
  7256. designer.SetDataSource("ReturnCode", returnCodeLabel);
  7257. designer.SetDataSource("ReturnCodeAir", "-");
  7258. int startIndex = 10;
  7259. const int startIndexcopy = 10;
  7260. if (dac2.Count == dac3.Count)//国家 币种 金额
  7261. {
  7262. for (int i = 0; i < dac2.Count; i++)
  7263. {
  7264. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  7265. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  7266. }
  7267. }
  7268. DataTable dtdac1 = new DataTable();
  7269. List<string> place = new List<string>();
  7270. dtdac1.Columns.AddRange(new DataColumn[] {
  7271. new DataColumn(){ ColumnName = "city"},
  7272. new DataColumn(){ ColumnName = "curr"},
  7273. new DataColumn(){ ColumnName = "criterion"},
  7274. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7275. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7276. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7277. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7278. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  7279. });
  7280. DataTable dtdac2 = new DataTable();
  7281. dtdac2.Columns.AddRange(new DataColumn[] {
  7282. new DataColumn(){ ColumnName = "city"},
  7283. new DataColumn(){ ColumnName = "curr"},
  7284. new DataColumn(){ ColumnName = "criterion"},
  7285. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  7286. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  7287. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  7288. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  7289. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  7290. });
  7291. dtdac1.TableName = "tb1";
  7292. dtdac2.TableName = "tb2";
  7293. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  7294. foreach (var item in dac1)
  7295. {
  7296. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7297. if (place.Contains(item.Place))
  7298. {
  7299. continue;
  7300. }
  7301. DataRow row = dtdac1.NewRow();
  7302. row["city"] = item.Place;
  7303. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7304. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7305. row["curr"] = currency;
  7306. row["rate"] = rate.ToString("#0.0000");
  7307. row["criterion"] = item.Cost.ToString("#0.00");
  7308. row["number"] = 1;
  7309. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7310. //row["costRMB"] = rbmPrice;
  7311. dtdac1.Rows.Add(row);
  7312. place.Add(item.Place);
  7313. }
  7314. place = new List<string>();
  7315. foreach (var item in dac2)
  7316. {
  7317. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  7318. if (place.Contains(item.Place))
  7319. {
  7320. continue;
  7321. }
  7322. DataRow row = dtdac2.NewRow();
  7323. row["city"] = item.Place;
  7324. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  7325. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  7326. row["curr"] = currency;
  7327. row["rate"] = rate.ToString("#0.0000");
  7328. row["criterion"] = item.Cost.ToString("#0.00");
  7329. row["number"] = 1;
  7330. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  7331. //row["cost"] = item.SubTotal;
  7332. //row["costRMB"] = rbmPrice;
  7333. dtdac2.Rows.Add(row);
  7334. place.Add(item.Place);
  7335. //dac2totalPrice += rbmPrice;
  7336. }
  7337. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  7338. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  7339. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  7340. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  7341. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic.ToString("#0.00")} 元");
  7342. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic.ToString("#0.00")} ");
  7343. string cell4Str1 = string.Empty;
  7344. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 元/人;";
  7345. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")} 元/人;";
  7346. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD.ToString("#0.00")} 元/人;";
  7347. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  7348. string cellStr = $" 5.其他费用(";
  7349. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")}元,";
  7350. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")}元,";
  7351. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan.ToString("#0.00")}元,";
  7352. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")}元,";
  7353. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")}元,";
  7354. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")}元,";
  7355. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  7356. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  7357. foreach (var otherInfo in dac5)
  7358. {
  7359. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  7360. }
  7361. #endregion
  7362. if (cellStr.Length > 8)
  7363. {
  7364. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  7365. }
  7366. cellStr += ")";
  7367. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  7368. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  7369. decimal pxFee = dac4.Sum(it => it.Cost);
  7370. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  7371. string celllastStr1 = "";
  7372. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice.ToString("#0.00")} 元";
  7373. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice.ToString("#0.00")} 元";
  7374. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee.ToString("#0.00")} 元";
  7375. celllastStr1 += $",国际旅费 元";
  7376. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee.ToString("#0.00")} 元";
  7377. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  7378. designer.SetDataSource("cell4Str", cell4Str);
  7379. designer.SetDataSource("cellStr", cellStr);
  7380. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  7381. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  7382. designer.SetDataSource("celllastStr", celllastStr);
  7383. Workbook wb = designer.Workbook;
  7384. var sheet = wb.Worksheets[0];
  7385. //绑定datatable数据集
  7386. designer.SetDataSource(dtdac1);
  7387. designer.SetDataSource(dtdac2);
  7388. designer.Process();
  7389. var rowStart = dtdac1.Rows.Count;
  7390. while (rowStart > 0)
  7391. {
  7392. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  7393. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7394. startIndex++;
  7395. rowStart--;
  7396. }
  7397. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  7398. startIndex += 1; //总计行
  7399. rowStart = dtdac2.Rows.Count;
  7400. while (rowStart > 0)
  7401. {
  7402. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  7403. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  7404. startIndex++;
  7405. rowStart--;
  7406. }
  7407. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  7408. wb.CalculateFormula(true);
  7409. //模板文件名
  7410. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  7411. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7412. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7413. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7414. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7415. }
  7416. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  7417. {
  7418. //获取模板
  7419. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  7420. //载入模板
  7421. Document doc = new Document(tempPath);
  7422. DocumentBuilder builder = new DocumentBuilder(doc);
  7423. Dictionary<string, string> dic = new Dictionary<string, string>();
  7424. dic.Add("GroupName", "-");
  7425. dic.Add("ClientUnit", "-");
  7426. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  7427. string missionLeaderJob = "";//负责人job
  7428. int groupNumber = 0; //团人数
  7429. dic.Add("MissionLeader", "-"); //团负责人
  7430. dic.Add("MissionLeaderJob", "-"); //团负责人job
  7431. dic.Add("GroupNumber", "0"); //团人数
  7432. dic.Add("Day", "0");
  7433. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  7434. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  7435. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7436. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7437. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  7438. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  7439. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  7440. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  7441. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  7442. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  7443. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  7444. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  7445. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  7446. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  7447. //其他费用
  7448. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  7449. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  7450. //其他费用合计
  7451. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  7452. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  7453. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  7454. //公务舱合计
  7455. //国际旅费
  7456. string outsideJJ = "";
  7457. string allPriceJJ = "";
  7458. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  7459. {
  7460. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  7461. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  7462. }
  7463. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  7464. {
  7465. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  7466. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  7467. }
  7468. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  7469. {
  7470. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ.ToString("#0.00")} 公务舱:{_EnterExitCosts.AirGW.ToString("#0.00")}");
  7471. dic.Add("AirFeeTotal", airFeeTotalStr);
  7472. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal.ToString("#0.00")} 公务舱:{_gwcFeeToatal.ToString("#0.00")}");
  7473. dic.Add("FeeTotal", feeTotalStr);
  7474. }
  7475. foreach (var key in dic.Keys)
  7476. {
  7477. builder.MoveToBookmark(key);
  7478. builder.Write(dic[key]);
  7479. }
  7480. //模板文件名
  7481. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  7482. strFileName = CommonFun.ValidFileName(strFileName);
  7483. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  7484. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  7485. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  7486. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  7487. }
  7488. }
  7489. else if (dto.ExportType == 2) //表格
  7490. {
  7491. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7492. }
  7493. else if (dto.ExportType == 3)
  7494. {
  7495. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  7496. }
  7497. return Ok(JsonView(400, "只可导出明细表!", ""));
  7498. }
  7499. catch (Exception ex)
  7500. {
  7501. return Ok(JsonView(400, ex.Message, ""));
  7502. }
  7503. }
  7504. /// <summary>
  7505. /// 获取三公费用标准city
  7506. /// </summary>
  7507. /// <param name="placeData"></param>
  7508. /// <param name="nationalTravelFeeId"></param>
  7509. /// <returns></returns>
  7510. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  7511. {
  7512. string _city = string.Empty;
  7513. if (!placeData.Any()) return _city;
  7514. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  7515. if (data == null) return _city;
  7516. string country = data.Country;
  7517. string city = data.City;
  7518. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  7519. else _city = city;
  7520. return _city;
  7521. }
  7522. /// <summary>
  7523. /// 团组模块 - 出入境费用-草稿 - 一键清空
  7524. /// </summary>
  7525. /// <returns></returns>
  7526. [HttpPost]
  7527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7528. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  7529. {
  7530. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  7531. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  7532. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  7533. if (_view.Code == 0)
  7534. {
  7535. return Ok(JsonView(true, "操作成功"));
  7536. }
  7537. return Ok(JsonView(false, "操作失败"));
  7538. }
  7539. /// <summary>
  7540. /// 团组模块 - 出入境费用-草稿 - 子项删除
  7541. /// </summary>
  7542. /// <returns></returns>
  7543. [HttpPost]
  7544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7545. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  7546. {
  7547. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  7548. if (data.Code != 0)
  7549. {
  7550. return Ok(JsonView(false, data.Msg));
  7551. }
  7552. return Ok(JsonView(true, "操作成功!", data.Data));
  7553. }
  7554. /// <summary>
  7555. /// 三公其他费用草稿 删除
  7556. /// </summary>
  7557. /// <param name="dto"></param>
  7558. /// <returns></returns>
  7559. [HttpPost]
  7560. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  7561. {
  7562. var jw = JsonView(false, "删除失败!");
  7563. var data = new Grp_DayOtherPriceDraft()
  7564. {
  7565. Id = dto.Id,
  7566. IsDel = 1,
  7567. DeleteUserId = dto.DeleteUserId,
  7568. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  7569. };
  7570. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  7571. if (del > 0)
  7572. {
  7573. jw.Code = 200;
  7574. jw.Msg = "删除成功!";
  7575. }
  7576. return Ok(jw);
  7577. }
  7578. /// <summary>
  7579. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  7580. /// </summary>
  7581. /// <param name="dto"></param>
  7582. /// <returns></returns>
  7583. [HttpPost]
  7584. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  7585. {
  7586. var jw = JsonView(false);
  7587. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  7588. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new {x.Id,x.DraftName }).ToListAsync();
  7589. jw.Code = StatusCodes.Status200OK;
  7590. jw.Msg = "操作成功!";
  7591. jw.Data = new { groupNameDatas= groupNameDatas.Data, draftNames = draftDatas };
  7592. return Ok(jw);
  7593. }
  7594. /// <summary>
  7595. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  7596. /// </summary>
  7597. /// <param name="dto"></param>
  7598. /// <returns></returns>
  7599. [HttpPost]
  7600. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  7601. {
  7602. int userId = dto.UserId,
  7603. portId = dto.PortType,
  7604. groupId = dto.GroupId,
  7605. draftId = dto.DraftId;
  7606. _portTypeData.Add(1);
  7607. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7608. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  7609. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  7610. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  7611. _sqlSugar.BeginTran();
  7612. try
  7613. {
  7614. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  7615. if (draftDatas == null)
  7616. {
  7617. _sqlSugar.RollbackTran();
  7618. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  7619. }
  7620. //验证可覆盖已有数据 两边创建人需为同一人;
  7621. int draftCreateUserId = draftDatas.CreateUserId,
  7622. formalCreateUserId = 0;
  7623. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7624. if (formalData != null)
  7625. {
  7626. formalCreateUserId = formalData.CreateUserId;
  7627. if (draftCreateUserId != formalCreateUserId)
  7628. {
  7629. _sqlSugar.RollbackTran();
  7630. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  7631. }
  7632. }
  7633. var permissionUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  7634. var userIds = permissionUsers.Select(x => x.Id).ToList();
  7635. var permissions = new List<Grp_EnterExitCostPermission>();
  7636. if (userIds.Any())
  7637. {
  7638. foreach (var userId1 in userIds)
  7639. {
  7640. permissions.Add(new Grp_EnterExitCostPermission() {
  7641. GroupId = groupId,
  7642. UserId = userId1,
  7643. CreateUserId = dto.UserId
  7644. });
  7645. }
  7646. }
  7647. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7648. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  7649. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  7650. newExterData.DiId = groupId;
  7651. newExterData.CreateUserId = userId;
  7652. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  7653. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  7654. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  7655. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  7656. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  7657. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  7658. //数据如果存在执行删除
  7659. if (enterExitCostInfo != null)
  7660. {
  7661. _sqlSugar.Updateable<Grp_EnterExitCost>()
  7662. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  7663. .Where(x => x.Id == enterExitCostInfo.Id)
  7664. .ExecuteCommand();
  7665. _sqlSugar.Updateable<Grp_DayAndCost>()
  7666. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7667. .Where(x => x.DiId == groupId)
  7668. .ExecuteCommand();
  7669. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  7670. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7671. .Where(x => x.Diid == groupId)
  7672. .ExecuteCommand();
  7673. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  7674. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  7675. .Where(x => x.GroupId == groupId)
  7676. .ExecuteCommand();
  7677. }
  7678. //执行insert
  7679. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  7680. if (insertId < 1)
  7681. {
  7682. _sqlSugar.RollbackTran();
  7683. return Ok(JsonView(false, "草稿数据导入失败!"));
  7684. }
  7685. if (permissions.Any()) _sqlSugar.Insertable(permissions).ExecuteCommand();
  7686. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  7687. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  7688. _sqlSugar.CommitTran();
  7689. //执行操作之后
  7690. //生成默认文件pdf并且通知人员
  7691. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7692. {
  7693. DiId = groupId,
  7694. ExportType = 1,
  7695. SubTypeId = 1005
  7696. }, "pdf");
  7697. //发送通知
  7698. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7699. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  7700. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  7701. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7702. //汇率信息记录
  7703. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  7704. return Ok(JsonView(true));
  7705. }
  7706. catch (Exception ex)
  7707. {
  7708. _sqlSugar.RollbackTran();
  7709. return Ok(JsonView(false,ex.Message));
  7710. }
  7711. }
  7712. #endregion
  7713. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  7714. /// <summary>
  7715. /// 获取币种基础数据(含逻辑处理)
  7716. /// </summary>
  7717. /// <returns></returns>
  7718. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  7719. {
  7720. //默认币种显示
  7721. var _currencyInfos = _currencyInit;
  7722. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7723. if (_currencyRate.Count > 0)
  7724. {
  7725. foreach (var item in _currencyInfos)
  7726. {
  7727. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7728. if (rateInfo != null)
  7729. {
  7730. decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  7731. rate1 *= 1.035M;
  7732. item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7733. }
  7734. }
  7735. }
  7736. return _currencyInfos;
  7737. }
  7738. /// <summary>
  7739. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  7740. /// </summary>
  7741. /// <returns></returns>
  7742. [HttpPost]
  7743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7744. public async Task<IActionResult> EnterExitCostMobileDataSource(PortDtoBase dto)
  7745. {
  7746. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  7747. //SetDataInfoView
  7748. var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  7749. var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  7750. List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  7751. var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  7752. List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  7753. //默认币种显示
  7754. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  7755. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7756. return Ok(JsonView(true, "查询成功!", new
  7757. {
  7758. WordTypeData = _WordTypeData,
  7759. ExcelTypeData = _ExcelTypeData,
  7760. CurrencyInit = _currencyInfos,
  7761. viewPermissionData = viewPermissionData
  7762. }));
  7763. }
  7764. /// <summary>
  7765. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  7766. /// </summary>
  7767. /// <returns></returns>
  7768. [HttpPost]
  7769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7770. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  7771. {
  7772. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7773. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7774. RefAsync<int> total = 0;
  7775. int diId = 0;
  7776. var status = int.TryParse(dto.GroupName, out diId);
  7777. string sql = string.Format(@"SELECT
  7778. Id,
  7779. TeamName GroupName,
  7780. CASE WHEN EXISTS (
  7781. SELECT
  7782. 1
  7783. FROM
  7784. Grp_EnterExitCost
  7785. WHERE
  7786. IsDel = 0
  7787. AND DiId = di.Id
  7788. ) THEN 1 ELSE 0 END AS [IsNull],
  7789. CASE WHEN EXISTS(
  7790. SELECT
  7791. TOP 1 *
  7792. FROM
  7793. Grp_EnterExitCost
  7794. WHERE
  7795. IsDel = 0
  7796. AND DiId = di.Id
  7797. AND CreateUserId = {0}
  7798. ORDER BY
  7799. CreateTime DESC
  7800. ) THEN 1 ELSE 0 END AS [IsEdit],
  7801. CASE WHEN EXISTS(
  7802. SELECT
  7803. TOP 1 *
  7804. FROM
  7805. Grp_EnterExitCost
  7806. WHERE
  7807. IsDel = 0
  7808. AND DiId = di.Id
  7809. AND CreateUserId = {0}
  7810. ORDER BY
  7811. CreateTime DESC
  7812. ) THEN 1 WHEN EXISTS(
  7813. SELECT
  7814. TOP 1 *
  7815. FROM
  7816. Grp_EnterExitCostPermission
  7817. WHERE
  7818. IsDel = 0
  7819. AND GroupId = di.Id
  7820. AND Permission = 1
  7821. AND UserId = {0}
  7822. ORDER BY
  7823. CreateTime DESC
  7824. ) THEN 1 ELSE 0 END AS [IsView]
  7825. FROM
  7826. Grp_DelegationInfo di
  7827. WHERE
  7828. di.Isdel = 0 ",dto.CurrUserId);
  7829. var data = await _sqlSugar.SqlQueryable<EnterExitCostMobileGroupView>(sql)
  7830. .Where(x => !string.IsNullOrEmpty(x.GroupName))
  7831. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  7832. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.GroupName.Contains(dto.GroupName))
  7833. .OrderByDescending(x => x.Id)
  7834. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7835. return Ok(JsonView(true, "查询成功!", data, total));
  7836. }
  7837. /// <summary>
  7838. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  7839. /// </summary>
  7840. /// <returns></returns>
  7841. [HttpPost]
  7842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7843. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  7844. {
  7845. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7846. RefAsync<int> total = 0;
  7847. var data = await _sqlSugar.Queryable<Sys_SetData>()
  7848. .Where(x => x.IsDel == 0 && x.STid == 66)
  7849. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  7850. .Select(x => new
  7851. {
  7852. id = x.Id,
  7853. name = x.Name,
  7854. remark = x.Remark,
  7855. })
  7856. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7857. return Ok(JsonView(true, "查询成功!", data, total));
  7858. }
  7859. /// <summary>
  7860. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  7861. /// </summary>
  7862. /// <returns></returns>
  7863. [HttpPost]
  7864. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7865. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  7866. {
  7867. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7868. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7869. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  7870. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  7871. var groupOtherRateData = groupRateData.TeamRates;
  7872. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7873. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  7874. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  7875. groupOtherRateData = groupOtherRateData
  7876. .Select(x => new TeamRateDescAddCurrencyIdView {
  7877. CurrencyId = x.CurrencyId,
  7878. CurrencyName = x.CurrencyName,
  7879. CurrencyCode = x.CurrencyCode,
  7880. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  7881. }).ToList();
  7882. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  7883. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData= groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  7884. }
  7885. /// <summary>
  7886. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  7887. /// </summary>
  7888. /// <returns></returns>
  7889. [HttpPost]
  7890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7891. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  7892. {
  7893. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7894. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7895. var tipsData = new List<int>() {1,2,3 };
  7896. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  7897. if (dto.TipsType == 1)
  7898. {
  7899. //默认币种显示
  7900. var _currencyInfos = _currencyInit;
  7901. var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  7902. List<dynamic> reteInfos = new List<dynamic>();
  7903. if (_currencyRate.Count > 0)
  7904. {
  7905. foreach (var item in _currencyInfos)
  7906. {
  7907. var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  7908. if (rateInfo != null)
  7909. {
  7910. item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  7911. decimal rate1 = item.Rate;
  7912. rate1 *= 1.03M;
  7913. decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  7914. reteInfos.Add(new
  7915. {
  7916. currCode = item.CurrencyCode,
  7917. currName = item.CurrencyName,
  7918. rate = rate2,
  7919. lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  7920. });
  7921. }
  7922. }
  7923. }
  7924. return Ok(JsonView(true, "查询成功!", reteInfos));
  7925. }
  7926. else if (dto.TipsType == 2)
  7927. {
  7928. var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.GroupId);
  7929. return Ok(JsonView(true, "查询成功!", visaData.Data));
  7930. }
  7931. else if (dto.TipsType == 3)
  7932. {
  7933. var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.GroupId);
  7934. return Ok(JsonView(true, "查询成功!", airData.Data));
  7935. }
  7936. return Ok(JsonView(false));
  7937. }
  7938. /// <summary>
  7939. /// 团组模块 - 出入境国家费用标准-移动端 List
  7940. /// </summary>
  7941. /// <returns></returns>
  7942. [HttpPost]
  7943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7944. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  7945. {
  7946. Stopwatch sw = new Stopwatch();
  7947. sw.Start();
  7948. RefAsync<int> total = 0;
  7949. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  7950. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  7951. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  7952. .Where((ntf, sd, u) => ntf.IsDel == 0)
  7953. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  7954. .Select((ntf, sd, u) => new
  7955. {
  7956. Id = ntf.Id,
  7957. Area = $"{ntf.Country}-{ntf.City}",
  7958. Currency = ntf.Currency,
  7959. CurrencyCode = sd.Name,
  7960. CurrencyName = sd.Remark,
  7961. RoomCost = ntf.RoomCost,
  7962. FoodCost = ntf.FoodCost,
  7963. PublicCost = ntf.PublicCost,
  7964. LastUpdateUserId = ntf.LastUpdateUserId,
  7965. LastUpdateUserName = u.CnName,
  7966. LastUpdateTime = ntf.LastUpdateTime,
  7967. })
  7968. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  7969. sw.Stop();
  7970. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data,total));
  7971. }
  7972. /// <summary>
  7973. /// 团组模块 - 出入境费用-移动端 - Info
  7974. /// </summary>
  7975. /// <returns></returns>
  7976. [HttpPost]
  7977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7978. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  7979. {
  7980. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7981. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7982. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  7983. return Ok(data);
  7984. }
  7985. /// <summary>
  7986. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  7987. /// </summary>
  7988. /// <returns></returns>
  7989. [HttpPost]
  7990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7991. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  7992. {
  7993. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  7994. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7995. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7996. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  7997. var mobileInfo = new EnterExitCostMobileParentInfoView();
  7998. mobileInfo.DiId = dto.DiId;
  7999. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  8000. if (eecInfo == null) return Ok(mobileInfo);
  8001. //验证查看权限
  8002. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8003. if (!isView) return Ok(JsonView(false, msg));
  8004. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  8005. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  8006. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8007. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8008. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8009. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8010. {
  8011. SubId = dac.Id,
  8012. DiId = dac.DiId,
  8013. Type = dac.Type,
  8014. Days = dac.Days,
  8015. NationalTravelFeeId = dac.NationalTravelFeeId,
  8016. Arae = $"{ntf.Country}-{ntf.City}",
  8017. Cost = dac.Cost,
  8018. Currency = dac.Currency,
  8019. CurrencyName = sd.Name,
  8020. SubTotal = dac.SubTotal,
  8021. })
  8022. .ToList();
  8023. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  8024. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  8025. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  8026. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  8027. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  8028. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  8029. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  8030. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  8031. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  8032. //其他款项
  8033. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8034. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8035. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8036. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8037. .OrderBy((dop, sd1, sd2) => dop.Index)
  8038. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8039. {
  8040. SubId = dop.Id,
  8041. DiId = dop.Diid,
  8042. Index = dop.Index,
  8043. SetDataId = dop.SetDataId,
  8044. SetDataName = sd1.Name,
  8045. Cost = dop.Cost,
  8046. Currency = dop.Currency,
  8047. CurrencyName = sd2.Remark,
  8048. SubTotal = dop.SubTotal,
  8049. Remark = dop.Remark,
  8050. })
  8051. .ToArray();
  8052. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  8053. return Ok(mobileInfo);
  8054. }
  8055. /// <summary>
  8056. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  8057. /// </summary>
  8058. /// <returns></returns>
  8059. [HttpPost]
  8060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8061. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  8062. {
  8063. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8064. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8065. //验证查看权限
  8066. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8067. if (!isView) return Ok(JsonView(false, msg));
  8068. var userIds = Array.Empty<int>();
  8069. userIds = await _sqlSugar
  8070. .Queryable<Grp_EnterExitCostPermission>()
  8071. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  8072. .Select(x => x.UserId)
  8073. .ToArrayAsync();
  8074. return Ok(userIds);
  8075. }
  8076. /// <summary>
  8077. /// 团组模块 - 出入境费用-移动端 - SubInfo
  8078. /// </summary>
  8079. /// <returns></returns>
  8080. [HttpPost]
  8081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8082. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  8083. {
  8084. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8085. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8086. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8087. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  8088. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  8089. //验证查看权限
  8090. (bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  8091. if (!isView) return Ok(JsonView(false, msg));
  8092. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  8093. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  8094. var subType = dto.SubType;
  8095. if (subType == 1) //1:境内费用
  8096. {
  8097. var oneData = new ChoiceOneMobileSubInfoView()
  8098. {
  8099. Id = eecInfo.Id,
  8100. ChoiceOne = eecInfo.ChoiceOne,
  8101. ChoiceOneTotalCost = eecInfo.InsidePay,
  8102. Visa = eecInfo.Visa,
  8103. VisaRemark = eecInfo.VisaRemark,
  8104. YiMiao = eecInfo.YiMiao,
  8105. HeSuan = eecInfo.HeSuan,
  8106. Service = eecInfo.Service,
  8107. Ticket = eecInfo.Ticket,
  8108. Safe = eecInfo.Safe,
  8109. FirstItemRemark = eecInfo.FirstItemRemark
  8110. };
  8111. return Ok(JsonView(oneData));
  8112. }
  8113. else if (subType == 2) //2:国际旅费
  8114. {
  8115. var twoData = new ChoiceTwoMobileSubInfoView() {
  8116. Id = eecInfo.Id,
  8117. ChoiceTwoJJ = eecInfo.SumJJC,
  8118. OutsideJJPay = eecInfo.OutsideJJPay,
  8119. ChoiceTwoGW = eecInfo.SumGWC,
  8120. OutsideGWPay = eecInfo.OutsideGWPay,
  8121. ChoiceTwoTD = eecInfo.SumTDC,
  8122. OutsideTDPay = eecInfo.OutsideTDPay,
  8123. AirJJ = eecInfo.AirJJ,
  8124. AirGW = eecInfo.AirGW,
  8125. AirTD = eecInfo.AirTD,
  8126. CityTranffic = eecInfo.CityTranffic,
  8127. TwoItemRemark = eecInfo.TwoItemRemark
  8128. };
  8129. return Ok(JsonView(twoData));
  8130. }
  8131. else if (subType == 3) //3:住宿费
  8132. {
  8133. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8134. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8135. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8136. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  8137. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8138. {
  8139. SubId = dac.Id,
  8140. DiId = dac.DiId,
  8141. Type = dac.Type,
  8142. Days = dac.Days,
  8143. NationalTravelFeeId = dac.NationalTravelFeeId,
  8144. Arae = $"{ntf.Country}-{ntf.City}",
  8145. Cost = dac.Cost,
  8146. Currency = dac.Currency,
  8147. CurrencyName = sd.Name,
  8148. SubTotal = dac.SubTotal,
  8149. })
  8150. .ToArray();
  8151. var data = new ChoiceMobileSubInfo3To6View() {
  8152. ParentId = eecInfo.Id,
  8153. Choice = eecInfo.ChoiceThree,
  8154. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8155. Details = dayAndCostDatas
  8156. };
  8157. return Ok(JsonView(data));
  8158. }
  8159. else if (subType == 4) //4:伙食费
  8160. {
  8161. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8162. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8163. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8164. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  8165. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8166. {
  8167. SubId = dac.Id,
  8168. DiId = dac.DiId,
  8169. Type = dac.Type,
  8170. Days = dac.Days,
  8171. NationalTravelFeeId = dac.NationalTravelFeeId,
  8172. Arae = $"{ntf.Country}-{ntf.City}",
  8173. Cost = dac.Cost,
  8174. Currency = dac.Currency,
  8175. CurrencyName = sd.Name,
  8176. SubTotal = dac.SubTotal,
  8177. })
  8178. .ToArray();
  8179. var data = new ChoiceMobileSubInfo3To6View()
  8180. {
  8181. ParentId = eecInfo.Id,
  8182. Choice = eecInfo.ChoiceFour,
  8183. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8184. Details = dayAndCostDatas
  8185. };
  8186. return Ok(JsonView(data));
  8187. }
  8188. else if (subType == 5) //5:公杂费
  8189. {
  8190. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8191. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8192. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8193. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  8194. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8195. {
  8196. SubId = dac.Id,
  8197. DiId = dac.DiId,
  8198. Type = dac.Type,
  8199. Days = dac.Days,
  8200. NationalTravelFeeId = dac.NationalTravelFeeId,
  8201. Arae = $"{ntf.Country}-{ntf.City}",
  8202. Cost = dac.Cost,
  8203. Currency = dac.Currency,
  8204. CurrencyName = sd.Name,
  8205. SubTotal = dac.SubTotal,
  8206. })
  8207. .ToArray();
  8208. var data = new ChoiceMobileSubInfo3To6View()
  8209. {
  8210. ParentId = eecInfo.Id,
  8211. Choice = eecInfo.ChoiceFive,
  8212. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8213. Details = dayAndCostDatas
  8214. };
  8215. return Ok(JsonView(data));
  8216. }
  8217. else if (subType == 6) //6:培训费
  8218. {
  8219. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  8220. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  8221. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  8222. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  8223. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  8224. {
  8225. SubId = dac.Id,
  8226. DiId = dac.DiId,
  8227. Type = dac.Type,
  8228. Days = dac.Days,
  8229. NationalTravelFeeId = dac.NationalTravelFeeId,
  8230. Arae = $"{ntf.Country}-{ntf.City}",
  8231. Cost = dac.Cost,
  8232. Currency = dac.Currency,
  8233. CurrencyName = sd.Name,
  8234. SubTotal = dac.SubTotal,
  8235. })
  8236. .ToArray();
  8237. var data = new ChoiceMobileSubInfo3To6View()
  8238. {
  8239. ParentId = eecInfo.Id,
  8240. Choice = eecInfo.ChoiceSix,
  8241. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  8242. Details = dayAndCostDatas
  8243. };
  8244. return Ok(JsonView(data));
  8245. }
  8246. else if (subType == 7) //7:其他
  8247. {
  8248. //其他款项
  8249. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8250. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  8251. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  8252. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8253. .OrderBy((dop, sd1, sd2) => dop.Index)
  8254. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  8255. {
  8256. SubId = dop.Id,
  8257. DiId = dop.Diid,
  8258. Index = dop.Index,
  8259. SetDataId = dop.SetDataId,
  8260. SetDataName = sd1.Name,
  8261. Cost = dop.Cost,
  8262. Currency = dop.Currency,
  8263. CurrencyName = sd2.Name,
  8264. SubTotal = dop.SubTotal,
  8265. Remark = dop.Remark,
  8266. })
  8267. .ToArray();
  8268. var data = new ChoiceSevenMobileSubInfoView()
  8269. {
  8270. ParentId = eecInfo.Id,
  8271. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  8272. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  8273. Details = otherData
  8274. };
  8275. return Ok(JsonView(data));
  8276. }
  8277. return Ok(JsonView(false));
  8278. }
  8279. #region op
  8280. /// <summary>
  8281. /// 移动端更新费用消息通知
  8282. /// </summary>
  8283. /// <param name="diid"></param>
  8284. /// <param name="id"></param>
  8285. /// <param name="currUserId"></param>
  8286. private async Task EnterExitCostMobileOpNotice(int diid, int id,int currUserId)
  8287. {
  8288. try
  8289. {
  8290. ////生成默认文件pdf并且通知人员
  8291. //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  8292. //{
  8293. // DiId = diid,
  8294. // ExportType = 1,
  8295. // SubTypeId = 1005
  8296. //}, "pdf");
  8297. ////发送通知
  8298. //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  8299. //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  8300. //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  8301. //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  8302. ////汇率信息记录
  8303. //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  8304. }
  8305. catch (Exception ex)
  8306. {
  8307. //记录日志
  8308. throw;
  8309. }
  8310. }
  8311. /// <summary>
  8312. /// 验证出入境费用数据是否存在
  8313. /// 不存在添加
  8314. /// </summary>
  8315. /// <param name="diId"></param>
  8316. /// <param name="currUserId"></param>
  8317. /// <returns></returns>
  8318. /// <exception cref="CustomException"></exception>
  8319. private async Task<int> EnterExitCostVerifyIsNull(int diId,int currUserId)
  8320. {
  8321. var parentId = 0;
  8322. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  8323. if (info != null) {
  8324. parentId = info.Id;
  8325. }
  8326. else
  8327. {
  8328. var currencys = await EnterExitCostMobileGetCurrencyInit();
  8329. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  8330. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  8331. parentId = addId;
  8332. }
  8333. return parentId;
  8334. }
  8335. /// <summary>
  8336. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  8337. /// </summary>
  8338. /// <returns></returns>
  8339. [HttpPost]
  8340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8341. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  8342. {
  8343. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8344. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8345. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  8346. //验证编辑权限
  8347. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8348. if (!isEdit) return Ok(JsonView(false, msg));
  8349. var permissions = new List<Grp_EnterExitCostPermission>();
  8350. foreach (var userId in dto.UserIds)
  8351. {
  8352. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  8353. }
  8354. if (permissions.Any())
  8355. {
  8356. _sqlSugar.BeginTran();
  8357. try
  8358. {
  8359. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  8360. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  8361. if (result < 1)
  8362. {
  8363. _sqlSugar.RollbackTran();
  8364. return Ok(JsonView(false));
  8365. }
  8366. }
  8367. catch (Exception ex)
  8368. {
  8369. _sqlSugar.RollbackTran();
  8370. return Ok(JsonView(false, ex.Message));
  8371. }
  8372. _sqlSugar.CommitTran();
  8373. return Ok(JsonView(true));
  8374. }
  8375. return Ok(JsonView(false));
  8376. }
  8377. /// <summary>
  8378. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  8379. /// </summary>
  8380. /// <returns></returns>
  8381. [HttpPost]
  8382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8383. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  8384. {
  8385. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8386. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8387. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8388. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  8389. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  8390. int id = dto.Id;
  8391. if (id <= 0) //add
  8392. {
  8393. var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  8394. if (add < 1) return Ok(JsonView(false));
  8395. id = add;
  8396. }
  8397. else //update
  8398. {
  8399. //验证编辑权限
  8400. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8401. if (!isEdit) return Ok(JsonView(false, msg));
  8402. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  8403. if (upd < 1) return Ok(JsonView(false));
  8404. }
  8405. #region 汇率变更时更改币种相关费用
  8406. var opDayCosts = new List<Grp_DayAndCost>();
  8407. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  8408. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  8409. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  8410. .LeftJoin<Sys_SetData>((dac,sd) => dac.Currency == sd.Id)
  8411. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  8412. .Select((dac, sd) => new {
  8413. dac.Id,
  8414. dac.DiId,
  8415. CurrencyCode = sd.Name,
  8416. dac.Cost
  8417. })
  8418. .ToList();
  8419. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  8420. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  8421. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  8422. .Select((dop, sd) => new {
  8423. dop.Id,
  8424. dop.Diid,
  8425. CurrencyCode = sd.Name,
  8426. dop.Cost
  8427. })
  8428. .ToList();
  8429. if (dayCosts.Count > 0)
  8430. {
  8431. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8432. foreach (var dc in new_dayCosts)
  8433. {
  8434. var thisCurrency = dc.Key.ToUpper();
  8435. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8436. if (thisRate == 0.00M) continue;
  8437. foreach (var dcSub in dc)
  8438. {
  8439. opDayCosts.Add(new Grp_DayAndCost() {
  8440. Id = dcSub.Id,
  8441. DiId = dcSub.DiId,
  8442. Cost = dcSub.Cost,
  8443. SubTotal = dcSub.Cost * thisRate,
  8444. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8445. });
  8446. }
  8447. }
  8448. if (opDayCosts.Count > 0)
  8449. {
  8450. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8451. }
  8452. }
  8453. if (dayOtherCosts.Count > 0)
  8454. {
  8455. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  8456. foreach (var dc in new_dayOtherCosts)
  8457. {
  8458. var thisCurrency = dc.Key.ToUpper();
  8459. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  8460. if (thisRate == 0.00M) continue;
  8461. foreach (var dcSub in dc)
  8462. {
  8463. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  8464. {
  8465. Id = dcSub.Id,
  8466. Diid = dcSub.Diid,
  8467. Cost = dcSub.Cost,
  8468. SubTotal = dcSub.Cost * thisRate,
  8469. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  8470. });
  8471. }
  8472. }
  8473. if (opDayOtherCosts.Count > 0)
  8474. {
  8475. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  8476. }
  8477. }
  8478. #endregion
  8479. //消息通知
  8480. await EnterExitCostMobileOpNotice(dto.DiId, id,dto.CurrUserId);
  8481. //汇率信息记录
  8482. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  8483. return Ok(JsonView(new { parentId = id }));
  8484. }
  8485. /// <summary>
  8486. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  8487. /// </summary>
  8488. /// <returns></returns>
  8489. [HttpPost]
  8490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8491. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  8492. {
  8493. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8494. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8495. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8496. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  8497. int id = dto.Id;
  8498. if (id <= 0) //add
  8499. {
  8500. checkboxInfo.CreateUserId = dto.CurrUserId;
  8501. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8502. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8503. if (add < 1) return Ok(JsonView(false));
  8504. }
  8505. else //update
  8506. {
  8507. //验证编辑权限
  8508. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8509. if (!isEdit) return Ok(JsonView(false, msg));
  8510. var upd = await _sqlSugar.Updateable(checkboxInfo)
  8511. .UpdateColumns(x => new {
  8512. x.ChoiceOne,
  8513. x.ChoiceTwo,
  8514. x.SumJJC,
  8515. x.SumGWC,
  8516. x.SumTDC,
  8517. x.ChoiceThree,
  8518. x.ChoiceFour,
  8519. x.ChoiceFive,
  8520. x.ChoiceSix,
  8521. x.OtherExpenses_Checked
  8522. })
  8523. .Where(x => x.Id == id)
  8524. .ExecuteCommandAsync();
  8525. if (upd < 1) return Ok(JsonView(false));
  8526. }
  8527. return Ok(JsonView(new { parentId = id }));
  8528. }
  8529. /// <summary>
  8530. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  8531. /// </summary>
  8532. /// <returns></returns>
  8533. [HttpPost]
  8534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8535. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  8536. {
  8537. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId,isSelected = dto.IsSelected;
  8538. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  8539. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8540. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8541. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8542. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  8543. var checkboxInfo = new Grp_EnterExitCost() {
  8544. Id = id,
  8545. DiId = diId,
  8546. CreateUserId = currUserId
  8547. };
  8548. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  8549. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  8550. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  8551. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  8552. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  8553. if (id <= 0) //add
  8554. {
  8555. checkboxInfo.CreateUserId = dto.CurrUserId;
  8556. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8557. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  8558. if (add < 1) return Ok(JsonView(false));
  8559. }
  8560. else //update
  8561. {
  8562. //验证编辑权限
  8563. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8564. if (!isEdit) return Ok(JsonView(false, msg));
  8565. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  8566. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  8567. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  8568. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  8569. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  8570. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  8571. .Where(x => x.Id == id)
  8572. .ExecuteCommandAsync();
  8573. if (upd < 1) return Ok(JsonView(false));
  8574. }
  8575. return Ok(JsonView(new { parentId = id }));
  8576. }
  8577. /// <summary>
  8578. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  8579. /// </summary>
  8580. /// <returns></returns>
  8581. [HttpPost]
  8582. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8583. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  8584. {
  8585. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8586. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8587. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8588. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8589. info.FirstItemRemark = dto.FirstItemRemark;
  8590. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  8591. int id = dto.Id;
  8592. if (id <= 0) //add
  8593. {
  8594. info.CreateUserId = dto.CurrUserId;
  8595. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8596. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8597. if (add < 1) return Ok(JsonView(false));
  8598. id = add;
  8599. }
  8600. else //update
  8601. {
  8602. //验证编辑权限
  8603. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8604. if (!isEdit) return Ok(JsonView(false, msg));
  8605. var upd = await _sqlSugar.Updateable(info)
  8606. .UpdateColumns(x => new {
  8607. x.ChoiceOne,
  8608. x.InsidePay,
  8609. x.VisaRemark,
  8610. x.Visa,
  8611. x.Service,
  8612. x.Safe,
  8613. x.Ticket,
  8614. x.HeSuan,
  8615. x.YiMiao,
  8616. x.FirstItemRemark
  8617. })
  8618. .Where(x => x.Id == id)
  8619. .ExecuteCommandAsync();
  8620. if (upd < 1) return Ok(JsonView(false));
  8621. }
  8622. //消息通知
  8623. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8624. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  8625. }
  8626. /// <summary>
  8627. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  8628. /// </summary>
  8629. /// <returns></returns>
  8630. [HttpPost]
  8631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8632. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  8633. {
  8634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8635. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8637. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  8638. info.OutsideJJPay = dto.OutsideJJPay;
  8639. info.OutsideGWPay = dto.OutsideGWPay;
  8640. info.OutsideTDPay = dto.OutsideTDPay;
  8641. info.AirJJ = dto.AirJJ;
  8642. info.AirGW = dto.AirGW;
  8643. info.AirTD = dto.AirTD;
  8644. info.CityTranffic = dto.CityTranffic;
  8645. info.TwoItemRemark = dto.TwoItemRemark;
  8646. info.SumJJC = dto.ChoiceTwoJJ;
  8647. info.SumGWC = dto.ChoiceTwoGW;
  8648. info.SumTDC = dto.ChoiceTwoTD;
  8649. int id = dto.Id;
  8650. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  8651. if (id <= 0) //add
  8652. {
  8653. info.CreateUserId = dto.CurrUserId;
  8654. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  8655. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  8656. if (addId <= 0) return Ok(JsonView(false));
  8657. id = addId;
  8658. }
  8659. else //update
  8660. {
  8661. //验证编辑权限
  8662. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8663. if (!isEdit) return Ok(JsonView(false, msg));
  8664. var upd = await _sqlSugar.Updateable(info)
  8665. .UpdateColumns(x => new {
  8666. x.SumJJC,
  8667. x.OutsideJJPay,
  8668. x.SumGWC,
  8669. x.OutsideGWPay,
  8670. x.SumTDC,
  8671. x.OutsideTDPay,
  8672. x.AirJJ,
  8673. x.AirGW,
  8674. x.AirTD,
  8675. x.CityTranffic,
  8676. x.TwoItemRemark
  8677. })
  8678. .Where(x => x.Id == id)
  8679. .ExecuteCommandAsync();
  8680. if (upd <1) return Ok(JsonView(false));
  8681. }
  8682. jjcItemTotal = info.AirJJ + info.CityTranffic;
  8683. gwcItemTotal = info.AirGW + info.CityTranffic;
  8684. tdcItemTotal = info.AirTD + info.CityTranffic;
  8685. //消息通知
  8686. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8687. return Ok(JsonView(new
  8688. {
  8689. parentId = id,
  8690. choiceTwoJJ = dto.ChoiceTwoJJ,
  8691. jjcItemTotal = jjcItemTotal,
  8692. choiceTwoGW = dto.ChoiceTwoGW,
  8693. gwcItemTotal = gwcItemTotal,
  8694. choiceTwoTD = dto.ChoiceTwoTD,
  8695. tdcItemTotal = tdcItemTotal
  8696. }));
  8697. }
  8698. /// <summary>
  8699. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  8700. /// </summary>
  8701. /// <returns></returns>
  8702. [HttpPost]
  8703. [ApiExplorerSettings(IgnoreApi = true)]
  8704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8705. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  8706. {
  8707. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8708. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8709. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8710. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  8711. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  8712. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8713. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  8714. var infos = infos1.Select(x => new Grp_DayAndCost
  8715. {
  8716. Id = x.Id,
  8717. DiId = dto.DiId,
  8718. Type = dto.FeeType,
  8719. Days = x.Days,
  8720. NationalTravelFeeId = x.NationalTravelFeeId,
  8721. Cost = x.Cost,
  8722. Currency = x.Currency,
  8723. SubTotal = x.SubTotal,
  8724. CreateUserId = dto.CurrUserId
  8725. })
  8726. .ToList();
  8727. var adds = infos.Where(x => x.Id <= 0).ToList();
  8728. var upds = infos.Where(x => x.Id > 0).ToList();
  8729. if (adds.Count > 0)
  8730. {
  8731. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8732. if (add < 1) return Ok(JsonView(false));
  8733. }
  8734. if (upds.Count > 0)
  8735. {
  8736. var upd = await _sqlSugar.Updateable(adds)
  8737. .UpdateColumns(x => new
  8738. {
  8739. x.Days,
  8740. x.NationalTravelFeeId,
  8741. x.Cost,
  8742. x.Currency,
  8743. x.SubTotal
  8744. })
  8745. .WhereColumns(x => new { x.Id })
  8746. .ExecuteCommandAsync();
  8747. if (upd < 1) return Ok(JsonView(false));
  8748. }
  8749. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  8750. //消息通知
  8751. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8752. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8753. return Ok(JsonView(new { itemTotal = itemTotal }));
  8754. }
  8755. /// <summary>
  8756. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  8757. /// </summary>
  8758. /// <returns></returns>
  8759. [HttpPost]
  8760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8761. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  8762. {
  8763. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  8764. int subId = dto.SubId, feeType = dto.FeeType;
  8765. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8766. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8767. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8768. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  8769. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  8770. subInfo.Id = subId;
  8771. subInfo.DiId = dto.DiId;
  8772. if (feeType == 3) subInfo.Type = 1;
  8773. else if (feeType == 4) subInfo.Type = 2;
  8774. else if (feeType == 5) subInfo.Type = 3;
  8775. else if (feeType == 6) subInfo.Type = 4;
  8776. subInfo.CreateUserId = dto.CurrUserId;
  8777. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  8778. if (parentId < 1) return Ok(JsonView(false));
  8779. //子表op
  8780. if (subId < 1)
  8781. {
  8782. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8783. if (subAdd < 1) return Ok(JsonView(false));
  8784. }
  8785. else
  8786. {
  8787. //验证编辑权限
  8788. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  8789. if (!isEdit) return Ok(JsonView(false, msg));
  8790. var subUpd = await _sqlSugar.Updateable(subInfo)
  8791. .UpdateColumns(x => new
  8792. {
  8793. x.Days,
  8794. x.NationalTravelFeeId,
  8795. x.Cost,
  8796. x.Currency,
  8797. x.SubTotal
  8798. })
  8799. .WhereColumns(x => new { x.Id })
  8800. .ExecuteCommandAsync();
  8801. if (subUpd < 1) return Ok(JsonView(false));
  8802. }
  8803. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  8804. await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  8805. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8806. }
  8807. /// <summary>
  8808. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  8809. /// </summary>
  8810. /// <returns></returns>
  8811. [HttpPost]
  8812. [ApiExplorerSettings(IgnoreApi = true)]
  8813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8814. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  8815. {
  8816. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8817. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8818. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8819. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  8820. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  8821. {
  8822. Id = x.Id,
  8823. Diid = dto.DiId,
  8824. SetDataId = x.SetDataId,
  8825. Index = x.Index,
  8826. Cost = x.Cost,
  8827. Currency = x.Currency,
  8828. SubTotal = x.SubTotal,
  8829. CreateUserId = dto.CurrUserId,
  8830. Remark = x.Remark
  8831. }).ToList();
  8832. var adds = infos.Where(x => x.Id <= 0).ToList();
  8833. var upds = infos.Where(x => x.Id > 0).ToList();
  8834. if (adds.Count > 0)
  8835. {
  8836. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  8837. if (add < 1) return Ok(JsonView(false));
  8838. }
  8839. if (upds.Count > 0)
  8840. {
  8841. var upd = await _sqlSugar.Updateable(adds)
  8842. .UpdateColumns(x => new
  8843. {
  8844. x.Index,
  8845. x.SetDataId,
  8846. x.Cost,
  8847. x.Currency,
  8848. x.SubTotal,
  8849. x.Remark
  8850. })
  8851. .WhereColumns(x => new { x.Id })
  8852. .ExecuteCommandAsync();
  8853. if (upd < 1) return Ok(JsonView(false));
  8854. }
  8855. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  8856. //消息通知
  8857. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  8858. await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  8859. return Ok(JsonView(new { itemTotal = itemTotal }));
  8860. }
  8861. /// <summary>
  8862. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  8863. /// </summary>
  8864. /// <returns></returns>
  8865. [HttpPost]
  8866. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8867. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  8868. {
  8869. int subId = dto.SubId;
  8870. int diId = dto.Diid;
  8871. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  8872. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  8873. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  8874. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  8875. subInfo.Id = subId;
  8876. subInfo.Diid = dto.Diid;
  8877. subInfo.CreateUserId = dto.CurrUserId;
  8878. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  8879. if (parentId < 1) return Ok(JsonView(false));
  8880. #region 子表op
  8881. if (subId < 1)//add
  8882. {
  8883. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  8884. if (subAdd < 1) return Ok(JsonView(false));
  8885. }
  8886. else //upd
  8887. {
  8888. //验证编辑权限
  8889. (bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  8890. if (!isEdit) return Ok(JsonView(false, msg));
  8891. var subUpd = await _sqlSugar.Updateable(subInfo)
  8892. .UpdateColumns(x => new
  8893. {
  8894. x.Index,
  8895. x.SetDataId,
  8896. x.Cost,
  8897. x.Currency,
  8898. x.SubTotal,
  8899. x.Remark
  8900. })
  8901. .WhereColumns(x => new { x.Id })
  8902. .ExecuteCommandAsync();
  8903. if (subUpd < 1) return Ok(JsonView(false));
  8904. }
  8905. #endregion
  8906. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  8907. //消息通知
  8908. await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  8909. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  8910. }
  8911. /// <summary>
  8912. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  8913. /// </summary>
  8914. /// <returns></returns>
  8915. [HttpPost]
  8916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8917. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  8918. {
  8919. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  8920. if (data.Code != 0)
  8921. {
  8922. return Ok(JsonView(false, data.Msg));
  8923. }
  8924. return Ok(JsonView(true, "操作成功!", data.Data));
  8925. }
  8926. /// <summary>
  8927. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  8928. /// </summary>
  8929. /// <param name="dto"></param>
  8930. /// <returns></returns>
  8931. [HttpPost]
  8932. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  8933. {
  8934. var data = new Grp_DayOtherPrice()
  8935. {
  8936. Id = dto.Id,
  8937. IsDel = 1,
  8938. DeleteUserId = dto.DeleteUserId,
  8939. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  8940. };
  8941. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  8942. if (del > 0) return Ok(JsonView(true,"删除成功!"));
  8943. return Ok(JsonView(false,"删除失败!"));
  8944. }
  8945. #endregion
  8946. #endregion
  8947. //#region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  8948. ///// <summary>
  8949. ///// 出入境费用-草稿 移动端
  8950. ///// 获取币种基础数据(含逻辑处理)
  8951. ///// </summary>
  8952. ///// <returns></returns>
  8953. //private async Task<List<CurrencyInfo>> EnterExitCostDratfMobileGetCurrencyInit()
  8954. //{
  8955. // //默认币种显示
  8956. // var _currencyInfos = _currencyInit;
  8957. // var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  8958. // if (_currencyRate.Count > 0)
  8959. // {
  8960. // foreach (var item in _currencyInfos)
  8961. // {
  8962. // var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  8963. // if (rateInfo != null)
  8964. // {
  8965. // decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
  8966. // rate1 *= 1.035M;
  8967. // item.Rate = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  8968. // }
  8969. // }
  8970. // }
  8971. // return _currencyInfos;
  8972. //}
  8973. ///// <summary>
  8974. ///// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  8975. ///// </summary>
  8976. ///// <returns></returns>
  8977. //[HttpPost]
  8978. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8979. //public async Task<IActionResult> EnterExitCostDraftMobileDataSource(PortDtoBase dto)
  8980. //{
  8981. // string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  8982. // //SetDataInfoView
  8983. // var dataSource = await _sqlSugar.SqlQueryable<Sys_SetData>(sql).ToListAsync();
  8984. // var wordTypeData = dataSource.Where(it => it.STid == 72).ToList(); //三公费用-Word明细类型
  8985. // List<SetDataInfoView> _WordTypeData = _mapper.Map<List<SetDataInfoView>>(wordTypeData);
  8986. // var excelTypeData = dataSource.Where(it => it.STid == 73).ToList(); //三公费用-Excel明细类型
  8987. // List<SetDataInfoView> _ExcelTypeData = _mapper.Map<List<SetDataInfoView>>(excelTypeData);
  8988. // //默认币种显示
  8989. // var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  8990. // return Ok(JsonView(true, "查询成功!", new
  8991. // {
  8992. // WordTypeData = _WordTypeData,
  8993. // ExcelTypeData = _ExcelTypeData,
  8994. // CurrencyInit = _currencyInfos
  8995. // }));
  8996. //}
  8997. ///// <summary>
  8998. ///// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  8999. ///// </summary>
  9000. ///// <returns></returns>
  9001. //[HttpPost]
  9002. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9003. //public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  9004. //{
  9005. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9006. // RefAsync<int> total = 0;
  9007. // int diId = 0;
  9008. // var status = int.TryParse(dto.GroupName, out diId);
  9009. // var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  9010. // .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  9011. // .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  9012. // .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  9013. // .Select(x => new
  9014. // {
  9015. // Id = x.Id,
  9016. // GroupName = x.TeamName
  9017. // })
  9018. // .OrderByDescending(x => x.Id)
  9019. // .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9020. // return Ok(JsonView(true, "查询成功!", data, total));
  9021. //}
  9022. ///// <summary>
  9023. ///// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  9024. ///// </summary>
  9025. ///// <returns></returns>
  9026. //[HttpPost]
  9027. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9028. //public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  9029. //{
  9030. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9031. // RefAsync<int> total = 0;
  9032. // var data = await _sqlSugar.Queryable<Sys_SetData>()
  9033. // .Where(x => x.IsDel == 0 && x.STid == 66)
  9034. // .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  9035. // .Select(x => new
  9036. // {
  9037. // id = x.Id,
  9038. // name = x.Name,
  9039. // remark = x.Remark,
  9040. // })
  9041. // .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9042. // return Ok(JsonView(true, "查询成功!", data, total));
  9043. //}
  9044. ///// <summary>
  9045. ///// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  9046. ///// </summary>
  9047. ///// <returns></returns>
  9048. //[HttpPost]
  9049. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9050. //public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  9051. //{
  9052. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9053. // if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  9054. // var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType,2274, 98);
  9055. // if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  9056. // var groupOtherRateData = groupRateData.TeamRates;
  9057. // var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9058. // if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  9059. // var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  9060. // groupOtherRateData = groupOtherRateData
  9061. // .Select(x => new TeamRateDescAddCurrencyIdView
  9062. // {
  9063. // CurrencyId = x.CurrencyId,
  9064. // CurrencyName = x.CurrencyName,
  9065. // CurrencyCode = x.CurrencyCode,
  9066. // Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  9067. // }).ToList();
  9068. // var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  9069. // return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  9070. //}
  9071. ///// <summary>
  9072. ///// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  9073. ///// </summary>
  9074. ///// <returns></returns>
  9075. //[HttpPost]
  9076. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9077. //public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  9078. //{
  9079. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9080. // var tipsData = new List<int>() { 1, 2, 3 };
  9081. // if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  9082. // if (dto.TipsType == 1)
  9083. // {
  9084. // //默认币种显示
  9085. // var _currencyInfos = _currencyInit;
  9086. // var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
  9087. // List<dynamic> reteInfos = new List<dynamic>();
  9088. // if (_currencyRate.Count > 0)
  9089. // {
  9090. // foreach (var item in _currencyInfos)
  9091. // {
  9092. // var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
  9093. // if (rateInfo != null)
  9094. // {
  9095. // item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
  9096. // decimal rate1 = item.Rate;
  9097. // rate1 *= 1.03M;
  9098. // decimal rate2 = Convert.ToDecimal(rate1.ToString("#0.00")) + 0.01M;
  9099. // reteInfos.Add(new
  9100. // {
  9101. // currCode = item.CurrencyCode,
  9102. // currName = item.CurrencyName,
  9103. // rate = rate2,
  9104. // lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
  9105. // });
  9106. // }
  9107. // }
  9108. // }
  9109. // return Ok(JsonView(true, "查询成功!", reteInfos));
  9110. // }
  9111. // else if (dto.TipsType == 2)
  9112. // {
  9113. // }
  9114. // else if (dto.TipsType == 3)
  9115. // {
  9116. // }
  9117. // return Ok(JsonView(false));
  9118. //}
  9119. ///// <summary>
  9120. ///// 团组模块 - 出入境费用-移动端 - ParentInfo
  9121. ///// </summary>
  9122. ///// <returns></returns>
  9123. //[HttpPost]
  9124. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9125. //public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  9126. //{
  9127. // if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9128. // var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  9129. // var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  9130. // mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  9131. // if (eecInfo == null) return Ok(mobileInfo);
  9132. // //验证查看、操作权限
  9133. // // var isView = await _enterExitCostRep.vi
  9134. // mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  9135. // var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  9136. // .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9137. // .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9138. // .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9139. // .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9140. // {
  9141. // SubId = dac.Id,
  9142. // DiId = dac.DiId,
  9143. // Type = dac.Type,
  9144. // Days = dac.Days,
  9145. // NationalTravelFeeId = dac.NationalTravelFeeId,
  9146. // Arae = $"{ntf.Country}-{ntf.City}",
  9147. // Cost = dac.Cost,
  9148. // Currency = dac.Currency,
  9149. // CurrencyName = sd.Name,
  9150. // SubTotal = dac.SubTotal,
  9151. // })
  9152. // .ToList();
  9153. // mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  9154. // mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  9155. // mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  9156. // mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  9157. // mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  9158. // mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  9159. // mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  9160. // mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  9161. // mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  9162. // //其他款项
  9163. // var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9164. // .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9165. // .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9166. // .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9167. // .OrderBy((dop, sd1, sd2) => dop.Index)
  9168. // .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9169. // {
  9170. // SubId = dop.Id,
  9171. // DiId = dop.Diid,
  9172. // Index = dop.Index,
  9173. // SetDataId = dop.SetDataId,
  9174. // SetDataName = sd1.Name,
  9175. // Cost = dop.Cost,
  9176. // Currency = dop.Currency,
  9177. // CurrencyName = sd2.Remark,
  9178. // SubTotal = dop.SubTotal,
  9179. // Remark = dop.Remark,
  9180. // })
  9181. // .ToArray();
  9182. // mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  9183. // return Ok(mobileInfo);
  9184. //}
  9185. ///// <summary>
  9186. ///// 团组模块 - 出入境费用-移动端 - SubInfo
  9187. ///// </summary>
  9188. ///// <returns></returns>
  9189. //[HttpPost]
  9190. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9191. //public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  9192. //{
  9193. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9194. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9195. // var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  9196. // if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  9197. // var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  9198. // if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  9199. // var subType = dto.SubType;
  9200. // if (subType == 1) //1:境内费用
  9201. // {
  9202. // var oneData = new ChoiceOneMobileSubInfoView()
  9203. // {
  9204. // Id = eecInfo.Id,
  9205. // ChoiceOne = eecInfo.ChoiceOne,
  9206. // ChoiceOneTotalCost = eecInfo.InsidePay,
  9207. // Visa = eecInfo.Visa,
  9208. // VisaRemark = eecInfo.VisaRemark,
  9209. // YiMiao = eecInfo.YiMiao,
  9210. // HeSuan = eecInfo.HeSuan,
  9211. // Service = eecInfo.Service,
  9212. // Ticket = eecInfo.Ticket,
  9213. // Safe = eecInfo.Safe,
  9214. // FirstItemRemark = eecInfo.FirstItemRemark
  9215. // };
  9216. // return Ok(JsonView(oneData));
  9217. // }
  9218. // else if (subType == 2) //2:国际旅费
  9219. // {
  9220. // var twoData = new ChoiceTwoMobileSubInfoView()
  9221. // {
  9222. // Id = eecInfo.Id,
  9223. // ChoiceTwoJJ = eecInfo.SumJJC,
  9224. // OutsideJJPay = eecInfo.OutsideJJPay,
  9225. // ChoiceTwoGW = eecInfo.SumGWC,
  9226. // OutsideGWPay = eecInfo.OutsideGWPay,
  9227. // ChoiceTwoTD = eecInfo.SumTDC,
  9228. // OutsideTDPay = eecInfo.OutsideTDPay,
  9229. // AirJJ = eecInfo.AirJJ,
  9230. // AirGW = eecInfo.AirGW,
  9231. // AirTD = eecInfo.AirTD,
  9232. // CityTranffic = eecInfo.CityTranffic,
  9233. // TwoItemRemark = eecInfo.TwoItemRemark
  9234. // };
  9235. // return Ok(JsonView(twoData));
  9236. // }
  9237. // else if (subType == 3) //3:住宿费
  9238. // {
  9239. // var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9240. // .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9241. // .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9242. // .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  9243. // .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9244. // {
  9245. // SubId = dac.Id,
  9246. // DiId = dac.DiId,
  9247. // Type = dac.Type,
  9248. // Days = dac.Days,
  9249. // NationalTravelFeeId = dac.NationalTravelFeeId,
  9250. // Arae = $"{ntf.Country}-{ntf.City}",
  9251. // Cost = dac.Cost,
  9252. // Currency = dac.Currency,
  9253. // CurrencyName = sd.Name,
  9254. // SubTotal = dac.SubTotal,
  9255. // })
  9256. // .ToArray();
  9257. // var data = new ChoiceMobileSubInfo3To6View()
  9258. // {
  9259. // ParentId = eecInfo.Id,
  9260. // Choice = eecInfo.ChoiceThree,
  9261. // TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9262. // Details = dayAndCostDatas
  9263. // };
  9264. // return Ok(JsonView(data));
  9265. // }
  9266. // else if (subType == 4) //4:伙食费
  9267. // {
  9268. // var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9269. // .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9270. // .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9271. // .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  9272. // .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9273. // {
  9274. // SubId = dac.Id,
  9275. // DiId = dac.DiId,
  9276. // Type = dac.Type,
  9277. // Days = dac.Days,
  9278. // NationalTravelFeeId = dac.NationalTravelFeeId,
  9279. // Arae = $"{ntf.Country}-{ntf.City}",
  9280. // Cost = dac.Cost,
  9281. // Currency = dac.Currency,
  9282. // CurrencyName = sd.Name,
  9283. // SubTotal = dac.SubTotal,
  9284. // })
  9285. // .ToArray();
  9286. // var data = new ChoiceMobileSubInfo3To6View()
  9287. // {
  9288. // ParentId = eecInfo.Id,
  9289. // Choice = eecInfo.ChoiceFour,
  9290. // TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9291. // Details = dayAndCostDatas
  9292. // };
  9293. // return Ok(JsonView(data));
  9294. // }
  9295. // else if (subType == 5) //5:公杂费
  9296. // {
  9297. // var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9298. // .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9299. // .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9300. // .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  9301. // .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9302. // {
  9303. // SubId = dac.Id,
  9304. // DiId = dac.DiId,
  9305. // Type = dac.Type,
  9306. // Days = dac.Days,
  9307. // NationalTravelFeeId = dac.NationalTravelFeeId,
  9308. // Arae = $"{ntf.Country}-{ntf.City}",
  9309. // Cost = dac.Cost,
  9310. // Currency = dac.Currency,
  9311. // CurrencyName = sd.Name,
  9312. // SubTotal = dac.SubTotal,
  9313. // })
  9314. // .ToArray();
  9315. // var data = new ChoiceMobileSubInfo3To6View()
  9316. // {
  9317. // ParentId = eecInfo.Id,
  9318. // Choice = eecInfo.ChoiceFive,
  9319. // TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9320. // Details = dayAndCostDatas
  9321. // };
  9322. // return Ok(JsonView(data));
  9323. // }
  9324. // else if (subType == 6) //6:培训费
  9325. // {
  9326. // var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  9327. // .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  9328. // .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  9329. // .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  9330. // .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  9331. // {
  9332. // SubId = dac.Id,
  9333. // DiId = dac.DiId,
  9334. // Type = dac.Type,
  9335. // Days = dac.Days,
  9336. // NationalTravelFeeId = dac.NationalTravelFeeId,
  9337. // Arae = $"{ntf.Country}-{ntf.City}",
  9338. // Cost = dac.Cost,
  9339. // Currency = dac.Currency,
  9340. // CurrencyName = sd.Name,
  9341. // SubTotal = dac.SubTotal,
  9342. // })
  9343. // .ToArray();
  9344. // var data = new ChoiceMobileSubInfo3To6View()
  9345. // {
  9346. // ParentId = eecInfo.Id,
  9347. // Choice = eecInfo.ChoiceSix,
  9348. // TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  9349. // Details = dayAndCostDatas
  9350. // };
  9351. // return Ok(JsonView(data));
  9352. // }
  9353. // else if (subType == 7) //7:其他
  9354. // {
  9355. // //其他款项
  9356. // var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9357. // .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  9358. // .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  9359. // .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9360. // .OrderBy((dop, sd1, sd2) => dop.Index)
  9361. // .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  9362. // {
  9363. // SubId = dop.Id,
  9364. // DiId = dop.Diid,
  9365. // Index = dop.Index,
  9366. // SetDataId = dop.SetDataId,
  9367. // SetDataName = sd1.Name,
  9368. // Cost = dop.Cost,
  9369. // Currency = dop.Currency,
  9370. // CurrencyName = sd2.Name,
  9371. // SubTotal = dop.SubTotal,
  9372. // Remark = dop.Remark,
  9373. // })
  9374. // .ToArray();
  9375. // var data = new ChoiceSevenMobileSubInfoView()
  9376. // {
  9377. // ParentId = eecInfo.Id,
  9378. // OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  9379. // OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  9380. // Details = otherData
  9381. // };
  9382. // return Ok(JsonView(data));
  9383. // }
  9384. // return Ok(JsonView(false));
  9385. //}
  9386. //#region op
  9387. ///// <summary>
  9388. ///// 移动端更新费用消息通知
  9389. ///// </summary>
  9390. ///// <param name="diid"></param>
  9391. ///// <param name="id"></param>
  9392. ///// <param name="currUserId"></param>
  9393. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  9394. //{
  9395. // try
  9396. // {
  9397. // ////生成默认文件pdf并且通知人员
  9398. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9399. // //{
  9400. // // DiId = diid,
  9401. // // ExportType = 1,
  9402. // // SubTypeId = 1005
  9403. // //}, "pdf");
  9404. // ////发送通知
  9405. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9406. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  9407. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  9408. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  9409. // ////汇率信息记录
  9410. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  9411. // }
  9412. // catch (Exception ex)
  9413. // {
  9414. // //记录日志
  9415. // throw;
  9416. // }
  9417. //}
  9418. ///// <summary>
  9419. ///// 验证出入境费用数据是否存在
  9420. ///// 不存在添加
  9421. ///// </summary>
  9422. ///// <param name="diId"></param>
  9423. ///// <param name="currUserId"></param>
  9424. ///// <returns></returns>
  9425. ///// <exception cref="CustomException"></exception>
  9426. //private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  9427. //{
  9428. // var parentId = 0;
  9429. // var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  9430. // if (info != null) parentId = info.Id;
  9431. // else
  9432. // {
  9433. // var currencys = await EnterExitCostMobileGetCurrencyInit();
  9434. // int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  9435. // if (addId < 1) throw new CustomException("出入境费用添加失败!");
  9436. // parentId = addId;
  9437. // }
  9438. // return parentId;
  9439. //}
  9440. ///// <summary>
  9441. ///// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  9442. ///// </summary>
  9443. ///// <returns></returns>
  9444. //[HttpPost]
  9445. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9446. //public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  9447. //{
  9448. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9449. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9450. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9451. // if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  9452. // var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  9453. // int id = dto.Id;
  9454. // if (id <= 0) //add
  9455. // {
  9456. // var add = await _sqlSugar.Insertable(new Grp_EnterExitCost() { CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  9457. // if (add < 1) return Ok(JsonView(false));
  9458. // id = add;
  9459. // }
  9460. // else //update
  9461. // {
  9462. // var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  9463. // if (upd < 1) return Ok(JsonView(false));
  9464. // }
  9465. // #region 汇率变更时更改币种相关费用
  9466. // var opDayCosts = new List<Grp_DayAndCost>();
  9467. // var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  9468. // var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  9469. // var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  9470. // .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  9471. // .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  9472. // .Select((dac, sd) => new {
  9473. // dac.Id,
  9474. // dac.DiId,
  9475. // CurrencyCode = sd.Name,
  9476. // dac.Cost
  9477. // })
  9478. // .ToList();
  9479. // var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9480. // .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  9481. // .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  9482. // .Select((dop, sd) => new {
  9483. // dop.Id,
  9484. // dop.Diid,
  9485. // CurrencyCode = sd.Name,
  9486. // dop.Cost
  9487. // })
  9488. // .ToList();
  9489. // if (dayCosts.Count > 0)
  9490. // {
  9491. // var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9492. // foreach (var dc in new_dayCosts)
  9493. // {
  9494. // var thisCurrency = dc.Key.ToUpper();
  9495. // var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9496. // if (thisRate == 0.00M) continue;
  9497. // foreach (var dcSub in dc)
  9498. // {
  9499. // opDayCosts.Add(new Grp_DayAndCost()
  9500. // {
  9501. // Id = dcSub.Id,
  9502. // DiId = dcSub.DiId,
  9503. // Cost = dcSub.Cost,
  9504. // SubTotal = dcSub.Cost * thisRate,
  9505. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9506. // });
  9507. // }
  9508. // }
  9509. // if (opDayCosts.Count > 0)
  9510. // {
  9511. // await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9512. // }
  9513. // }
  9514. // if (dayOtherCosts.Count > 0)
  9515. // {
  9516. // var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  9517. // foreach (var dc in new_dayOtherCosts)
  9518. // {
  9519. // var thisCurrency = dc.Key.ToUpper();
  9520. // var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  9521. // if (thisRate == 0.00M) continue;
  9522. // foreach (var dcSub in dc)
  9523. // {
  9524. // opDayOtherCosts.Add(new Grp_DayOtherPrice()
  9525. // {
  9526. // Id = dcSub.Id,
  9527. // Diid = dcSub.Diid,
  9528. // Cost = dcSub.Cost,
  9529. // SubTotal = dcSub.Cost * thisRate,
  9530. // // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  9531. // });
  9532. // }
  9533. // }
  9534. // if (opDayOtherCosts.Count > 0)
  9535. // {
  9536. // await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  9537. // }
  9538. // }
  9539. // #endregion
  9540. // //消息通知
  9541. // await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9542. // //汇率信息记录
  9543. // await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  9544. // return Ok(JsonView(new { parentId = id }));
  9545. //}
  9546. ///// <summary>
  9547. ///// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  9548. ///// </summary>
  9549. ///// <returns></returns>
  9550. //[HttpPost]
  9551. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9552. //public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  9553. //{
  9554. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9555. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9556. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9557. // var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  9558. // int id = dto.Id;
  9559. // if (id <= 0) //add
  9560. // {
  9561. // checkboxInfo.CreateUserId = dto.CurrUserId;
  9562. // checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9563. // var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9564. // if (add < 1) return Ok(JsonView(false));
  9565. // }
  9566. // else //update
  9567. // {
  9568. // var upd = await _sqlSugar.Updateable(checkboxInfo)
  9569. // .UpdateColumns(x => new {
  9570. // x.ChoiceOne,
  9571. // x.ChoiceTwo,
  9572. // x.SumJJC,
  9573. // x.SumGWC,
  9574. // x.SumTDC,
  9575. // x.ChoiceThree,
  9576. // x.ChoiceFour,
  9577. // x.ChoiceFive,
  9578. // x.ChoiceSix,
  9579. // x.OtherExpenses_Checked
  9580. // })
  9581. // .Where(x => x.Id == id)
  9582. // .ExecuteCommandAsync();
  9583. // if (upd < 1) return Ok(JsonView(false));
  9584. // }
  9585. // return Ok(JsonView(new { parentId = id }));
  9586. //}
  9587. ///// <summary>
  9588. ///// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  9589. ///// </summary>
  9590. ///// <returns></returns>
  9591. //[HttpPost]
  9592. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9593. //public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  9594. //{
  9595. // int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  9596. // var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  9597. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9598. // if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9599. // if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9600. // if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  9601. // var checkboxInfo = new Grp_EnterExitCost()
  9602. // {
  9603. // Id = id,
  9604. // DiId = diId,
  9605. // CreateUserId = currUserId
  9606. // };
  9607. // if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  9608. // else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  9609. // else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  9610. // else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  9611. // else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  9612. // if (id <= 0) //add
  9613. // {
  9614. // checkboxInfo.CreateUserId = dto.CurrUserId;
  9615. // checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9616. // var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  9617. // if (add < 1) return Ok(JsonView(false));
  9618. // }
  9619. // else //update
  9620. // {
  9621. // var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  9622. // .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  9623. // .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  9624. // .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  9625. // .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  9626. // .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  9627. // .Where(x => x.Id == id)
  9628. // .ExecuteCommandAsync();
  9629. // if (upd < 1) return Ok(JsonView(false));
  9630. // }
  9631. // return Ok(JsonView(new { parentId = id }));
  9632. //}
  9633. ///// <summary>
  9634. ///// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  9635. ///// </summary>
  9636. ///// <returns></returns>
  9637. //[HttpPost]
  9638. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9639. //public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  9640. //{
  9641. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9642. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9643. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9644. // var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9645. // info.FirstItemRemark = dto.FirstItemRemark;
  9646. // info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  9647. // int id = dto.Id;
  9648. // if (id <= 0) //add
  9649. // {
  9650. // info.CreateUserId = dto.CurrUserId;
  9651. // info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9652. // var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9653. // if (add < 1) return Ok(JsonView(false));
  9654. // id = add;
  9655. // }
  9656. // else //update
  9657. // {
  9658. // var upd = await _sqlSugar.Updateable(info)
  9659. // .UpdateColumns(x => new {
  9660. // x.ChoiceOne,
  9661. // x.InsidePay,
  9662. // x.VisaRemark,
  9663. // x.Visa,
  9664. // x.Service,
  9665. // x.Safe,
  9666. // x.Ticket,
  9667. // x.HeSuan,
  9668. // x.YiMiao,
  9669. // x.FirstItemRemark
  9670. // })
  9671. // .Where(x => x.Id == id)
  9672. // .ExecuteCommandAsync();
  9673. // if (upd < 1) return Ok(JsonView(false));
  9674. // }
  9675. // //消息通知
  9676. // await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9677. // return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  9678. //}
  9679. ///// <summary>
  9680. ///// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  9681. ///// </summary>
  9682. ///// <returns></returns>
  9683. //[HttpPost]
  9684. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9685. //public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  9686. //{
  9687. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9688. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9689. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9690. // var info = _mapper.Map<Grp_EnterExitCost>(dto);
  9691. // info.OutsideJJPay = dto.OutsideJJPay;
  9692. // info.OutsideGWPay = dto.OutsideGWPay;
  9693. // info.OutsideTDPay = dto.OutsideTDPay;
  9694. // info.AirJJ = dto.AirJJ;
  9695. // info.AirGW = dto.AirGW;
  9696. // info.AirTD = dto.AirTD;
  9697. // info.CityTranffic = dto.CityTranffic;
  9698. // info.TwoItemRemark = dto.TwoItemRemark;
  9699. // info.SumJJC = dto.ChoiceTwoJJ;
  9700. // info.SumGWC = dto.ChoiceTwoGW;
  9701. // info.SumTDC = dto.ChoiceTwoTD;
  9702. // int id = dto.Id;
  9703. // decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  9704. // if (id <= 0) //add
  9705. // {
  9706. // info.CreateUserId = dto.CurrUserId;
  9707. // info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  9708. // var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  9709. // if (addId <= 0) return Ok(JsonView(false));
  9710. // id = addId;
  9711. // }
  9712. // else //update
  9713. // {
  9714. // var upd = await _sqlSugar.Updateable(info)
  9715. // .UpdateColumns(x => new {
  9716. // x.SumJJC,
  9717. // x.OutsideJJPay,
  9718. // x.SumGWC,
  9719. // x.OutsideGWPay,
  9720. // x.SumTDC,
  9721. // x.OutsideTDPay,
  9722. // x.AirJJ,
  9723. // x.AirGW,
  9724. // x.AirTD,
  9725. // x.CityTranffic,
  9726. // x.TwoItemRemark
  9727. // })
  9728. // .Where(x => x.Id == id)
  9729. // .ExecuteCommandAsync();
  9730. // if (upd < 1) return Ok(JsonView(false));
  9731. // }
  9732. // jjcItemTotal = info.AirJJ + info.CityTranffic;
  9733. // gwcItemTotal = info.AirGW + info.CityTranffic;
  9734. // tdcItemTotal = info.AirTD + info.CityTranffic;
  9735. // //消息通知
  9736. // await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9737. // return Ok(JsonView(new
  9738. // {
  9739. // parentId = id,
  9740. // choiceTwoJJ = dto.ChoiceTwoJJ,
  9741. // jjcItemTotal = jjcItemTotal,
  9742. // choiceTwoGW = dto.ChoiceTwoGW,
  9743. // gwcItemTotal = gwcItemTotal,
  9744. // choiceTwoTD = dto.ChoiceTwoTD,
  9745. // tdcItemTotal = tdcItemTotal
  9746. // }));
  9747. //}
  9748. ///// <summary>
  9749. ///// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  9750. ///// </summary>
  9751. ///// <returns></returns>
  9752. //[HttpPost]
  9753. //[ApiExplorerSettings(IgnoreApi = true)]
  9754. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9755. //public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  9756. //{
  9757. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9758. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9759. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9760. // if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  9761. // var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  9762. // if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9763. // var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  9764. // var infos = infos1.Select(x => new Grp_DayAndCost
  9765. // {
  9766. // Id = x.Id,
  9767. // DiId = dto.DiId,
  9768. // Type = dto.FeeType,
  9769. // Days = x.Days,
  9770. // NationalTravelFeeId = x.NationalTravelFeeId,
  9771. // Cost = x.Cost,
  9772. // Currency = x.Currency,
  9773. // SubTotal = x.SubTotal,
  9774. // CreateUserId = dto.CurrUserId
  9775. // })
  9776. // .ToList();
  9777. // var adds = infos.Where(x => x.Id <= 0).ToList();
  9778. // var upds = infos.Where(x => x.Id > 0).ToList();
  9779. // if (adds.Count > 0)
  9780. // {
  9781. // var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9782. // if (add < 1) return Ok(JsonView(false));
  9783. // }
  9784. // if (upds.Count > 0)
  9785. // {
  9786. // var upd = await _sqlSugar.Updateable(adds)
  9787. // .UpdateColumns(x => new
  9788. // {
  9789. // x.Days,
  9790. // x.NationalTravelFeeId,
  9791. // x.Cost,
  9792. // x.Currency,
  9793. // x.SubTotal
  9794. // })
  9795. // .WhereColumns(x => new { x.Id })
  9796. // .ExecuteCommandAsync();
  9797. // if (upd < 1) return Ok(JsonView(false));
  9798. // }
  9799. // var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  9800. // //消息通知
  9801. // var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9802. // await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9803. // return Ok(JsonView(new { itemTotal = itemTotal }));
  9804. //}
  9805. ///// <summary>
  9806. ///// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  9807. ///// </summary>
  9808. ///// <returns></returns>
  9809. //[HttpPost]
  9810. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9811. //public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  9812. //{
  9813. // var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  9814. // int subId = dto.SubId, feeType = dto.FeeType;
  9815. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9816. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9817. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9818. // if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  9819. // var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  9820. // subInfo.Id = subId;
  9821. // subInfo.DiId = dto.DiId;
  9822. // if (feeType == 3) subInfo.Type = 1;
  9823. // else if (feeType == 4) subInfo.Type = 2;
  9824. // else if (feeType == 5) subInfo.Type = 3;
  9825. // else if (feeType == 6) subInfo.Type = 4;
  9826. // subInfo.CreateUserId = dto.CurrUserId;
  9827. // int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  9828. // if (parentId < 1) return Ok(JsonView(false));
  9829. // //子表op
  9830. // if (subId < 1)
  9831. // {
  9832. // var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9833. // if (subAdd < 1) return Ok(JsonView(false));
  9834. // }
  9835. // else
  9836. // {
  9837. // var subUpd = await _sqlSugar.Updateable(subInfo)
  9838. // .UpdateColumns(x => new
  9839. // {
  9840. // x.Days,
  9841. // x.NationalTravelFeeId,
  9842. // x.Cost,
  9843. // x.Currency,
  9844. // x.SubTotal
  9845. // })
  9846. // .WhereColumns(x => new { x.Id })
  9847. // .ExecuteCommandAsync();
  9848. // if (subUpd < 1) return Ok(JsonView(false));
  9849. // }
  9850. // var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  9851. // await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  9852. // return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9853. //}
  9854. ///// <summary>
  9855. ///// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  9856. ///// </summary>
  9857. ///// <returns></returns>
  9858. //[HttpPost]
  9859. //[ApiExplorerSettings(IgnoreApi = true)]
  9860. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9861. //public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  9862. //{
  9863. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9864. // if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9865. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9866. // var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  9867. // var infos = infos1.Select(x => new Grp_DayOtherPrice()
  9868. // {
  9869. // Id = x.Id,
  9870. // Diid = dto.DiId,
  9871. // SetDataId = x.SetDataId,
  9872. // Index = x.Index,
  9873. // Cost = x.Cost,
  9874. // Currency = x.Currency,
  9875. // SubTotal = x.SubTotal,
  9876. // CreateUserId = dto.CurrUserId,
  9877. // Remark = x.Remark
  9878. // }).ToList();
  9879. // var adds = infos.Where(x => x.Id <= 0).ToList();
  9880. // var upds = infos.Where(x => x.Id > 0).ToList();
  9881. // if (adds.Count > 0)
  9882. // {
  9883. // var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  9884. // if (add < 1) return Ok(JsonView(false));
  9885. // }
  9886. // if (upds.Count > 0)
  9887. // {
  9888. // var upd = await _sqlSugar.Updateable(adds)
  9889. // .UpdateColumns(x => new
  9890. // {
  9891. // x.Index,
  9892. // x.SetDataId,
  9893. // x.Cost,
  9894. // x.Currency,
  9895. // x.SubTotal,
  9896. // x.Remark
  9897. // })
  9898. // .WhereColumns(x => new { x.Id })
  9899. // .ExecuteCommandAsync();
  9900. // if (upd < 1) return Ok(JsonView(false));
  9901. // }
  9902. // var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  9903. // //消息通知
  9904. // var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  9905. // await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  9906. // return Ok(JsonView(new { itemTotal = itemTotal }));
  9907. //}
  9908. ///// <summary>
  9909. ///// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  9910. ///// </summary>
  9911. ///// <returns></returns>
  9912. //[HttpPost]
  9913. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9914. //public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  9915. //{
  9916. // int subId = dto.SubId;
  9917. // int diId = dto.Diid;
  9918. // if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  9919. // if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9920. // if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9921. // var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  9922. // subInfo.Id = subId;
  9923. // subInfo.Diid = dto.Diid;
  9924. // subInfo.CreateUserId = dto.CurrUserId;
  9925. // int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  9926. // if (parentId < 1) return Ok(JsonView(false));
  9927. // #region 子表op
  9928. // if (subId < 1)//add
  9929. // {
  9930. // var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  9931. // if (subAdd < 1) return Ok(JsonView(false));
  9932. // }
  9933. // else //upd
  9934. // {
  9935. // var subUpd = await _sqlSugar.Updateable(subInfo)
  9936. // .UpdateColumns(x => new
  9937. // {
  9938. // x.Index,
  9939. // x.SetDataId,
  9940. // x.Cost,
  9941. // x.Currency,
  9942. // x.SubTotal,
  9943. // x.Remark
  9944. // })
  9945. // .WhereColumns(x => new { x.Id })
  9946. // .ExecuteCommandAsync();
  9947. // if (subUpd < 1) return Ok(JsonView(false));
  9948. // }
  9949. // #endregion
  9950. // var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  9951. // //消息通知
  9952. // await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  9953. // return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  9954. //}
  9955. ///// <summary>
  9956. ///// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  9957. ///// </summary>
  9958. ///// <returns></returns>
  9959. //[HttpPost]
  9960. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9961. //public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  9962. //{
  9963. // var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9964. // if (data.Code != 0)
  9965. // {
  9966. // return Ok(JsonView(false, data.Msg));
  9967. // }
  9968. // return Ok(JsonView(true, "操作成功!", data.Data));
  9969. //}
  9970. ///// <summary>
  9971. ///// 团组模块 - 出入境费用-移动端 - 其他费用删除
  9972. ///// </summary>
  9973. ///// <param name="dto"></param>
  9974. ///// <returns></returns>
  9975. //[HttpPost]
  9976. //public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  9977. //{
  9978. // var data = new Grp_DayOtherPrice()
  9979. // {
  9980. // Id = dto.Id,
  9981. // IsDel = 1,
  9982. // DeleteUserId = dto.DeleteUserId,
  9983. // DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9984. // };
  9985. // var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9986. // if (del > 0) return Ok(JsonView(true, "删除成功!"));
  9987. // return Ok(JsonView(false, "删除失败!"));
  9988. //}
  9989. //#endregion
  9990. //#endregion
  9991. #region 签证费用录入
  9992. /// <summary>
  9993. /// 根据diid查询签证费用列表
  9994. /// </summary>
  9995. /// <param name="dto"></param>
  9996. /// <returns></returns>
  9997. [HttpPost]
  9998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9999. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  10000. {
  10001. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  10002. if (groupData.Code != 0)
  10003. {
  10004. return Ok(JsonView(false, groupData.Msg));
  10005. }
  10006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10007. }
  10008. /// <summary>
  10009. /// 根据签证费用Id查询单条数据及c表数据
  10010. /// </summary>
  10011. /// <param name="dto"></param>
  10012. /// <returns></returns>
  10013. [HttpPost]
  10014. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10015. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  10016. {
  10017. Result groupData = await _visaPriceRep.PostVisaById(dto);
  10018. if (groupData.Code != 0)
  10019. {
  10020. return Ok(JsonView(false, groupData.Msg));
  10021. }
  10022. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10023. }
  10024. /// <summary>
  10025. /// 签证费用删除
  10026. /// </summary>
  10027. /// <param name="dto"></param>
  10028. /// <returns></returns>
  10029. [HttpPost]
  10030. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10031. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  10032. {
  10033. _sqlSugar.BeginTran();
  10034. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  10035. if (!res)
  10036. {
  10037. _sqlSugar.RollbackTran();
  10038. return Ok(JsonView(false, "删除失败"));
  10039. }
  10040. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  10041. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  10042. .SetColumns(a => new Grp_CreditCardPayment()
  10043. {
  10044. IsDel = 1,
  10045. DeleteUserId = dto.DeleteUserId,
  10046. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10047. })
  10048. .ExecuteCommand();
  10049. if (resSub < 1)
  10050. {
  10051. _sqlSugar.RollbackTran();
  10052. return Ok(JsonView(false, "删除失败"));
  10053. }
  10054. _sqlSugar.CommitTran();
  10055. return Ok(JsonView(true, "删除成功!"));
  10056. }
  10057. /// <summary>
  10058. /// 签证费用录入下拉框初始化
  10059. /// </summary>
  10060. /// <returns></returns>
  10061. [HttpPost]
  10062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10063. public async Task<IActionResult> VisaPriceAddSelect()
  10064. {
  10065. //支付方式
  10066. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  10067. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  10068. //币种
  10069. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  10070. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  10071. //乘客类型
  10072. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  10073. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  10074. //卡类型
  10075. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  10076. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  10077. //代办费类型
  10078. var agencyFeeTypeData = new List<dynamic>() {
  10079. new { id = 0 , Text = "未选择" },
  10080. new { id = 1 , Text = "小公务" },
  10081. new { id = 2 , Text = "大公务" },
  10082. };
  10083. //签证费用标准国家Data
  10084. var visaCountryFeeData = _sqlSugar.Queryable<Res_CountryFeeCost>().Where(x => x.IsDel == 0).Select(x => new { x.Id, Country = x.VisaCountry }).ToList();
  10085. var data = new
  10086. {
  10087. Payment = _Payment,
  10088. CurrencyList = _CurrencyList,
  10089. PassengerType = _PassengerType,
  10090. BankCard = _BankCard,
  10091. AgencyFeeType = agencyFeeTypeData,
  10092. CountryFeeData = visaCountryFeeData
  10093. };
  10094. return Ok(JsonView(true, "查询成功!", data));
  10095. }
  10096. /// <summary>
  10097. /// 签证费用录入操作(Status:1.新增,2.修改)
  10098. /// </summary>
  10099. /// <param name="dto"></param>
  10100. /// <returns></returns>
  10101. [HttpPost]
  10102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10103. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  10104. {
  10105. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  10106. if (groupData.Code != 0)
  10107. {
  10108. return Ok(JsonView(false, groupData.Msg));
  10109. }
  10110. #region 应用推送
  10111. try
  10112. {
  10113. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10114. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10115. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10116. //2024-10-21 新增LZ UID
  10117. var userIds = new List<int>() { 21 };
  10118. string title = $"系统通知";
  10119. string content = "";
  10120. var diId = dto.DiId;
  10121. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10122. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10123. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10124. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  10125. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10126. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10127. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10128. }
  10129. catch (Exception ex)
  10130. {
  10131. }
  10132. #endregion
  10133. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10134. }
  10135. #endregion
  10136. #region 签证提成录入
  10137. /// <summary>
  10138. /// 签证提成录入
  10139. /// 基础数据
  10140. /// </summary>
  10141. /// <param name="_dto"></param>
  10142. /// <returns></returns>
  10143. [HttpGet]
  10144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10145. public async Task<IActionResult> VisaCommissionInit()
  10146. {
  10147. return Ok(await _visaCommissionRep.Init());
  10148. }
  10149. /// <summary>
  10150. /// 签证提成录入
  10151. /// Item
  10152. /// </summary>
  10153. /// <param name="_dto"></param>
  10154. /// <returns></returns>
  10155. [HttpPost]
  10156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10157. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  10158. {
  10159. var validator = new VisaCommissionItemDtoValidator();
  10160. var validatorRes = await validator.ValidateAsync(_dto);
  10161. if (!validatorRes.IsValid)
  10162. {
  10163. StringBuilder sb = new StringBuilder();
  10164. foreach (var item in validatorRes.Errors)
  10165. {
  10166. sb.AppendLine(item.ErrorMessage);
  10167. }
  10168. return Ok(JsonView(false, sb.ToString()));
  10169. }
  10170. return Ok(await _visaCommissionRep.Item(_dto));
  10171. }
  10172. /// <summary>
  10173. /// 签证提成录入
  10174. /// Save
  10175. /// </summary>
  10176. /// <param name="_dto"></param>
  10177. /// <returns></returns>
  10178. [HttpPost]
  10179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10180. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  10181. {
  10182. //参数验证
  10183. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  10184. foreach (var item in _dto.Items)
  10185. {
  10186. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  10187. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  10188. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  10189. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  10190. }
  10191. return Ok(await _visaCommissionRep.Save(_dto));
  10192. }
  10193. /// <summary>
  10194. /// 签证提成录入
  10195. /// Create
  10196. /// </summary>
  10197. /// <param name="_dto"></param>
  10198. /// <returns></returns>
  10199. [HttpPost]
  10200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10201. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  10202. {
  10203. var validator = new VisaCommissionCreateDtoValidator();
  10204. var validatorRes = await validator.ValidateAsync(_dto);
  10205. if (!validatorRes.IsValid)
  10206. {
  10207. StringBuilder sb = new StringBuilder();
  10208. foreach (var item in validatorRes.Errors)
  10209. {
  10210. sb.AppendLine(item.ErrorMessage);
  10211. }
  10212. return Ok(JsonView(false, sb.ToString()));
  10213. }
  10214. return Ok(await _visaCommissionRep.Create(_dto));
  10215. }
  10216. /// <summary>
  10217. /// 签证提成录入
  10218. /// Put(编辑)
  10219. /// </summary>
  10220. /// <param name="id"></param>
  10221. /// <param name="_dto"></param>
  10222. /// <returns></returns>
  10223. [HttpPut]
  10224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10225. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  10226. {
  10227. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10228. var validator = new VisaCommissionCreateDtoValidator();
  10229. var validatorRes = await validator.ValidateAsync(_dto);
  10230. if (!validatorRes.IsValid)
  10231. {
  10232. StringBuilder sb = new StringBuilder();
  10233. foreach (var item in validatorRes.Errors)
  10234. {
  10235. sb.AppendLine(item.ErrorMessage);
  10236. }
  10237. return Ok(JsonView(false, sb.ToString()));
  10238. }
  10239. return Ok(await _visaCommissionRep.Edit(id, _dto));
  10240. }
  10241. /// <summary>
  10242. /// 签证提成录入
  10243. /// Del
  10244. /// </summary>
  10245. /// <param name="id"></param>
  10246. /// <param name="currUserId"></param>
  10247. /// <returns></returns>
  10248. [HttpPost]
  10249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10250. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  10251. {
  10252. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  10253. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  10254. return Ok(await _visaCommissionRep.Del(id, currUserId));
  10255. }
  10256. #endregion
  10257. #region op费用录入
  10258. /// <summary>
  10259. /// 根据diid查询op费用列表
  10260. /// </summary>
  10261. /// <param name="dto"></param>
  10262. /// <returns></returns>
  10263. [HttpPost]
  10264. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10265. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  10266. {
  10267. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  10268. if (groupData.Code != 0)
  10269. {
  10270. return Ok(JsonView(false, groupData.Msg));
  10271. }
  10272. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10273. }
  10274. /// <summary>
  10275. /// 根据op费用Id查询单条数据及c表数据
  10276. /// </summary>
  10277. /// <param name="dto"></param>
  10278. /// <returns></returns>
  10279. [HttpPost]
  10280. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10281. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  10282. {
  10283. try
  10284. {
  10285. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  10286. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  10287. var data = new
  10288. {
  10289. CarTouristGuideGround = _groupData,
  10290. CreditCardPayment = _creditCardPayment
  10291. };
  10292. return Ok(JsonView(true, "查询成功!", data));
  10293. }
  10294. catch (Exception ex)
  10295. {
  10296. return Ok(JsonView(false, "程序错误!"));
  10297. }
  10298. }
  10299. /// <summary>
  10300. /// op费用删除
  10301. /// </summary>
  10302. /// <param name="dto"></param>
  10303. /// <returns></returns>
  10304. [HttpPost]
  10305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10306. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  10307. {
  10308. try
  10309. {
  10310. _sqlSugar.BeginTran();
  10311. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  10312. if (!res)
  10313. {
  10314. return Ok(JsonView(false, "删除失败"));
  10315. }
  10316. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  10317. {
  10318. IsDel = 1,
  10319. DeleteUserId = dto.DeleteUserId,
  10320. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10321. }).ExecuteCommandAsync();
  10322. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  10323. {
  10324. IsDel = 1,
  10325. DeleteUserId = dto.DeleteUserId,
  10326. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10327. }).ExecuteCommandAsync();
  10328. #region 删除超支相关数据
  10329. //删除导入的超支数据
  10330. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  10331. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  10332. {
  10333. IsDel = 1,
  10334. DeleteUserId = dto.DeleteUserId,
  10335. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10336. }).ExecuteCommand();
  10337. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  10338. {
  10339. IsDel = 1,
  10340. DeleteUserId = dto.DeleteUserId,
  10341. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10342. }).ExecuteCommand();
  10343. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  10344. {
  10345. IsDel = 1,
  10346. DeleteUserId = dto.DeleteUserId,
  10347. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10348. }).ExecuteCommand();
  10349. #endregion
  10350. _sqlSugar.CommitTran();
  10351. return Ok(JsonView(true, "删除成功!"));
  10352. }
  10353. catch (Exception ex)
  10354. {
  10355. _sqlSugar.RollbackTran();
  10356. return Ok(JsonView(false, "程序错误!" + ex.Message));
  10357. }
  10358. }
  10359. /// <summary>
  10360. /// op费用录入操作(Status:1.新增,2.修改)
  10361. /// </summary>
  10362. /// <param name="dto"></param>
  10363. /// <returns></returns>
  10364. [HttpPost]
  10365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10366. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  10367. {
  10368. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  10369. if (groupData.Code != 0)
  10370. {
  10371. return Ok(JsonView(false, groupData.Msg));
  10372. }
  10373. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10374. }
  10375. /// <summary>
  10376. /// 填写费用详细页面初始化绑定
  10377. /// </summary>
  10378. /// <param name="dto"></param>
  10379. /// <returns></returns>
  10380. [HttpPost]
  10381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10382. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  10383. {
  10384. try
  10385. {
  10386. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  10387. if (groupData.Code != 0)
  10388. {
  10389. return Ok(JsonView(false, groupData.Msg));
  10390. }
  10391. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10392. }
  10393. catch (Exception ex)
  10394. {
  10395. return Ok(JsonView(false, ex.Message));
  10396. }
  10397. }
  10398. /// <summary>
  10399. /// 根据op费用Id查询详细数据
  10400. /// </summary>
  10401. /// <param name="dto"></param>
  10402. /// <returns></returns>
  10403. [HttpPost]
  10404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10405. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  10406. {
  10407. try
  10408. {
  10409. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  10410. if (groupData.Code != 0)
  10411. {
  10412. return Ok(JsonView(false, groupData.Msg));
  10413. }
  10414. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10415. }
  10416. catch (Exception ex)
  10417. {
  10418. return Ok(JsonView(false, ex.Message));
  10419. }
  10420. }
  10421. /// <summary>
  10422. /// OP费用录入填写详情
  10423. /// </summary>
  10424. /// <param name="dto"></param>
  10425. /// <returns></returns>
  10426. [HttpPost]
  10427. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10428. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  10429. {
  10430. try
  10431. {
  10432. #region 参数校验
  10433. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  10434. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  10435. if (di == null) return Ok(JsonView(false, "团组错误!"));
  10436. #endregion
  10437. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  10438. if (groupData.Code != 0)
  10439. {
  10440. return Ok(JsonView(false, groupData.Msg));
  10441. }
  10442. //自动审核
  10443. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  10444. #region 应用推送
  10445. try
  10446. {
  10447. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  10448. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  10449. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  10450. //2024-10-21 新增LZ UID
  10451. var userIds = new List<int>() { 21 };
  10452. string title = $"系统通知";
  10453. var diId = dto.DiId;
  10454. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  10455. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  10456. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage).ToString("#0.00")} CNY;";
  10457. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  10458. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  10459. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  10460. }
  10461. catch (Exception ex)
  10462. {
  10463. }
  10464. #endregion
  10465. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  10466. }
  10467. catch (Exception ex)
  10468. {
  10469. return Ok(JsonView(false, ex.Message));
  10470. }
  10471. }
  10472. /// <summary>
  10473. /// 获取三公详细所有城市
  10474. /// </summary>
  10475. /// <returns></returns>
  10476. [HttpGet]
  10477. public IActionResult OpCarCityResult()
  10478. {
  10479. var jw = JsonView(false);
  10480. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  10481. {
  10482. x.Id,
  10483. x.Country,
  10484. x.City,
  10485. }).ToList();
  10486. if (data.Count > 0)
  10487. {
  10488. jw = JsonView(true, "获取成功!", data);
  10489. }
  10490. else
  10491. {
  10492. jw.Msg = "城市数据为空!";
  10493. jw.Data = new string[0];
  10494. }
  10495. return Ok(jw);
  10496. }
  10497. /// <summary>
  10498. /// 导出地接费用明细
  10499. /// </summary>
  10500. /// <param name="dto"></param>
  10501. /// <returns></returns>
  10502. [HttpPost]
  10503. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  10504. {
  10505. var jw = JsonView(false);
  10506. if (dto.Diid < 1)
  10507. {
  10508. jw.Msg = "请输入正确的diid!";
  10509. return Ok(jw);
  10510. }
  10511. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  10512. if (group == null)
  10513. {
  10514. jw.Msg = "未找到团组信息!";
  10515. return Ok(jw);
  10516. }
  10517. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  10518. if (localGuideArr.Count == 0)
  10519. {
  10520. jw.Msg = "该团组暂无地接信息!";
  10521. return Ok(jw);
  10522. }
  10523. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  10524. var overspendSoure = new Dictionary<int, int>
  10525. {
  10526. { 91, 982 }, //车
  10527. { 92 , 1059} ,//导游
  10528. { 994 , 1073}, //翻译
  10529. { 988 , 1074 }, //早餐
  10530. { 93 , 1075 }, //午餐
  10531. { 989 , 1076 }, //晚餐
  10532. };
  10533. Dictionary<string, Stream> Zips = new Dictionary<string, Stream>();
  10534. foreach (var groupArr in localGroup)
  10535. {
  10536. var keyValue = groupArr.Key;
  10537. if (int.TryParse(keyValue, out int cityid))
  10538. {
  10539. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  10540. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  10541. }
  10542. List<List<Grp_CarTouristGuideGroundReservationsContentExtend>> contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  10543. foreach (var item in groupArr)
  10544. {
  10545. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  10546. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  10547. new Grp_CarTouristGuideGroundReservationsContentExtend
  10548. {
  10549. Count = a.Count,
  10550. CreateTime = a.CreateTime,
  10551. CreateUserId = a.CreateUserId,
  10552. CTGGRId = a.CTGGRId,
  10553. Currency = a.Currency,
  10554. DatePrice = a.DatePrice,
  10555. DeleteTime = a.DeleteTime,
  10556. DeleteUserId = a.DeleteUserId,
  10557. DiId = a.DiId,
  10558. Id = a.Id,
  10559. IsDel = a.IsDel,
  10560. Price = a.Price,
  10561. PriceContent = a.PriceContent,
  10562. Remark = a.Remark,
  10563. SId = a.SId,
  10564. SidName = b.Name,
  10565. Units = a.Units,
  10566. }
  10567. ).ToList();
  10568. if (content.Count > 0)
  10569. {
  10570. contentArr.Add(content);
  10571. }
  10572. }
  10573. //open excel
  10574. //set excel
  10575. //save excel
  10576. try
  10577. {
  10578. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  10579. IWorkbook workbook;
  10580. if (Path.GetExtension(filePath).ToLower() == ".xls")
  10581. {
  10582. workbook = new HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10583. }
  10584. else
  10585. {
  10586. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  10587. }
  10588. ISheet sheet = workbook.GetSheetAt(0);
  10589. var rowStartIndex = 2;
  10590. var clounmCount = 10;
  10591. var initStyleRow = sheet.GetRow(2);
  10592. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  10593. //var overspendArrDetail =
  10594. var existsId = new List<CarCompare>();
  10595. var lastElem = arr.Last();
  10596. var thisSid = -1;
  10597. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  10598. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  10599. {
  10600. Name = "未知币种!",
  10601. Remark = "未知币种!",
  10602. };
  10603. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  10604. Action cloneRowFn = () =>
  10605. {
  10606. rowStartIndex++;
  10607. var cloneRow = sheet.CreateRow(rowStartIndex);
  10608. // 复制样式
  10609. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  10610. {
  10611. ICell sourceCell = initStyleRow.GetCell(i);
  10612. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  10613. // 确保单元格存在样式
  10614. if (sourceCell.CellStyle != null)
  10615. {
  10616. targetCell.CellStyle = sourceCell.CellStyle;
  10617. }
  10618. }
  10619. };
  10620. var mergeRow = () =>
  10621. {
  10622. for (int i = 2; i < sheet.LastRowNum; i++)
  10623. {
  10624. var row = sheet.GetRow(i);
  10625. var cellFirst = row.GetCell(0);
  10626. var thisIndex = i + 1;
  10627. while (thisIndex < sheet.LastRowNum)
  10628. {
  10629. var nextRow = sheet.GetRow(thisIndex);
  10630. var nextCellFirst = nextRow.GetCell(0);
  10631. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  10632. {
  10633. thisIndex++;
  10634. }
  10635. else
  10636. {
  10637. break;
  10638. }
  10639. }
  10640. thisIndex--;
  10641. if (thisIndex != i)
  10642. {
  10643. //合并row
  10644. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10645. i, // 起始行索引(0-based)
  10646. thisIndex, // 结束行索引(0-based)
  10647. 0, // 起始列索引(0-based)
  10648. 0 // 结束列索引(0-based)
  10649. );
  10650. sheet.AddMergedRegion(cellRangeAddress);
  10651. i = thisIndex;
  10652. }
  10653. }
  10654. };
  10655. var chaoshiNumber = 0;
  10656. var totalNumber = 0.00M;
  10657. string lastStr = "";
  10658. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  10659. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  10660. {
  10661. b.IsAuditGM,
  10662. x.Id,
  10663. x.Area,
  10664. b.PayPercentage,
  10665. b.PayMoney,
  10666. }).ToList();
  10667. string yesPayment = "", noPayment = "";
  10668. foreach (var item in queryCarArrByCityAndDiid)
  10669. {
  10670. if (item.IsAuditGM == 1)
  10671. {
  10672. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10673. }
  10674. else
  10675. {
  10676. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  10677. }
  10678. }
  10679. lastStr = yesPayment + noPayment;
  10680. foreach (var item in arr)
  10681. {
  10682. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.Values.Contains(item.SId))
  10683. {
  10684. if (thisSid != item.SId)
  10685. {
  10686. if (thisSid == -1)
  10687. {
  10688. thisSid = item.SId;
  10689. }
  10690. else
  10691. {
  10692. //合并小计行
  10693. //创建合并区域的实例
  10694. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10695. rowStartIndex, // 起始行索引(0-based)
  10696. rowStartIndex, // 结束行索引(0-based)
  10697. 0, // 起始列索引(0-based)
  10698. 3 // 结束列索引(0-based)
  10699. );
  10700. sheet.AddMergedRegion(cellRangeAddress);
  10701. var CellStyle = workbook.CreateCellStyle();
  10702. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10703. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10704. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10705. for (int i = 0; i <= clounmCount; i++)
  10706. {
  10707. if (i > 6)
  10708. {
  10709. var CellStyle1 = workbook.CreateCellStyle();
  10710. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10711. IFont Font = workbook.CreateFont(); // 创建字体
  10712. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10713. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10714. CellStyle1.SetFont(Font);
  10715. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10716. }
  10717. else
  10718. {
  10719. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10720. }
  10721. }
  10722. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10723. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10724. //超时合计
  10725. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10726. //超时数
  10727. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10728. //超时合计费用
  10729. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10730. thisSid = item.SId;
  10731. cloneRowFn();
  10732. chaoshiNumber = 0;
  10733. totalNumber = 0;
  10734. }
  10735. }
  10736. IRow row = sheet.GetRow(rowStartIndex);
  10737. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10738. var isOpenOverspendSoure = overspendSoure.Keys.Contains(item.SId);
  10739. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  10740. if (isOpenOverspendSoure)
  10741. {
  10742. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10743. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  10744. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  10745. }
  10746. for (int i = 0; i <= clounmCount; i++)
  10747. {
  10748. var cell = row.GetCell(i);
  10749. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  10750. if (cell == null)
  10751. {
  10752. cell = row.CreateCell(i);
  10753. }
  10754. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  10755. fontRed.CloneStyleFrom(cell.CellStyle);
  10756. IFont Font = workbook.CreateFont(); // 创建字体
  10757. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  10758. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10759. fontRed.SetFont(Font);
  10760. byte[] rgb = new byte[3] { 255, 242, 204 };
  10761. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  10762. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  10763. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  10764. if (workbook is XSSFWorkbook)
  10765. {
  10766. BackgroundColor255_242_204.FillForegroundColor = 0;
  10767. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  10768. BackgroundColor255_242_204.FillPattern = FillPattern.SolidForeground;
  10769. }
  10770. else
  10771. {
  10772. BackgroundColor255_242_204.FillForegroundColor = (((HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  10773. }
  10774. if (i == 1 || i > 6)
  10775. {
  10776. if (i > 6)
  10777. {
  10778. fontRed.FillForegroundColor = 0;
  10779. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  10780. fontRed.FillPattern = FillPattern.SolidForeground;
  10781. }
  10782. cell.CellStyle = fontRed;
  10783. }
  10784. if (i > 2 && i < 7)
  10785. {
  10786. cell.CellStyle = BackgroundColor255_242_204;
  10787. }
  10788. cell.SetCellValue(setCellValue); //写入单元格
  10789. }
  10790. if (overspendSoure.ContainsKey(thisSid))
  10791. {
  10792. var overspendId = overspendSoure[thisSid];
  10793. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  10794. }
  10795. cloneRowFn();
  10796. existsId.Add(new CarCompare
  10797. {
  10798. DataPrice = item.DatePrice.ObjToDate(),
  10799. Sid = item.SId
  10800. });
  10801. }
  10802. if (item.Equals(lastElem))
  10803. {
  10804. //合并小计行
  10805. //创建合并区域的实例
  10806. CellRangeAddress cellRangeAddress = new CellRangeAddress(
  10807. rowStartIndex, // 起始行索引(0-based)
  10808. rowStartIndex, // 结束行索引(0-based)
  10809. 0, // 起始列索引(0-based)
  10810. 3 // 结束列索引(0-based)
  10811. );
  10812. sheet.AddMergedRegion(cellRangeAddress);
  10813. var CellStyle = workbook.CreateCellStyle();
  10814. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10815. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  10816. CellStyle.FillPattern = FillPattern.SolidForeground; // 填充方式
  10817. for (int i = 0; i <= clounmCount; i++)
  10818. {
  10819. if (i > 6)
  10820. {
  10821. var CellStyle1 = workbook.CreateCellStyle();
  10822. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  10823. IFont Font = workbook.CreateFont(); // 创建字体
  10824. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  10825. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  10826. CellStyle1.SetFont(Font);
  10827. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  10828. }
  10829. else
  10830. {
  10831. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  10832. }
  10833. }
  10834. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  10835. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  10836. //超时合计
  10837. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  10838. //超时数
  10839. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  10840. //超时合计费用
  10841. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  10842. cloneRowFn();
  10843. // 创建合并区域的实例
  10844. cellRangeAddress = new CellRangeAddress(
  10845. rowStartIndex, // 起始行索引(0-based)
  10846. rowStartIndex, // 结束行索引(0-based)
  10847. 0, // 起始列索引(0-based)
  10848. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  10849. );
  10850. // 添加合并区域
  10851. sheet.AddMergedRegion(cellRangeAddress);
  10852. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  10853. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  10854. }
  10855. }
  10856. mergeRow();
  10857. // 保存修改后的Excel文件到新文件
  10858. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  10859. // new FileStream(newFilePath, FileMode.CreateNew)
  10860. using (var stream = new MemoryStream())
  10861. {
  10862. workbook.Write(stream, true);
  10863. stream.Flush();
  10864. stream.Seek(0, SeekOrigin.Begin);
  10865. MemoryStream memoryStream = new MemoryStream();
  10866. stream.CopyTo(memoryStream);
  10867. memoryStream.Seek(0, SeekOrigin.Begin);
  10868. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  10869. }
  10870. workbook.Close();
  10871. workbook.Dispose();
  10872. }
  10873. catch (Exception ex)
  10874. {
  10875. jw.Msg = "出现异常!" + ex.Message;
  10876. return Ok(jw);
  10877. }
  10878. }
  10879. if (Zips.Count > 0)
  10880. {
  10881. IOOperatorHelper io = new IOOperatorHelper();
  10882. var byts = io.ConvertZipStream(Zips);
  10883. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  10884. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  10885. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  10886. }
  10887. else
  10888. {
  10889. jw.Msg = "暂无生成文件!";
  10890. }
  10891. return Ok(jw);
  10892. }
  10893. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  10894. {
  10895. string outStr = string.Empty;
  10896. switch (i)
  10897. {
  10898. case 0:
  10899. outStr = arr[0].SidName;
  10900. break;
  10901. case 1:
  10902. outStr = arr[0].DataPriceStr;
  10903. break;
  10904. case 2:
  10905. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  10906. break;
  10907. case 4:
  10908. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  10909. break;
  10910. case 7:
  10911. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10912. {
  10913. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  10914. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  10915. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  10916. }
  10917. break;
  10918. case 8:
  10919. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10920. {
  10921. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  10922. }
  10923. break;
  10924. case 9:
  10925. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10926. {
  10927. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  10928. }
  10929. break;
  10930. case 10:
  10931. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  10932. {
  10933. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  10934. }
  10935. break;
  10936. }
  10937. return outStr;
  10938. }
  10939. #region OP行程单
  10940. /// <summary>
  10941. /// OP行程单初始化
  10942. /// </summary>
  10943. /// <param name="dto"></param>
  10944. /// <returns></returns>
  10945. [HttpPost]
  10946. public IActionResult InitOpTravel(InitOpTravelDto dto)
  10947. {
  10948. var jw = JsonView(false);
  10949. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  10950. var group = groupList.First();
  10951. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  10952. if (group == null)
  10953. {
  10954. jw.Msg = "暂无团组!";
  10955. return Ok(jw);
  10956. }
  10957. group = groupList.Find(x => x.Id == diid);
  10958. if (group == null)
  10959. {
  10960. jw.Msg = "请输入正确的团组ID!";
  10961. return Ok(jw);
  10962. }
  10963. string city = string.Empty;
  10964. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  10965. if (blackCode.Count > 0)
  10966. {
  10967. var black = blackCode.First();
  10968. black.BlackCode = black.BlackCode == null ? "" : black.BlackCode;
  10969. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  10970. if (blackSp.Length > 0)
  10971. {
  10972. try
  10973. {
  10974. var cityArrCode = new List<string>(20);
  10975. foreach (var item in blackSp)
  10976. {
  10977. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  10978. var IndexSelect = itemSp[2];
  10979. var cityArrCodeLength = cityArrCode.Count - 1;
  10980. var startCity = IndexSelect.Substring(0, 3);
  10981. if (cityArrCodeLength > 0)
  10982. {
  10983. var arrEndCity = cityArrCode[cityArrCodeLength];
  10984. if (arrEndCity != startCity)
  10985. {
  10986. cityArrCode.Add(startCity.ToUpper());
  10987. }
  10988. }
  10989. else
  10990. {
  10991. cityArrCode.Add(startCity.ToUpper());
  10992. }
  10993. var endCity = IndexSelect.Substring(3, 3);
  10994. cityArrCode.Add(endCity.ToUpper());
  10995. }
  10996. var cityThree = string.Empty;
  10997. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  10998. cityThree = cityThree.TrimEnd(',');
  10999. if (string.IsNullOrWhiteSpace(cityThree))
  11000. {
  11001. throw new
  11002. Exception("error");
  11003. }
  11004. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  11005. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  11006. foreach (var item in cityArrCode)
  11007. {
  11008. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  11009. if (find != null)
  11010. {
  11011. city += find.City + "/";
  11012. }
  11013. else
  11014. {
  11015. city += item + "三字码未收入/";
  11016. }
  11017. }
  11018. city = city.TrimEnd('/');
  11019. }
  11020. catch (Exception e)
  11021. {
  11022. city = "黑屏代码格式不正确!";
  11023. }
  11024. }
  11025. }
  11026. else
  11027. {
  11028. city = "未录入黑屏代码";
  11029. }
  11030. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  11031. {
  11032. Date = x.Date,
  11033. Days = x.Days,
  11034. Diffgroup = x.Diffgroup,
  11035. Diid = x.Diid,
  11036. Traffic_First = x.Traffic_First,
  11037. Traffic_Second = x.Traffic_Second,
  11038. Trip = x.Trip,
  11039. WeekDay = x.WeekDay,
  11040. Id = x.Id
  11041. }).ToList();
  11042. jw.Data = new
  11043. {
  11044. groupList = groupList.Select(x => new
  11045. {
  11046. x.Id,
  11047. x.TeamName,
  11048. x.TourCode
  11049. }).ToList(),
  11050. groupInfo = new
  11051. {
  11052. group.VisitDays,
  11053. group.TourCode,
  11054. group.VisitPNumber,
  11055. group.TeamName,
  11056. city
  11057. },
  11058. OpTravelList
  11059. };
  11060. jw.Code = 200;
  11061. jw.Msg = "操作成功!";
  11062. return Ok(jw);
  11063. }
  11064. /// <summary>
  11065. /// 删除团组行程单
  11066. /// </summary>
  11067. /// <returns></returns>
  11068. [HttpPost]
  11069. public IActionResult DelTravel(DelOpTravelDto dto)
  11070. {
  11071. var jw = JsonView(false);
  11072. if (dto.UserId <= 0 || dto.Diid <= 0)
  11073. {
  11074. jw.Msg = "请输入正确的参数!";
  11075. return Ok(jw);
  11076. }
  11077. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  11078. .SetColumns(x => new Grp_TravelList
  11079. {
  11080. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11081. DeleteUserId = dto.UserId,
  11082. IsDel = 1,
  11083. }).ExecuteCommand();
  11084. jw = JsonView(true);
  11085. return Ok(jw);
  11086. }
  11087. /// <summary>
  11088. /// 行程单保存
  11089. /// </summary>
  11090. /// <returns></returns>
  11091. [HttpPost]
  11092. public IActionResult TravelSave(TravelSaveDto dto)
  11093. {
  11094. var jw = JsonView(false);
  11095. if (dto.Arr.Count > 0)
  11096. {
  11097. try
  11098. {
  11099. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  11100. .Where(x => dto.Arr.Select(x=>x.Id).Contains(x.Id))
  11101. .ToList();
  11102. _sqlSugar.BeginTran();
  11103. foreach (var item in dto.Arr)
  11104. {
  11105. if (item.Id == 0)
  11106. {
  11107. throw new Exception("请传入正确的Id");
  11108. }
  11109. //比较上一次的差异
  11110. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  11111. if (findTravel != null)
  11112. {
  11113. item.Trip = item.Trip.Replace("[++]", string.Empty);
  11114. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  11115. item.Trip = CheckStr(findTravel.Trip,item.Trip);
  11116. }
  11117. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  11118. .SetColumns(x => new Grp_TravelList
  11119. {
  11120. Trip = item.Trip
  11121. }).ExecuteCommand();
  11122. }
  11123. _sqlSugar.CommitTran();
  11124. jw = JsonView(true);
  11125. }
  11126. catch (Exception ex)
  11127. {
  11128. _sqlSugar.RollbackTran();
  11129. jw.Msg = "程序异常!" + ex.Message;
  11130. }
  11131. }
  11132. else
  11133. {
  11134. jw.Msg = "请传入正确的参数!";
  11135. }
  11136. return Ok(jw);
  11137. }
  11138. private string CheckStr(string original, string changed)
  11139. {
  11140. // 创建diff_match_patch对象
  11141. var dmp = new diff_match_patch();
  11142. // 计算差异
  11143. List<Diff> diffs = dmp.diff_main(original, changed);
  11144. // 清理和合并差异
  11145. dmp.diff_cleanupSemantic(diffs);
  11146. // 使用StringBuilder构建最终的字符串
  11147. StringBuilder finalString = new StringBuilder();
  11148. // 输出差异结果,并构建变动后的字符串
  11149. foreach (Diff diff in diffs)
  11150. {
  11151. switch (diff.operation)
  11152. {
  11153. case Operation.EQUAL:
  11154. // 相等的部分,直接添加到最终字符串
  11155. finalString.Append(diff.text);
  11156. break;
  11157. case Operation.INSERT:
  11158. // 插入的部分,添加标记并添加到最终字符串
  11159. finalString.Append("[++]" + diff.text + "[++]");
  11160. break;
  11161. case Operation.DELETE:
  11162. // 删除的部分,不添加到最终字符串
  11163. //finalString.Append("[++]" + diff.text + "[++]");
  11164. break;
  11165. }
  11166. }
  11167. // 输出变动后的字符串
  11168. return finalString.ToString();
  11169. }
  11170. private class tagContent
  11171. {
  11172. public DateTime Date { get; set; }
  11173. public string StartTag { get; set; }
  11174. public string EndTag { get; set; }
  11175. public string Content { get; set; }
  11176. public static int tagLength { get { return 3; } }
  11177. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  11178. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  11179. public bool IsFinally { get; set; }
  11180. }
  11181. private List<string> ExtractContentBetweenTags(string input, string tag)
  11182. {
  11183. List<string> results = new List<string>();
  11184. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  11185. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  11186. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  11187. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  11188. string[] strValueArr = new string[1];
  11189. foreach (Match match in matches)
  11190. {
  11191. var strValue = match.Groups[1].Value;
  11192. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  11193. }
  11194. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  11195. return results;
  11196. }
  11197. /// <summary>
  11198. /// 导出行程单
  11199. /// </summary>
  11200. /// <param name="dto"></param>
  11201. /// <returns></returns>
  11202. [HttpPost]
  11203. public IActionResult ExportTravel(ExportTravelDto dto)
  11204. {
  11205. var jw = JsonView(false);
  11206. jw.Data = "";
  11207. int diid = 0;
  11208. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  11209. if (Find == null)
  11210. {
  11211. jw.Msg = "请选择正确的团组!";
  11212. return Ok(jw);
  11213. }
  11214. else
  11215. {
  11216. diid = Find.Id;
  11217. }
  11218. //数据源
  11219. List<Grp_TravelList> _travelList = new List<Grp_TravelList>();
  11220. DataTable dtBlack = null;
  11221. try
  11222. {
  11223. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  11224. }
  11225. catch (Exception)
  11226. {
  11227. jw.Msg = "机票黑屏代码有误!";
  11228. return Ok(jw);
  11229. }
  11230. string CityStr = string.Empty;
  11231. if (dtBlack.Rows.Count == 0)
  11232. {
  11233. jw.Msg = "机票黑屏代码有误!";
  11234. return Ok(jw);
  11235. }
  11236. else
  11237. {
  11238. foreach (DataRow row in dtBlack.Rows)
  11239. {
  11240. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  11241. {
  11242. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  11243. return Ok(jw);
  11244. }
  11245. }
  11246. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  11247. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  11248. }
  11249. // 指定的文字
  11250. var targetTextDic = new Dictionary<string, List<string>>();
  11251. //创建数据源Table
  11252. DataTable dtSource = new DataTable();
  11253. dtSource.Columns.Add("Days", typeof(string));
  11254. dtSource.Columns.Add("Date", typeof(string));
  11255. dtSource.Columns.Add("Week", typeof(string));
  11256. dtSource.Columns.Add("Traffic", typeof(string));
  11257. dtSource.Columns.Add("Trip", typeof(string));
  11258. //获取数据,放到datatable
  11259. foreach (var item in _travelList)
  11260. {
  11261. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  11262. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  11263. .Replace(tagContent.TagFormat.Item2, string.Empty)
  11264. .Replace("[++]", string.Empty);
  11265. DataRow dr = dtSource.NewRow();
  11266. dr["Days"] = item.Days;
  11267. dr["Date"] = item.Date;
  11268. dr["Week"] = item.WeekDay;
  11269. dr["Traffic"] = item.Traffic_First
  11270. + "\r\n"
  11271. + item.Traffic_Second;
  11272. dr["Trip"] = item.Trip;
  11273. dtSource.Rows.Add(dr);
  11274. }
  11275. Dictionary<string, string> dic = new Dictionary<string, string>();
  11276. dic.Add("Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()));
  11277. dic.Add("City", CityStr);
  11278. dic.Add("Days", Find.VisitDays.ToString());
  11279. dic.Add("DeleCode", Find.TourCode);
  11280. dic.Add("Pnum", Find.VisitPNumber.ToString());
  11281. //模板路径
  11282. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  11283. //载入模板
  11284. Document doc = null;
  11285. DocumentBuilder builder = null;
  11286. try
  11287. {
  11288. //载入模板
  11289. doc = new Document(tempPath);
  11290. builder = new DocumentBuilder(doc);
  11291. }
  11292. catch (Exception)
  11293. {
  11294. jw.Msg = "模板位置不存在!";
  11295. return Ok(jw);
  11296. }
  11297. foreach (var key in dic.Keys)
  11298. {
  11299. Bookmark bookmark = doc.Range.Bookmarks[key];
  11300. if (bookmark != null)
  11301. {
  11302. builder.MoveToBookmark(key);
  11303. builder.Write(dic[key]);
  11304. }
  11305. }
  11306. //获取word里所有表格
  11307. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11308. //获取所填表格的序数
  11309. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  11310. try
  11311. {
  11312. //循环赋值
  11313. for (int i = 0; i < dtSource.Rows.Count; i++)
  11314. {
  11315. builder.MoveToCell(0, i + 1, 0, 0);
  11316. builder.Write(dtSource.Rows[i]["Days"].ToString());
  11317. builder.MoveToCell(0, i + 1, 1, 0);
  11318. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  11319. builder.MoveToCell(0, i + 1, 2, 0);
  11320. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  11321. var trip = dtSource.Rows[i]["Trip"].ToString();
  11322. builder.MoveToCell(0, i + 1, 3, 0);
  11323. builder.Write(trip);
  11324. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  11325. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11326. // 获取特定索引的段落
  11327. Paragraph paragraph = (Paragraph)paragraphs[0];
  11328. Run run = paragraph.Runs[0];
  11329. Aspose.Words.Font font = run.Font;
  11330. font.Name = "黑体";
  11331. //设置双休红色
  11332. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  11333. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  11334. paragraph = (Paragraph)paragraphs[1];
  11335. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  11336. {
  11337. run = paragraph.Runs[0];
  11338. font = run.Font;
  11339. font.Color = Color.Red;
  11340. }
  11341. }
  11342. }
  11343. catch (Exception ex)
  11344. {
  11345. }
  11346. //删除多余行
  11347. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  11348. {
  11349. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  11350. }
  11351. var targetTextList = new List<string>();
  11352. // 遍历文档中的表格
  11353. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  11354. {
  11355. foreach (Aspose.Words.Tables.Row row in table.Rows)
  11356. {
  11357. var cellIndex = 0;
  11358. foreach (Cell cell in row.Cells)
  11359. {
  11360. if (cellIndex == 1 && row.Cells.Count == 4)
  11361. {
  11362. foreach (var target in targetTextDic.Keys)
  11363. {
  11364. if (cell.GetText().Contains(target))
  11365. {
  11366. targetTextList = targetTextDic[target];
  11367. break;
  11368. }
  11369. }
  11370. }
  11371. // 遍历单元格中的所有段落
  11372. foreach (Paragraph paragraph in cell.Paragraphs)
  11373. {
  11374. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  11375. List<Run> runs = new List<Run>();
  11376. foreach (Run run in paragraph.Runs)
  11377. {
  11378. runs.Add(run);
  11379. }
  11380. foreach (Run run in runs)
  11381. {
  11382. foreach (var targetText in targetTextList)
  11383. {
  11384. // 检查文字是否包含指定文字
  11385. if (run.Text.Contains(targetText))
  11386. {
  11387. // 将包含的部分设置为红色
  11388. HighlightText(run, targetText, Color.Red);
  11389. }
  11390. }
  11391. }
  11392. }
  11393. cellIndex++;
  11394. }
  11395. }
  11396. }
  11397. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  11398. if (!Directory.Exists(savePath))
  11399. {
  11400. try
  11401. {
  11402. Directory.CreateDirectory(savePath);
  11403. }
  11404. catch
  11405. {
  11406. }
  11407. }
  11408. string path = savePath + Find.TeamName + "出访日程";
  11409. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  11410. try
  11411. {
  11412. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  11413. string postfix = ".docx";
  11414. if (dto.IsPDF == 1)
  11415. {
  11416. saveFormat = Aspose.Words.SaveFormat.Pdf;
  11417. postfix = ".pdf";
  11418. }
  11419. doc.Save(path + postfix, saveFormat);
  11420. jw = JsonView(true, "导出成功", ftpPath + postfix);
  11421. }
  11422. catch (Exception)
  11423. {
  11424. jw = JsonView(false);
  11425. }
  11426. return Ok(jw);
  11427. }
  11428. /// <summary>
  11429. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  11430. /// </summary>
  11431. /// <param name="num"></param>
  11432. /// <returns></returns>
  11433. string GetNum(string num)
  11434. {
  11435. string str = "";
  11436. switch (num)
  11437. {
  11438. case "1":
  11439. str = "一";
  11440. break;
  11441. case "2":
  11442. str = "二";
  11443. break;
  11444. case "3":
  11445. str = "三";
  11446. break;
  11447. case "4":
  11448. str = "四";
  11449. break;
  11450. case "5":
  11451. str = "五";
  11452. break;
  11453. case "6":
  11454. str = "六";
  11455. break;
  11456. case "7":
  11457. str = "七";
  11458. break;
  11459. case "8":
  11460. str = "八";
  11461. break;
  11462. case "9":
  11463. str = "九";
  11464. break;
  11465. case "10":
  11466. str = "十";
  11467. break;
  11468. case "11":
  11469. str = "十一";
  11470. break;
  11471. case "12":
  11472. str = "十二";
  11473. break;
  11474. case "一":
  11475. str = "1";
  11476. break;
  11477. case "二":
  11478. str = "2";
  11479. break;
  11480. case "三":
  11481. str = "3";
  11482. break;
  11483. case "四":
  11484. str = "4";
  11485. break;
  11486. case "五":
  11487. str = "5";
  11488. break;
  11489. case "六":
  11490. str = "6";
  11491. break;
  11492. case "七":
  11493. str = "7";
  11494. break;
  11495. case "八":
  11496. str = "8";
  11497. break;
  11498. case "九":
  11499. str = "9";
  11500. break;
  11501. case "十":
  11502. str = "10";
  11503. break;
  11504. case "十一":
  11505. str = "11";
  11506. break;
  11507. case "十二":
  11508. str = "12";
  11509. break;
  11510. }
  11511. return str;
  11512. }
  11513. // 高亮包含指定文字的部分
  11514. void HighlightText(Run run, string targetText, Color color)
  11515. {
  11516. string text = run.Text;
  11517. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  11518. if (startIndex >= 0)
  11519. {
  11520. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  11521. // 前部分
  11522. if (startIndex > 0)
  11523. {
  11524. Run beforeRun = (Run)run.Clone(true);
  11525. beforeRun.Text = text.Substring(0, startIndex);
  11526. parentParagraph.InsertBefore(beforeRun, run);
  11527. }
  11528. // 匹配部分
  11529. Run matchRun = (Run)run.Clone(true);
  11530. matchRun.Text = text.Substring(startIndex, targetText.Length);
  11531. matchRun.Font.Color = color;
  11532. parentParagraph.InsertBefore(matchRun, run);
  11533. // 后部分
  11534. if (startIndex + targetText.Length < text.Length)
  11535. {
  11536. Run afterRun = (Run)run.Clone(true);
  11537. afterRun.Text = text.Substring(startIndex + targetText.Length);
  11538. parentParagraph.InsertBefore(afterRun, run);
  11539. }
  11540. // 删除原始Run
  11541. run.Remove();
  11542. }
  11543. }
  11544. #endregion
  11545. #endregion
  11546. #region 团组成本
  11547. /// <summary>
  11548. /// 团组成本数据初始化
  11549. /// </summary>
  11550. /// <param name="dto"></param>
  11551. /// <returns></returns>
  11552. [HttpPost]
  11553. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  11554. {
  11555. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  11556. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  11557. WHEN COUNT(*) >= 0 THEN 'True'
  11558. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  11559. Where TeamName != '' And IsDel = 0 Order By a.Id Desc
  11560. ").ToList(); //团组列表
  11561. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  11562. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  11563. List<Res_CountryFeeCost> visaCountryInfoArr = new List<Res_CountryFeeCost>();
  11564. var groupinfoValue = (groupInfo.Data as Web_ShareGroupInfoView);
  11565. if (groupinfoValue != null)
  11566. {
  11567. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  11568. var spArr = new string[1] { countryArr };
  11569. if (countryArr.Contains("|"))
  11570. {
  11571. spArr = countryArr.Split("|");
  11572. }
  11573. else if (countryArr.Contains("、"))
  11574. {
  11575. spArr = countryArr.Split("、");
  11576. }
  11577. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  11578. {
  11579. var dbQueryCountry = _sqlSugar.Queryable<Res_CountryFeeCost>().First(x => x.VisaCountry.Contains(item));
  11580. if (dbQueryCountry != null)
  11581. {
  11582. visaCountryInfoArr.Add(dbQueryCountry);
  11583. }
  11584. }
  11585. }
  11586. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  11587. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  11588. var create = _GroupCostRepository.
  11589. CreateGroupCostByBlackCode(dto.Diid);
  11590. if (groupCost.Count == 0 && create.Code == 0)
  11591. {
  11592. groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  11593. }
  11594. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  11595. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  11596. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  11597. groupCostMap = groupCostMap.Select(x =>
  11598. {
  11599. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  11600. {
  11601. x.Date = dataForamt.ToString("yyyy-MM-dd");
  11602. }
  11603. return x;
  11604. }).ToList();
  11605. //GroupCostParameter.Add(new
  11606. // Grp_GroupCostParameter());
  11607. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  11608. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).Count() > 0;
  11609. return Ok(JsonView(new
  11610. {
  11611. groupList,
  11612. groupInfo,
  11613. groupChecks,
  11614. groupCost = groupCostMap,
  11615. hotelNumber,
  11616. GroupCostParameter = GroupCostParameterMap,
  11617. visaCountryInfoArr = visaCountryInfoArr.Select(x => new
  11618. {
  11619. x.VisaCountry,
  11620. x.VisaPrice,
  11621. x.Id,
  11622. }).ToList(),
  11623. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  11624. blackCodeIsTrue = create.Code == 0 ? true : false,
  11625. hotelIsTrue = hotelIsTrue,
  11626. }));
  11627. }
  11628. /// <summary>
  11629. /// 团组成本信息保存
  11630. /// </summary>
  11631. /// <param name="dto"></param>
  11632. /// <returns></returns>
  11633. [HttpPost]
  11634. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  11635. {
  11636. if (dto.Diid <= 0 || dto.Userid <= 0)
  11637. {
  11638. return Ok(JsonView(false));
  11639. }
  11640. JsonView jw = null;
  11641. bool isTrue = false;
  11642. #region 复制团组成本
  11643. //if (dto.Diid == 2581)
  11644. //{
  11645. // dto.Diid = 2599;
  11646. // dto.CheckBoxs.ForEach(x =>
  11647. // {
  11648. // x.Diid = 2599;
  11649. // });
  11650. // dto.GroupCosts.ForEach(x =>
  11651. // {
  11652. // x.Diid = 2599;
  11653. // });
  11654. // dto.CostTypeHotelNumbers.ForEach(x =>
  11655. // {
  11656. // x.Diid = 2599;
  11657. // });
  11658. // dto.GroupCostParameters.ForEach(x =>
  11659. // {
  11660. // x.DiId = 2599;
  11661. // });
  11662. //}
  11663. #endregion
  11664. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  11665. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  11666. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  11667. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  11668. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  11669. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  11670. try
  11671. {
  11672. _sqlSugar.BeginTran();
  11673. isTrue = await _GroupCostRepository.
  11674. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  11675. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  11676. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  11677. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  11678. _sqlSugar.CommitTran();
  11679. jw = JsonView(true, "保存成功!", isTrue);
  11680. }
  11681. catch (Exception)
  11682. {
  11683. _sqlSugar.RollbackTran();
  11684. jw = JsonView(false);
  11685. }
  11686. return Ok(jw);
  11687. }
  11688. /// <summary>
  11689. /// 司兼导数据
  11690. /// </summary>
  11691. /// <param name="dto"></param>
  11692. /// <returns></returns>
  11693. [HttpPost]
  11694. public IActionResult GetCarGuides(CarGuidesDto dto)
  11695. {
  11696. JsonView jw = null;
  11697. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  11698. jw = JsonView(true, "获取成功!", Data);
  11699. return Ok(jw);
  11700. }
  11701. /// <summary>
  11702. /// 导游数据
  11703. /// </summary>
  11704. /// <param name="dto"></param>
  11705. /// <returns></returns>
  11706. [HttpPost]
  11707. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  11708. {
  11709. JsonView jw = null;
  11710. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  11711. // 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
  11712. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  11713. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  11714. jw = JsonView(true, "获取成功!", Data);
  11715. return Ok(jw);
  11716. }
  11717. /// <summary>
  11718. /// 成本车数据
  11719. /// </summary>
  11720. /// <param name="dto"></param>
  11721. /// <returns></returns>
  11722. [HttpPost]
  11723. public IActionResult GetCarInfo(CarGuidesDto dto)
  11724. {
  11725. JsonView jw = null;
  11726. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  11727. jw = JsonView(true, "获取成功!", Data);
  11728. return Ok(jw);
  11729. }
  11730. /// <summary>
  11731. /// 景点数据
  11732. /// </summary>
  11733. /// <param name="dto"></param>
  11734. /// <returns></returns>
  11735. [HttpPost]
  11736. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  11737. {
  11738. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  11739. return Ok(JsonView(true, "获取成功!", Data));
  11740. }
  11741. /// <summary>
  11742. /// 成本通知
  11743. /// </summary>
  11744. /// <param name="dto"></param>
  11745. /// <returns></returns>
  11746. [HttpPost]
  11747. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  11748. {
  11749. if (dto.Diid < 0)
  11750. {
  11751. return Ok(JsonView(false));
  11752. }
  11753. JsonView jw = null;
  11754. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  11755. if (GroupCostParameter != null)
  11756. {
  11757. int IsShare = 0;
  11758. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  11759. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  11760. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  11761. string msg = string.Empty;
  11762. if (isTrue)
  11763. {
  11764. if (IsShare == 0)
  11765. {
  11766. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  11767. }
  11768. else
  11769. {
  11770. #region 企微通知对应岗位用户
  11771. try
  11772. {
  11773. AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  11774. }
  11775. catch (Exception ex)
  11776. {
  11777. }
  11778. #endregion
  11779. msg = "通知成功,其他模块操作人员可见此成本信息!";
  11780. }
  11781. jw = JsonView(isTrue, msg, new { IsShare });
  11782. }
  11783. else
  11784. {
  11785. msg = "修改失败!";
  11786. jw = JsonView(isTrue, msg);
  11787. }
  11788. }
  11789. else
  11790. {
  11791. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  11792. }
  11793. return Ok(jw);
  11794. }
  11795. /// <summary>
  11796. /// 导出报价单
  11797. /// </summary>
  11798. /// <param name="dto"></param>
  11799. /// <returns></returns>
  11800. [HttpPost]
  11801. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  11802. {
  11803. if (dto.Diid == 0)
  11804. {
  11805. return Ok(JsonView(false, "请传递团组id"));
  11806. }
  11807. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11808. if (deleInfo.Code != 0)
  11809. {
  11810. return Ok(JsonView(false, "团组信息查询失败!"));
  11811. }
  11812. var di = deleInfo.Data as DelegationInfoWebView;
  11813. if (di != null)
  11814. {
  11815. di.TeamName = di.TeamName.Replace("|", "、");
  11816. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  11817. //文件名
  11818. string strFileName = di.TeamName + "-收款账单.doc";
  11819. //获取模板
  11820. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  11821. //载入模板
  11822. Document doc = new Document(tmppath);
  11823. decimal TotalPrice = 0.00M;
  11824. string itemStr = string.Empty;
  11825. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  11826. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11827. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  11828. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  11829. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  11830. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  11831. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  11832. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  11833. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  11834. foreach (var cost in groupCostType)
  11835. {
  11836. var List = cost.ToList();
  11837. if (cost.Key == "A")
  11838. {
  11839. foreach (var ListItem in List)
  11840. {
  11841. if (ListItem.number > 0)
  11842. {
  11843. if (ListItem.code.Contains("TBR"))
  11844. {
  11845. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11846. }
  11847. else
  11848. {
  11849. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11850. }
  11851. TotalPrice += (ListItem.number * ListItem.price);
  11852. }
  11853. }
  11854. }
  11855. else
  11856. {
  11857. itemStr = itemStr.Insert(0, "A段\r\n");
  11858. itemStr += "B段\r\n";
  11859. foreach (var ListItem in List)
  11860. {
  11861. if (ListItem.number > 0)
  11862. {
  11863. if (ListItem.code.Contains("TBR"))
  11864. {
  11865. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11866. }
  11867. else
  11868. {
  11869. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  11870. }
  11871. TotalPrice += (ListItem.number * ListItem.price);
  11872. }
  11873. }
  11874. }
  11875. }
  11876. #region 替换Word模板书签内容
  11877. Dictionary<string, string> marks = new Dictionary<string, string>();
  11878. marks.Add("To", di.ClientUnit);//付款方
  11879. marks.Add("ToTel", di.TellPhone);//付款方电话
  11880. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  11881. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  11882. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  11883. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  11884. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  11885. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  11886. marks.Add("PayItemContent", itemStr);//详细信息
  11887. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  11888. #endregion
  11889. ////注
  11890. //if (doc.Range.Bookmarks["Attention"] != null)
  11891. //{
  11892. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  11893. // mark.Text = frList[0].Attention;
  11894. //}
  11895. foreach (var item in marks.Keys)
  11896. {
  11897. if (doc.Range.Bookmarks[item] != null)
  11898. {
  11899. Bookmark mark = doc.Range.Bookmarks[item];
  11900. mark.Text = marks[item];
  11901. }
  11902. }
  11903. byte[] bytes = null;
  11904. using (MemoryStream stream = new MemoryStream())
  11905. {
  11906. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  11907. bytes = stream.ToArray();
  11908. }
  11909. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  11910. return Ok(JsonView(true, "", new
  11911. {
  11912. Data = bytes,
  11913. strFileName,
  11914. }));
  11915. }
  11916. else
  11917. {
  11918. return Ok(JsonView(false, "团组信息不存在!"));
  11919. }
  11920. }
  11921. /// <summary>
  11922. /// 导出团组成本
  11923. /// </summary>
  11924. /// <param name="dto"></param>
  11925. /// <returns></returns>
  11926. [HttpPost]
  11927. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  11928. {
  11929. var jw = JsonView(false);
  11930. if (dto.Diid == 0)
  11931. {
  11932. return Ok(JsonView(false, "请传递团组id"));
  11933. }
  11934. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  11935. if (deleInfo.Code != 0)
  11936. {
  11937. return Ok(JsonView(false, "团组信息查询失败!"));
  11938. }
  11939. var di = deleInfo.Data as DelegationInfoWebView;
  11940. if (di == null)
  11941. {
  11942. return Ok(JsonView(false, "团组信息查询失败!"));
  11943. }
  11944. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  11945. WorkbookDesigner designer = new WorkbookDesigner();
  11946. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  11947. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  11948. for (int i = 0; i < List_GC.Count; i++)
  11949. {
  11950. GroupCost_Excel gc = new GroupCost_Excel();
  11951. gc.Id = List_GC[i].Id;
  11952. gc.Diid = List_GC[i].Diid.ToString();
  11953. gc.DAY = List_GC[i].DAY;
  11954. string week = "";
  11955. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  11956. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  11957. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  11958. gc.ITIN = List_GC[i].ITIN;
  11959. gc.CarType = List_GC[i].CarType;
  11960. gc.CarTiming = List_GC[i].CarTiming.ToString() == "0" ? "/" : List_GC[i].CarTiming.ToString();
  11961. gc.CarCost = List_GC[i].CarCost.ToString() == "0" ? "/" : List_GC[i].CarCost.ToString();
  11962. gc.CarNumber = List_GC[i].CarNumber.ToString() == "0" ? "/" : List_GC[i].CarNumber.ToString();
  11963. gc.TGS = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGS.ToString();
  11964. gc.TGWH = List_GC[i].TGWH.ToString() == "0" ? "/" : List_GC[i].TGWH.ToString();
  11965. gc.TGN = List_GC[i].TGS.ToString() == "0" ? "/" : List_GC[i].TGN.ToString();
  11966. gc.TGOF = List_GC[i].TGOF.ToString() == "0" ? "/" : List_GC[i].TGOF.ToString();
  11967. gc.TGM = List_GC[i].TGM.ToString() == "0" ? "/" : List_GC[i].TGM.ToString();
  11968. gc.TGA = List_GC[i].TGA.ToString() == "0" ? "/" : List_GC[i].TGA.ToString();
  11969. gc.TGTF = List_GC[i].TGTF.ToString() == "0" ? "/" : List_GC[i].TGTF.ToString();
  11970. gc.TGEF = List_GC[i].TGEF.ToString() == "0" ? "/" : List_GC[i].TGEF.ToString();
  11971. gc.CFS = List_GC[i].CFS.ToString() == "0" ? "/" : List_GC[i].CFS.ToString();
  11972. gc.CFM = List_GC[i].CFM.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  11973. gc.CFOF = List_GC[i].CFOF.ToString() == "0" ? "/" : List_GC[i].CFOF.ToString();
  11974. gc.B = List_GC[i].B.ToString() == "0" ? "/" : List_GC[i].B.ToString();
  11975. gc.L = List_GC[i].L.ToString() == "0" ? "/" : List_GC[i].L.ToString();
  11976. gc.D = List_GC[i].D.ToString() == "0" ? "/" : List_GC[i].D.ToString();
  11977. gc.TBR = List_GC[i].TBR.ToString() == "0" ? "/" : List_GC[i].TBR.ToString();
  11978. gc.SGR = List_GC[i].SGR.ToString() == "0" ? "/" : List_GC[i].SGR.ToString();
  11979. gc.JS_ES = List_GC[i].JS_ES.ToString() == "0" ? "/" : List_GC[i].JS_ES.ToString();
  11980. gc.Suite = List_GC[i].Suite.ToString() == "0" ? "/" : List_GC[i].Suite.ToString();
  11981. gc.ACCON = List_GC[i].ACCON.ToString() == "0" ? "/" : List_GC[i].ACCON.ToString();
  11982. gc.TV = List_GC[i].TV.ToString() == "0" ? "/" : List_GC[i].TV.ToString();
  11983. gc.iL = List_GC[i].iL.ToString() == "0" ? "/" : List_GC[i].iL.ToString();
  11984. gc.IF = List_GC[i].IF.ToString() == "0" ? "/" : List_GC[i].IF.ToString();
  11985. gc.EF = List_GC[i].EF.ToString() == "0" ? "/" : List_GC[i].EF.ToString();
  11986. gc.B_R_F = List_GC[i].B_R_F.ToString() == "0" ? "/" : List_GC[i].B_R_F.ToString();
  11987. gc.TE = List_GC[i].TE.ToString() == "0" ? "/" : List_GC[i].TE.ToString();
  11988. gc.TGTips = List_GC[i].TGTips.ToString() == "0" ? "/" : List_GC[i].TGTips.ToString();
  11989. gc.DRVTips = List_GC[i].DRVTips.ToString() == "0" ? "/" : List_GC[i].DRVTips.ToString();
  11990. gc.PC = List_GC[i].PC.ToString() == "0" ? "/" : List_GC[i].PC.ToString();
  11991. gc.TLF = List_GC[i].TLF.ToString() == "0" ? "/" : List_GC[i].TLF.ToString();
  11992. gc.ECT = List_GC[i].ECT.ToString() == "0" ? "/" : List_GC[i].ECT.ToString();
  11993. List_GC1.Add(gc);
  11994. }
  11995. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  11996. dt.TableName = "TB";
  11997. //报表标题等不用dt的值
  11998. designer.SetDataSource("TeamName", dto.title.TeamName);
  11999. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  12000. designer.SetDataSource("Tax", dto.title.Tax);
  12001. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  12002. designer.SetDataSource("Currency", dto.title.Currency);
  12003. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  12004. designer.SetDataSource("Rate", dto.title.Rate);
  12005. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  12006. var Aparams = hotels.Find(x => x.Type == "Default");
  12007. if (Aparams == null)
  12008. {
  12009. return Ok(jw);
  12010. }
  12011. //酒店数量
  12012. var txtSGRNumber = Aparams.SGR.ToString();
  12013. var txtTBRNumber = Aparams.TBR.ToString();
  12014. var txtJSESNumber = Aparams.JSES.ToString();
  12015. var txtSUITENumbe = Aparams.SUITE.ToString();
  12016. if (dto.costType == "B")
  12017. {
  12018. Aparams = hotels.Find(x => x.Type == "A");
  12019. var Bparams = hotels.Find(x => x.Type == "B");
  12020. if (Aparams == null || Bparams == null)
  12021. {
  12022. return Ok(jw);
  12023. }
  12024. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  12025. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  12026. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  12027. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  12028. }
  12029. designer.SetDataSource("SGRNumber", txtSGRNumber);
  12030. designer.SetDataSource("TBRNumber", txtTBRNumber);
  12031. designer.SetDataSource("JSESNumber", txtJSESNumber);
  12032. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  12033. var ws = designer.Workbook.Worksheets[0];
  12034. int Row = List_GC.Count;
  12035. int startIndex = 11;
  12036. int HideRows = 0;
  12037. List<int> hideRowsList = new List<int>();
  12038. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  12039. #region A段left数据
  12040. var left = dto.leftInfo.Find(x => x.Type == "A");
  12041. if (left == null)
  12042. {
  12043. return Ok(jw);
  12044. }
  12045. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  12046. if (leftBindData != null)
  12047. {
  12048. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  12049. designer.SetDataSource("VisaRS", leftBindData.rs);
  12050. designer.SetDataSource("VisaXS", leftBindData.xs);
  12051. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12052. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12053. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12054. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12055. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12056. }
  12057. else
  12058. {
  12059. hideRowsList.Add(Row + startIndex + HideRows);
  12060. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12061. }
  12062. HideRows += 2;
  12063. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  12064. if (leftBindData != null)
  12065. {
  12066. designer.SetDataSource("BXDRCB", leftBindData.cb);
  12067. designer.SetDataSource("BXRS", leftBindData.rs);
  12068. designer.SetDataSource("BXXS", leftBindData.xs);
  12069. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12070. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12071. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12072. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12073. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12074. }
  12075. else
  12076. {
  12077. hideRowsList.Add(Row + startIndex + HideRows);
  12078. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12079. }
  12080. HideRows += 2;
  12081. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12082. if (leftBindData != null)
  12083. {
  12084. designer.SetDataSource("HSDRCB", leftBindData.cb);
  12085. designer.SetDataSource("HSRS", leftBindData.rs);
  12086. designer.SetDataSource("HSXS", leftBindData.xs);
  12087. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12088. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12089. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12090. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12091. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12092. }
  12093. else
  12094. {
  12095. hideRowsList.Add(Row + startIndex + HideRows);
  12096. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12097. }
  12098. HideRows += 2;
  12099. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12100. if (leftBindData != null)
  12101. {
  12102. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  12103. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  12104. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  12105. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12106. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12107. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12108. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12109. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12110. }
  12111. else
  12112. {
  12113. hideRowsList.Add(Row + startIndex + HideRows);
  12114. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12115. }
  12116. HideRows += 2;
  12117. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12118. if (leftBindData != null)
  12119. {
  12120. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  12121. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  12122. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  12123. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12124. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12125. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12126. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12127. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12128. }
  12129. else
  12130. {
  12131. hideRowsList.Add(Row + startIndex + HideRows);
  12132. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12133. }
  12134. HideRows += 2;
  12135. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12136. if (leftBindData != null)
  12137. {
  12138. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  12139. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  12140. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  12141. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12142. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12143. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12144. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12145. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12146. }
  12147. else
  12148. {
  12149. hideRowsList.Add(Row + startIndex + HideRows);
  12150. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12151. }
  12152. HideRows += 2;
  12153. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12154. if (leftBindData != null)
  12155. {
  12156. ////TBR
  12157. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  12158. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  12159. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  12160. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12161. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12162. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12163. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12164. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12165. }
  12166. else
  12167. {
  12168. hideRowsList.Add(Row + startIndex + HideRows);
  12169. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12170. }
  12171. HideRows += 2;
  12172. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12173. if (leftBindData != null)
  12174. {
  12175. ////SGR
  12176. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  12177. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  12178. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  12179. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12180. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12181. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12182. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12183. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12184. }
  12185. else
  12186. {
  12187. hideRowsList.Add(Row + startIndex + HideRows);
  12188. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12189. }
  12190. HideRows += 2;
  12191. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12192. if (leftBindData != null)
  12193. {
  12194. ////JS/ES
  12195. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  12196. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  12197. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  12198. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12199. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12200. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12201. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12202. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12203. }
  12204. else
  12205. {
  12206. hideRowsList.Add(Row + startIndex + HideRows);
  12207. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12208. }
  12209. HideRows += 2;
  12210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12211. if (leftBindData != null)
  12212. {
  12213. ////SUITE
  12214. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  12215. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  12216. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  12217. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12218. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12219. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12220. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12221. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12222. }
  12223. else
  12224. {
  12225. hideRowsList.Add(Row + startIndex + HideRows);
  12226. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12227. }
  12228. HideRows += 2;
  12229. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  12230. if (leftBindData != null)
  12231. {
  12232. designer.SetDataSource("DJDRCB", leftBindData.cb);
  12233. designer.SetDataSource("DJRS", leftBindData.rs);
  12234. designer.SetDataSource("DJXS", leftBindData.xs);
  12235. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12236. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12237. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12238. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12239. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12240. }
  12241. else
  12242. {
  12243. hideRowsList.Add(Row + startIndex + HideRows);
  12244. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12245. }
  12246. HideRows += 2;
  12247. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12248. if (leftBindData != null)
  12249. {
  12250. designer.SetDataSource("HCPCB", leftBindData.cb);
  12251. designer.SetDataSource("HCPRS", leftBindData.rs);
  12252. designer.SetDataSource("HCPXS", leftBindData.xs);
  12253. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12254. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12255. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12256. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12257. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12258. }
  12259. else
  12260. {
  12261. hideRowsList.Add(Row + startIndex + HideRows);
  12262. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12263. }
  12264. HideRows += 2;
  12265. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12266. if (leftBindData != null)
  12267. {
  12268. designer.SetDataSource("CPCB", leftBindData.cb);
  12269. designer.SetDataSource("CPRS", leftBindData.rs);
  12270. designer.SetDataSource("CPXS", leftBindData.xs);
  12271. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12272. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12273. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12274. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12275. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12276. }
  12277. else
  12278. {
  12279. hideRowsList.Add(Row + startIndex + HideRows);
  12280. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12281. }
  12282. HideRows += 2;
  12283. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12284. if (leftBindData != null)
  12285. {
  12286. designer.SetDataSource("GWDRCD", leftBindData.cb);
  12287. designer.SetDataSource("GWRS", leftBindData.rs);
  12288. designer.SetDataSource("GWXS", leftBindData.xs);
  12289. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12290. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12291. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12292. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12293. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12294. }
  12295. else
  12296. {
  12297. hideRowsList.Add(Row + startIndex + HideRows);
  12298. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12299. }
  12300. HideRows += 2;
  12301. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12302. if (leftBindData != null)
  12303. {
  12304. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  12305. designer.SetDataSource("LYJRS", leftBindData.rs);
  12306. designer.SetDataSource("LYJXS", leftBindData.xs);
  12307. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12308. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12309. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12310. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12311. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12312. }
  12313. else
  12314. {
  12315. hideRowsList.Add(Row + startIndex + HideRows);
  12316. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  12317. }
  12318. #endregion
  12319. #region A段Right信息
  12320. var right = dto.rightInfo.Find(x => x.Type == "A");
  12321. if (right == null)
  12322. {
  12323. return Ok(jw);
  12324. }
  12325. HideRows += 4;
  12326. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12327. if (rightBindData != null)
  12328. {
  12329. //经济舱 + 双人间 TBR
  12330. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  12331. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  12332. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12333. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  12334. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12335. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12336. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12337. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12338. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12339. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12340. }
  12341. else
  12342. {
  12343. hideRowsList.Add(Row + startIndex + HideRows);
  12344. }
  12345. HideRows += 2;
  12346. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12347. if (rightBindData != null)
  12348. {
  12349. //经济舱 + 单人间 SGR
  12350. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  12351. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  12352. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12353. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  12354. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12355. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12356. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12357. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12358. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12359. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12360. }
  12361. else
  12362. {
  12363. hideRowsList.Add(Row + startIndex + HideRows);
  12364. }
  12365. HideRows += 2;
  12366. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12367. if (rightBindData != null)
  12368. {
  12369. //公务舱 + 单人间 SGR
  12370. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  12371. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  12372. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12373. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  12374. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12375. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12376. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12377. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12378. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12379. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12380. }
  12381. else
  12382. {
  12383. hideRowsList.Add(Row + startIndex + HideRows);
  12384. }
  12385. HideRows += 2;
  12386. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12387. if (rightBindData != null)
  12388. {
  12389. //公务舱 + 小套房 JSES
  12390. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  12391. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  12392. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12393. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  12394. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12395. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12396. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12397. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12398. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12399. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12400. }
  12401. else
  12402. {
  12403. hideRowsList.Add(Row + startIndex + HideRows);
  12404. }
  12405. HideRows += 2;
  12406. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12407. if (rightBindData != null)
  12408. {
  12409. //公务舱 + 小套房 JSES
  12410. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  12411. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  12412. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12413. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  12414. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12415. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12416. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12417. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12418. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12419. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12420. }
  12421. else
  12422. {
  12423. hideRowsList.Add(Row + startIndex + HideRows);
  12424. }
  12425. HideRows += 2;
  12426. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12427. if (rightBindData != null)
  12428. {
  12429. //经济舱 + 大套房
  12430. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  12431. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  12432. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12433. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  12434. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12435. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12436. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12437. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12438. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12439. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12440. }
  12441. else
  12442. {
  12443. hideRowsList.Add(Row + startIndex + HideRows);
  12444. }
  12445. HideRows += 2;
  12446. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12447. if (rightBindData != null)
  12448. {
  12449. //头等舱 + 小套房 JSES
  12450. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  12451. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  12452. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12453. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  12454. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12455. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12456. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12457. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12458. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12459. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12460. }
  12461. else
  12462. {
  12463. hideRowsList.Add(Row + startIndex + HideRows);
  12464. }
  12465. HideRows += 2;
  12466. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12467. if (rightBindData != null)
  12468. {
  12469. //头等舱 + 大套房
  12470. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  12471. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  12472. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12473. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  12474. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12475. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12476. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12477. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12478. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12479. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12480. }
  12481. else
  12482. {
  12483. hideRowsList.Add(Row + startIndex + HideRows);
  12484. }
  12485. #endregion
  12486. #region B段标题清空
  12487. designer.SetDataSource("CostBDRCB", "");
  12488. designer.SetDataSource("CostBRS", "");
  12489. designer.SetDataSource("CostBXS", "");
  12490. designer.SetDataSource("CostBZCB", "");
  12491. designer.SetDataSource("CostBDRBJ", "");
  12492. designer.SetDataSource("CostBZBJ", "");
  12493. designer.SetDataSource("CostBDRLR", "");
  12494. designer.SetDataSource("CostBZLR", "");
  12495. designer.SetDataSource("CostBDRCBOM", "");
  12496. designer.SetDataSource("CostBRSOM", "");
  12497. designer.SetDataSource("CostBZCBOM", "");
  12498. designer.SetDataSource("CostBDRBJOM", "");
  12499. designer.SetDataSource("CostBZBJOM", "");
  12500. designer.SetDataSource("CostBDRLROM", "");
  12501. designer.SetDataSource("CostBZLROM", "");
  12502. #endregion
  12503. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  12504. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  12505. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  12506. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  12507. designer.SetDataSource("DJName", "地接(CNY)");
  12508. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  12509. designer.SetDataSource("CPName", "地接-船票(CNY)");
  12510. designer.SetDataSource("GWName", "公务(CNY)");
  12511. designer.SetDataSource("YQHName", "邀请函(CNY)");
  12512. designer.SetDataSource("LYJName", "零用金(CNY)");
  12513. designer.SetDataSource("HSName", "核酸检测(CNY)");
  12514. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  12515. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  12516. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  12517. designer.SetDataSource("BXName", "保险(CNY)");
  12518. designer.SetDataSource("VisaName", "签证(CNY)");
  12519. #region B段基本数据
  12520. if (dto.costType == "B")
  12521. {
  12522. left = dto.leftInfo.Find(x => x.Type == "B");
  12523. if (left == null)
  12524. {
  12525. return Ok(jw);
  12526. }
  12527. #region B段left数据
  12528. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  12529. if (leftBindData != null)
  12530. {
  12531. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  12532. designer.SetDataSource("BHSRS", leftBindData.rs);
  12533. designer.SetDataSource("BHSXS", leftBindData.xs);
  12534. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12535. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12536. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12537. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12538. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12539. }
  12540. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  12541. if (leftBindData != null)
  12542. {
  12543. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  12544. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  12545. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  12546. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12547. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12548. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12549. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12550. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12551. }
  12552. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  12553. if (leftBindData != null)
  12554. {
  12555. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  12556. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  12557. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  12558. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12559. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12560. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12561. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12562. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12563. }
  12564. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  12565. if (leftBindData != null)
  12566. {
  12567. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  12568. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  12569. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  12570. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12571. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12572. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12573. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12574. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12575. }
  12576. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  12577. if (leftBindData != null)
  12578. {
  12579. designer.SetDataSource("BHCPCB", leftBindData.cb);
  12580. designer.SetDataSource("BHCPRS", leftBindData.rs);
  12581. designer.SetDataSource("BHCPXS", leftBindData.xs);
  12582. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12583. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12584. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12585. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12586. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12587. }
  12588. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  12589. if (leftBindData != null)
  12590. {
  12591. designer.SetDataSource("BCPCB", leftBindData.cb);
  12592. designer.SetDataSource("BCPRS", leftBindData.rs);
  12593. designer.SetDataSource("BCPXS", leftBindData.xs);
  12594. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12595. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12596. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12597. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12598. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12599. }
  12600. //TBR
  12601. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  12602. if (leftBindData != null)
  12603. {
  12604. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  12605. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  12606. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  12607. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12608. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12609. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12610. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12611. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12612. }
  12613. //SGR
  12614. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  12615. if (leftBindData != null)
  12616. {
  12617. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  12618. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  12619. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  12620. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12621. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12622. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12623. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12624. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12625. }
  12626. //JS/ES
  12627. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  12628. if (leftBindData != null)
  12629. {
  12630. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  12631. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  12632. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  12633. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12634. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12635. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12636. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12637. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12638. }
  12639. //SUITE
  12640. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  12641. if (leftBindData != null)
  12642. {
  12643. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  12644. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  12645. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  12646. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12647. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12648. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12649. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12650. designer.SetDataSource("BHotelSUITEZLR", ((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("BDJDRCB", leftBindData.cb);
  12656. designer.SetDataSource("BDJRS", leftBindData.rs);
  12657. designer.SetDataSource("BDJXS", leftBindData.xs);
  12658. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12659. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12660. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12661. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12662. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12663. }
  12664. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  12665. if (leftBindData != null)
  12666. {
  12667. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  12668. designer.SetDataSource("BGWRS", leftBindData.rs);
  12669. designer.SetDataSource("BGWXS", leftBindData.xs);
  12670. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12671. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12672. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12673. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12674. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12675. }
  12676. #region 优化方案
  12677. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  12678. //excelBind.Add("零用金", new {
  12679. //cb="",
  12680. //rs="",
  12681. //xs ="",
  12682. //zcb = "",
  12683. //});
  12684. #endregion
  12685. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  12686. if (leftBindData != null)
  12687. {
  12688. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  12689. designer.SetDataSource("BLYJRS", leftBindData.rs);
  12690. designer.SetDataSource("BLYJXS", leftBindData.xs);
  12691. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  12692. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  12693. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  12694. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  12695. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  12696. }
  12697. #endregion
  12698. #region B段Right信息
  12699. right = dto.rightInfo.Find(x => x.Type == "B");
  12700. if (right == null)
  12701. {
  12702. return Ok(jw);
  12703. }
  12704. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  12705. if (rightBindData != null)
  12706. {
  12707. //经济舱 + 双人间 TBR
  12708. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  12709. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  12710. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12711. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  12712. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12713. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12714. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12715. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12716. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12717. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12718. }
  12719. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  12720. if (rightBindData != null)
  12721. {
  12722. //经济舱 + 单人间 SGR
  12723. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  12724. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  12725. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12726. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  12727. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12728. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12729. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12730. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12731. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12732. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12733. }
  12734. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  12735. if (rightBindData != null)
  12736. {
  12737. //公务舱 + 单人间 SGR
  12738. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  12739. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  12740. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12741. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  12742. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12743. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12744. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12745. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12746. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12747. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12748. }
  12749. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  12750. if (rightBindData != null)
  12751. {
  12752. //公务舱 + 小套房 JSES
  12753. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  12754. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  12755. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12756. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  12757. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12758. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12759. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12760. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12761. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12762. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12763. }
  12764. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  12765. if (rightBindData != null)
  12766. {
  12767. //公务舱 + 小套房 JSES
  12768. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  12769. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  12770. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12771. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  12772. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12773. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12774. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12775. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12776. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12777. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12778. }
  12779. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  12780. if (rightBindData != null)
  12781. {
  12782. //经济舱 + 大套房
  12783. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  12784. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  12785. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12786. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  12787. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12788. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12789. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12790. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12791. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12792. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12793. }
  12794. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  12795. if (rightBindData != null)
  12796. {
  12797. //头等舱 + 小套房 JSES
  12798. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  12799. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  12800. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12801. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  12802. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12803. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12804. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12805. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12806. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12807. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12808. }
  12809. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  12810. if (rightBindData != null)
  12811. {
  12812. //头等舱 + 大套房
  12813. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  12814. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  12815. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  12816. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  12817. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  12818. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  12819. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  12820. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  12821. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  12822. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  12823. }
  12824. #endregion
  12825. #region 标题
  12826. designer.SetDataSource("CostBDRCB", "单人成本");
  12827. designer.SetDataSource("CostBRS", "人数");
  12828. designer.SetDataSource("CostBXS", "系数");
  12829. designer.SetDataSource("CostBZCB", "总成本");
  12830. designer.SetDataSource("CostBDRBJ", "单人报价");
  12831. designer.SetDataSource("CostBZBJ", "总报价");
  12832. designer.SetDataSource("CostBDRLR", "单人利润");
  12833. designer.SetDataSource("CostBZLR", "总利润");
  12834. designer.SetDataSource("CostBDRCBOM", "单人成本");
  12835. designer.SetDataSource("CostBRSOM", "人数");
  12836. designer.SetDataSource("CostBZCBOM", "总成本");
  12837. designer.SetDataSource("CostBDRBJOM", "单人报价");
  12838. designer.SetDataSource("CostBZBJOM", "总报价");
  12839. designer.SetDataSource("CostBDRLROM", "单人利润");
  12840. designer.SetDataSource("CostBZLROM", "总利润");
  12841. #endregion
  12842. }
  12843. #endregion
  12844. designer.SetDataSource("TzZCB2", TzZCB2);
  12845. designer.SetDataSource("TzZBJ2", TzZBJ2);
  12846. designer.SetDataSource("TzZLR2", TzZLR2);
  12847. string[] dataSourceKeys = new string[]
  12848. {
  12849. "VF",
  12850. "TGS",
  12851. "TGOF",
  12852. "TGM",
  12853. "TGA",
  12854. "TGTF",
  12855. "TGEF",
  12856. "CFM",
  12857. "CFOF",
  12858. "B",
  12859. "L",
  12860. "D",
  12861. "TBR",
  12862. "SGR",
  12863. "JSES",
  12864. "Suite",
  12865. "TV",
  12866. "1L",
  12867. "IF",
  12868. "EF",
  12869. "BRF",
  12870. "TE",
  12871. "TGT",
  12872. "DRVT",
  12873. "PC",
  12874. "TLF",
  12875. "ECT"
  12876. };
  12877. foreach (var item in dataSourceKeys)
  12878. {
  12879. var find = dto.titleModel.FirstOrDefault(x => x.label.Replace(" ", "").Replace("/", "") == item);
  12880. if (find != null)
  12881. {
  12882. designer.SetDataSource(item, find.text);
  12883. }
  12884. else
  12885. {
  12886. designer.SetDataSource(item, 0);
  12887. }
  12888. }
  12889. designer.SetDataSource(dt);
  12890. //根据数据源处理生成报表内容
  12891. designer.Process();
  12892. designer.Workbook.Worksheets[0].Name = "清单";
  12893. Worksheet sheet = designer.Workbook.Worksheets[0];
  12894. foreach (var Rowindex in hideRowsList)
  12895. {
  12896. ws.Cells.HideRows(Rowindex, 2);
  12897. }
  12898. byte[] bytes = null;
  12899. string strFileName = di.TeamName + "-团组-成本.xls";
  12900. using (MemoryStream stream = new MemoryStream())
  12901. {
  12902. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  12903. bytes = stream.ToArray();
  12904. }
  12905. return Ok(JsonView(true, "", new
  12906. {
  12907. Data = bytes,
  12908. strFileName,
  12909. }));
  12910. }
  12911. /// <summary>
  12912. /// 导出客户报表
  12913. /// </summary>
  12914. /// <returns></returns>
  12915. [HttpPost]
  12916. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  12917. {
  12918. var jw = JsonView(false);
  12919. if (dto.Diid == 0)
  12920. {
  12921. return Ok(JsonView(false, "请传递团组id"));
  12922. }
  12923. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  12924. if (deleInfo.Code != 0)
  12925. {
  12926. return Ok(JsonView(false, "团组信息查询失败!"));
  12927. }
  12928. var di = deleInfo.Data as DelegationInfoWebView;
  12929. if (di == null)
  12930. {
  12931. return Ok(JsonView(false, "团组信息查询失败!"));
  12932. }
  12933. //文件名
  12934. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  12935. //获取模板
  12936. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  12937. //载入模板
  12938. Document doc = new Document(tmppath);
  12939. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  12940. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  12941. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  12942. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  12943. var AParameter = ParameterList.Find(x => x.CostType == "A");
  12944. var BParameter = ParameterList.Find(x => x.CostType == "B");
  12945. if (AParameter == null)
  12946. {
  12947. return Ok(JsonView(false, "系数不存在!"));
  12948. }
  12949. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  12950. , TzAirDesc, TzZCost;
  12951. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  12952. = TzAirDesc = TzZCost = string.Empty;
  12953. TzNumber = AParameter.CostTypenumber.ToString();
  12954. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  12955. CarGuides1 = dto.CarGuides1;
  12956. Meal = dto.Meal;
  12957. SubsidizedMeals = dto.SubsidizedMeals;
  12958. NightRepair = dto.NightRepair;
  12959. AttractionsTickets = dto.AttractionsTickets;
  12960. MiscellaneousFees = dto.MiscellaneousFees;
  12961. ATip = dto.ATip;
  12962. TzHotelDesc = "";
  12963. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  12964. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  12965. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  12966. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  12967. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  12968. TzAirDesc = "";
  12969. TzZCost = dto.TzZCost;
  12970. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  12971. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  12972. var index = 1;
  12973. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  12974. foreach (var item in TzHotelDescArr)
  12975. {
  12976. if (AinfoArr != null)
  12977. {
  12978. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  12979. if (Ainfo != null)
  12980. {
  12981. if (int.Parse(Ainfo.rs) <= 0)
  12982. {
  12983. continue;
  12984. }
  12985. var hotelText = string.Empty;
  12986. switch (item)
  12987. {
  12988. case "SGR":
  12989. hotelText = "单人间";
  12990. break;
  12991. case "JSES":
  12992. hotelText = "小套房";
  12993. break;
  12994. case "SUITE":
  12995. hotelText = "套房";
  12996. break;
  12997. case "TBR":
  12998. hotelText = "双人间";
  12999. break;
  13000. }
  13001. if (item != "TBR")
  13002. {
  13003. 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";
  13004. }
  13005. else
  13006. {
  13007. 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";
  13008. }
  13009. index++;
  13010. }
  13011. }
  13012. }
  13013. index = 1;
  13014. foreach (var item in TzAirDescArr)
  13015. {
  13016. if (AinfoArr != null)
  13017. {
  13018. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13019. if (Ainfo != null)
  13020. {
  13021. if (int.Parse(Ainfo.rs) <= 0)
  13022. {
  13023. continue;
  13024. }
  13025. 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";
  13026. index++;
  13027. }
  13028. }
  13029. }
  13030. if (dto.costType == "B")
  13031. {
  13032. if (BParameter == null)
  13033. {
  13034. return Ok(JsonView(false, "B段系数不存在!"));
  13035. }
  13036. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  13037. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  13038. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  13039. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  13040. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  13041. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  13042. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  13043. foreach (var item in TzHotelDescArr)
  13044. {
  13045. if (AinfoArr != null)
  13046. {
  13047. TzHotelDesc += "B段信息 \r\n";
  13048. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13049. if (Ainfo != null)
  13050. {
  13051. if (int.Parse(Ainfo.rs) <= 0)
  13052. {
  13053. continue;
  13054. }
  13055. var hotelText = string.Empty;
  13056. switch (item)
  13057. {
  13058. case "SGR":
  13059. hotelText = "单人间";
  13060. break;
  13061. case "JSES":
  13062. hotelText = "小套房";
  13063. break;
  13064. case "SUITE":
  13065. hotelText = "套房";
  13066. break;
  13067. case "TBR":
  13068. hotelText = "双人间";
  13069. break;
  13070. }
  13071. if (item != "TBR")
  13072. {
  13073. 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";
  13074. }
  13075. else
  13076. {
  13077. 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";
  13078. }
  13079. index++;
  13080. }
  13081. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  13082. }
  13083. }
  13084. index = 1;
  13085. foreach (var item in TzAirDescArr)
  13086. {
  13087. if (AinfoArr != null)
  13088. {
  13089. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  13090. if (Ainfo != null)
  13091. {
  13092. if (int.Parse(Ainfo.rs) <= 0)
  13093. {
  13094. continue;
  13095. }
  13096. 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";
  13097. index++;
  13098. }
  13099. }
  13100. }
  13101. }
  13102. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  13103. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  13104. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  13105. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  13106. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  13107. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  13108. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  13109. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  13110. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  13111. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  13112. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  13113. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  13114. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  13115. DickeyValue.Add("Visa", Visa); // 签证单人报价
  13116. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  13117. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  13118. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  13119. DickeyValue.Add("TzZCost", TzZCost);
  13120. foreach (var key in DickeyValue.Keys)
  13121. {
  13122. if (doc.Range.Bookmarks[key] != null)
  13123. {
  13124. Bookmark mark = doc.Range.Bookmarks[key];
  13125. mark.Text = DickeyValue[key];
  13126. }
  13127. }
  13128. byte[] bytes = null;
  13129. string strFileName = di.TeamName + "-客户报价.doc";
  13130. using (MemoryStream stream = new MemoryStream())
  13131. {
  13132. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  13133. bytes = stream.ToArray();
  13134. }
  13135. return Ok(JsonView(true, "", new
  13136. {
  13137. Data = bytes,
  13138. strFileName,
  13139. }));
  13140. }
  13141. /// <summary>
  13142. /// 团组成本 各模块(酒店,地接,机票)成本提示
  13143. /// </summary>
  13144. /// <param name="dto"></param>
  13145. /// <returns></returns>
  13146. [HttpPost]
  13147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13148. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  13149. {
  13150. try
  13151. {
  13152. #region 参数验证
  13153. if (dto.DiId < 0)
  13154. {
  13155. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  13156. }
  13157. List<int> cTableIds = new List<int>() {
  13158. 76 ,//酒店预订
  13159. 77 ,//行程
  13160. 79 ,//车/导游地接
  13161. 80 ,//签证
  13162. 81 ,//邀请/公务活
  13163. 82 ,//团组客户保险
  13164. 85 ,//机票预订
  13165. 98 ,//其他款项
  13166. 285 ,//收款退还
  13167. 751 ,//酒店早餐
  13168. 1015 // 超支费用
  13169. };
  13170. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  13171. {
  13172. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  13173. }
  13174. #endregion
  13175. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  13176. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  13177. if (_GroupCostParameters.Count <= 0)
  13178. {
  13179. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  13180. }
  13181. if (_GroupCostParameters[0].IsShare == 0)
  13182. {
  13183. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  13184. }
  13185. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13186. //处理date为空问题
  13187. if (_GroupCosts.Count > 0)
  13188. {
  13189. for (int i = 0; i < _GroupCosts.Count; i++)
  13190. {
  13191. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  13192. {
  13193. if (i > 0)
  13194. {
  13195. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  13196. }
  13197. }
  13198. }
  13199. }
  13200. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  13201. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  13202. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  13203. string currCode = "";
  13204. #region currCode 验证
  13205. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  13206. if (isInt)
  13207. {
  13208. var currData = currDatas.Find(it => it.Id == intCurrency);
  13209. if (currData != null)
  13210. {
  13211. currCode = currData.Name;
  13212. }
  13213. }
  13214. else
  13215. {
  13216. currCode = _GroupCostParameters[0].Currency.Trim();
  13217. }
  13218. #endregion
  13219. //op,酒店单段模式存储
  13220. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  13221. {
  13222. CurrencyCode = currCode,
  13223. Rate = _GroupCostParameters[0].Rate,
  13224. CostType = _GroupCostParameters[0].CostType,
  13225. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  13226. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  13227. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  13228. };
  13229. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  13230. if (_GroupCostParameters.Count == 2)
  13231. {
  13232. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  13233. }
  13234. foreach (var item in _GroupCostParameters)
  13235. {
  13236. decimal _rate = 1;
  13237. decimal _rate1 = item.Rate;
  13238. decimal _scale = 1;
  13239. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  13240. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  13241. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  13242. //if (userInfo != null)
  13243. //{
  13244. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  13245. // {
  13246. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  13247. // {
  13248. // _scale = 1.00M;
  13249. // }
  13250. // }
  13251. //}
  13252. #endregion
  13253. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  13254. {
  13255. CurrencyCode = currCode,
  13256. Rate = _rate1,
  13257. CostType = item.CostType,
  13258. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  13259. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  13260. CostTypeNumber = item.CostTypenumber
  13261. };
  13262. if (_GroupCostParameters.Count > 1)
  13263. {
  13264. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  13265. }
  13266. else
  13267. {
  13268. modulePromptInfo.CostTypeNumber = item.LYJRS;
  13269. }
  13270. if (dto.CTable == 79)//
  13271. {
  13272. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  13273. modulePromptInfo.TotalCost = item.DJCB;
  13274. }
  13275. List<string> costTypes = new List<string>() { "A", "B" };
  13276. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  13277. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  13278. if (_GroupCostsDuplicates.Count() == 1)
  13279. {
  13280. _GroupCostsTypeData = _GroupCosts;
  13281. }
  13282. else
  13283. {
  13284. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  13285. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  13286. }
  13287. /*
  13288. * 76 酒店预订
  13289. * 77 行程
  13290. * 79 车/导游地接
  13291. * 80 签证
  13292. * 81 邀请/公务活动
  13293. * 82 团组客户保险
  13294. * 85 机票预订
  13295. * 98 其他款项
  13296. * 285 收款退还
  13297. * 751 酒店早餐
  13298. * 1015 超支费用
  13299. */
  13300. switch (dto.CTable)
  13301. {
  13302. case 76: // 酒店预订
  13303. _ModuleSubPromptInfo.AddRange(
  13304. _GroupCostsTypeData.Select(it => new
  13305. {
  13306. it.DAY,
  13307. it.Date,
  13308. it.ACCON,
  13309. it.ITIN,
  13310. it.SGR,
  13311. it.TBR,
  13312. it.JS_ES,
  13313. it.Suite
  13314. })
  13315. );
  13316. break;
  13317. case 79: // 车/导游地接
  13318. _ModuleSubPromptInfo.AddRange(
  13319. _GroupCostsTypeData.Select(it => new
  13320. {
  13321. Date = it.Date, //日期
  13322. CarFee = it.CarCost * _rate * _scale, //车费用
  13323. CarType = it.CarType, //车型
  13324. DriverFee = it.CFS * _rate * _scale, //司机工资
  13325. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  13326. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  13327. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  13328. GuideFee = it.TGS * _rate * _scale, //导游费用
  13329. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  13330. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  13331. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  13332. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  13333. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  13334. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  13335. Breakfast = it.B * _rate * _scale, //早餐费
  13336. Lunch = it.L * _rate * _scale, //午餐费
  13337. Dinner = it.D * _rate * _scale, //晚餐费
  13338. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  13339. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  13340. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  13341. TicketFee = it.EF * _rate * _scale, //门票费
  13342. TicketRemark = it.EFR, //门票费描述
  13343. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  13344. TravelSupplies = it.TE * _rate * _scale, //出行物资
  13345. SpentCash = it.PC * _rate * _scale, //零用金
  13346. LeadersFee = it.TLF * _rate * _scale, //领队费
  13347. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  13348. })
  13349. );
  13350. break;
  13351. case 85: // 机票
  13352. List<dynamic> datas = new List<dynamic>();
  13353. datas.Add(
  13354. new
  13355. {
  13356. AirType = "经济舱",
  13357. AirNum = item.JJCRS,
  13358. AirDRCB = item.JJCCB,
  13359. AirZCB = (item.JJCRS * item.JJCCB)
  13360. }
  13361. );
  13362. datas.Add(
  13363. new
  13364. {
  13365. AirType = "公务舱",
  13366. AirNum = item.GWCRS,
  13367. AirDRCB = item.GWCCB,
  13368. AirZCB = (item.GWCRS * item.GWCCB)
  13369. }
  13370. );
  13371. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  13372. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  13373. modulePromptInfo.Data = new
  13374. {
  13375. airFeeData = datas,
  13376. airInitData = initDatas
  13377. };
  13378. _ModulePromptInfos.Add(modulePromptInfo);
  13379. break;
  13380. default:
  13381. break;
  13382. }
  13383. }
  13384. if (dto.CTable != 85)
  13385. {
  13386. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  13387. _ModulePromptInfos.Add(_ModulePromptInfo);
  13388. }
  13389. _view.ModulePromptInfos = _ModulePromptInfos;
  13390. return Ok(JsonView(true, "操作成功!", _view));
  13391. }
  13392. catch (Exception ex)
  13393. {
  13394. return Ok(JsonView(false, ex.Message));
  13395. }
  13396. }
  13397. /// <summary>
  13398. /// 根据黑屏代码重新生成行程
  13399. /// </summary>
  13400. /// <param name="dto"></param>
  13401. /// <returns></returns>
  13402. [HttpPost]
  13403. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  13404. {
  13405. var jw = JsonView(false);
  13406. var Create = _GroupCostRepository.
  13407. CreateGroupCostByBlackCode(dto.Diid);
  13408. jw.Msg = Create.Msg;
  13409. if (Create.Code == 0)
  13410. {
  13411. jw.Code = 200;
  13412. jw.Data = new
  13413. {
  13414. groupCost = Create.Data,
  13415. blackCodeIsTrue = true
  13416. };
  13417. }
  13418. else
  13419. {
  13420. jw.Code = 400;
  13421. jw.Data = new
  13422. {
  13423. groupCost = Create.Data,
  13424. blackCodeIsTrue = false,
  13425. };
  13426. }
  13427. return Ok(jw);
  13428. }
  13429. /// <summary>
  13430. /// 成本获取OP历史车费用
  13431. /// </summary>
  13432. /// <param name="dto"></param>
  13433. /// <returns></returns>
  13434. [HttpPost]
  13435. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  13436. {
  13437. var jw = JsonView(false);
  13438. try
  13439. {
  13440. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  13441. //获取现有所有车的数据
  13442. if (!dto.Param.IsNullOrWhiteSpace())
  13443. {
  13444. string sql = $@"
  13445. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  13446. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  13447. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  13448. 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
  13449. AND gctggr.ServiceEndTime is not NULL
  13450. ORDER by gctggrc.id DESC
  13451. ";
  13452. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  13453. var numeberResult = await Task.Run(() =>
  13454. {
  13455. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  13456. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  13457. return numberArr;
  13458. });
  13459. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  13460. foreach (var item in numeberResult)
  13461. {
  13462. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  13463. {
  13464. Country = "数据异常!",
  13465. City = string.Empty,
  13466. };
  13467. item.Area = find.Country + " " + find.City;
  13468. }
  13469. dbResult.AddRange(numeberResult);
  13470. if (dto.Param.Contains("、"))
  13471. {
  13472. var sp = dto.Param.Split("、");
  13473. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13474. .Where(x =>
  13475. {
  13476. return System.Array.Exists(sp, e =>
  13477. {
  13478. bool where = false;
  13479. if (x.Area != null)
  13480. {
  13481. where = x.Area.Contains(e);
  13482. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13483. {
  13484. return false;
  13485. }
  13486. }
  13487. if (x.PriceName != null && !where)
  13488. {
  13489. where = x.PriceName.Contains(e);
  13490. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13491. {
  13492. return false;
  13493. }
  13494. }
  13495. return where;
  13496. });
  13497. }).ToList();
  13498. }
  13499. else
  13500. {
  13501. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  13502. .Where(x =>
  13503. {
  13504. bool where = false;
  13505. if (x.Area != null)
  13506. {
  13507. where = x.Area.Contains(dto.Param);
  13508. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  13509. {
  13510. return false;
  13511. }
  13512. }
  13513. if (x.PriceName != null && !where)
  13514. {
  13515. where = x.PriceName.Contains(dto.Param);
  13516. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  13517. {
  13518. return false;
  13519. }
  13520. }
  13521. return where;
  13522. }
  13523. )
  13524. .ToList();
  13525. }
  13526. }
  13527. var view = dbResult.Select(x =>
  13528. {
  13529. decimal dp = 0.00M;
  13530. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  13531. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  13532. if (string.IsNullOrWhiteSpace(x.DatePrice))
  13533. {
  13534. if (startB && endB)
  13535. {
  13536. var timesp = endD.Subtract(startD);
  13537. if ((timesp.Days + 1) != 0)
  13538. {
  13539. dp = x.Price / (timesp.Days + 1);
  13540. }
  13541. }
  13542. }
  13543. else
  13544. {
  13545. dp = x.Price;
  13546. }
  13547. return new
  13548. {
  13549. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  13550. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  13551. x.Area,
  13552. x.id,
  13553. price = x.Price.ToString("F2"),
  13554. x.PriceName,
  13555. x.PriceContent,
  13556. x.TeamName,
  13557. x.DatePrice,
  13558. dayPrice = dp.ToString("F2"),
  13559. };
  13560. }).OrderByDescending(x => x.id).ToList();
  13561. jw = JsonView(true, "获取成功!", view);
  13562. }
  13563. catch (Exception e)
  13564. {
  13565. jw = JsonView(false, e.Message);
  13566. }
  13567. return Ok(jw);
  13568. }
  13569. #endregion
  13570. #region 酒店预订 新 雷怡 2023-12-28 17:45
  13571. /// <summary>
  13572. /// 酒店预订
  13573. /// 酒店费用列表 根据团组Id查询
  13574. /// </summary>
  13575. /// <param name="_dto"></param>
  13576. /// <returns></returns>
  13577. [HttpPost]
  13578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13579. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  13580. {
  13581. #region 参数验证
  13582. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13583. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13584. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13585. #region 团组操作权限验证 76 酒店预定模块
  13586. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13587. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13588. #endregion
  13589. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13590. #region 页面操作权限验证
  13591. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13592. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13593. #endregion
  13594. #endregion
  13595. return Ok(await _hotelPriceRep._ItemsByDiId(_dto.PortType, _dto.DiId));
  13596. }
  13597. /// <summary>
  13598. /// 酒店预订
  13599. /// 基础数据
  13600. /// </summary>
  13601. /// <param name="_dto"></param>
  13602. /// <returns></returns>
  13603. [HttpPost]
  13604. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13605. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  13606. {
  13607. #region 参数验证
  13608. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13609. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13610. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13611. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13612. #region 页面操作权限验证
  13613. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13614. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13615. #endregion
  13616. #region 团组操作权限验证 76 酒店预定模块
  13617. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13618. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13619. #endregion
  13620. #endregion
  13621. return Ok(await _hotelPriceRep._BasicsDataInit(_dto.PortType, _dto.DiId));
  13622. }
  13623. /// <summary>
  13624. /// 酒店预订
  13625. /// 创建 入住卷号码
  13626. /// </summary>
  13627. /// <param name="_dto"></param>
  13628. /// <returns></returns>
  13629. [HttpPost]
  13630. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13631. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  13632. {
  13633. #region 参数验证
  13634. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13635. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13636. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13637. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13638. #region 页面操作权限验证
  13639. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13640. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13641. #endregion
  13642. #region 团组操作权限验证 76 酒店预定模块
  13643. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13644. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13645. #endregion
  13646. #endregion
  13647. Result data = await _hotelPriceRep._CreateCheckVolumeNo(_dto.DiId);
  13648. if (data.Code != 0)
  13649. {
  13650. return Ok(JsonView(false, data.Msg));
  13651. }
  13652. return Ok(JsonView(true, data.Msg, data.Data));
  13653. }
  13654. /// <summary>
  13655. /// 酒店预订
  13656. /// 详情
  13657. /// </summary>
  13658. /// <param name="_dto"></param>
  13659. /// <returns></returns>
  13660. [HttpPost]
  13661. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13662. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  13663. {
  13664. #region 参数验证
  13665. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  13666. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13667. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  13668. #region 团组操作权限验证 76 酒店预定模块
  13669. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13670. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13671. #endregion
  13672. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13673. #region 页面操作权限验证
  13674. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13675. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  13676. #endregion
  13677. #endregion
  13678. return Ok(await _hotelPriceRep._Details(_dto.PortType, _dto.Id));
  13679. }
  13680. /// <summary>
  13681. /// 酒店预订
  13682. /// Add Or Edit
  13683. /// </summary>
  13684. /// <param name="_dto"></param>
  13685. /// <returns></returns>
  13686. [HttpPost]
  13687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13688. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  13689. {
  13690. #region 参数验证
  13691. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13692. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13693. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13694. #region 团组操作权限验证 76 酒店预定模块
  13695. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13696. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13697. #endregion
  13698. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13699. #region 页面操作权限验证
  13700. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13701. if (_dto.Id == 0) // Add
  13702. {
  13703. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  13704. }
  13705. else if (_dto.Id > 1) // Edit
  13706. {
  13707. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  13708. }
  13709. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  13710. #endregion
  13711. #endregion
  13712. JsonView _view = await _hotelPriceRep._AddOrEdit(_dto);
  13713. if (_view.Code != 200)
  13714. {
  13715. return Ok(_view);
  13716. }
  13717. #region 成本无酒店价格数据进入超支
  13718. _sqlSugar.BeginTran();
  13719. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  13720. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  13721. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  13722. for (int i = 0; i < groupCost.Count; i++)
  13723. {
  13724. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  13725. {
  13726. groupCost[i].Date = groupCost[i - 1].Date;
  13727. }
  13728. }
  13729. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  13730. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  13731. List<Fin_GroupExtraCostDto_OP>();
  13732. if (start_Bool && end_Bool)
  13733. {
  13734. while (start_Time < end_Time)
  13735. {
  13736. foreach (var item in groupCost_Grp)
  13737. {
  13738. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  13739. {
  13740. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  13741. {
  13742. extraCostList.Add(new
  13743. Fin_GroupExtraCostDto_OP
  13744. {
  13745. Area = _dto.AreaId,
  13746. coefficient = 1.5M,
  13747. createUser = _dto.UserId,
  13748. currency = _dto.CardPriceCurrency,
  13749. diId = _dto.DiId,
  13750. ManagerConfirm = 0,
  13751. SupervisorConfirm = 0,
  13752. SYsupervisorConfirm = 0,
  13753. editType = 1,
  13754. PortType = 1,
  13755. price = _dto.CardPrice,
  13756. PriceCount = 1,
  13757. priceType = 1027,
  13758. priceDetailType = 1044,
  13759. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  13760. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  13761. });
  13762. }
  13763. }
  13764. }
  13765. start_Time = start_Time.AddDays(1);
  13766. }
  13767. }
  13768. if (extraCostList.Any())
  13769. {
  13770. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  13771. }
  13772. _sqlSugar.CommitTran();
  13773. #endregion
  13774. #region 应用推送
  13775. try
  13776. {
  13777. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13778. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13779. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13780. var diId = _dto.DiId;
  13781. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13782. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13783. #region 操作记录
  13784. var opInfo = new Crm_TableOperationRecord() {
  13785. TableName = "Grp_HotelReservations",
  13786. PortType = _dto.PortType,
  13787. DataId = hotelId,
  13788. CreateUserId = _dto.UserId
  13789. };
  13790. var opStatus = OperationEnum.NoOperation;
  13791. if (_dto.Id<1) //添加操作
  13792. {
  13793. opInfo.OperationItem = OperationEnum.Add;
  13794. }
  13795. else if (_dto.Id > 0)
  13796. {
  13797. opInfo.OperationItem = OperationEnum.Edit;
  13798. }
  13799. string opRemark = string.Empty;
  13800. if (ccpInfo != null)
  13801. {
  13802. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  13803. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  13804. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  13805. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  13806. }
  13807. opInfo.Remark = opRemark;
  13808. await _tableorRep.AddAsync(opInfo);
  13809. #endregion
  13810. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  13811. //2024-10-21 新增LZ UID
  13812. var userIds = new List<int>() { 21 };
  13813. string title = $"费用审核";
  13814. string content = "";
  13815. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13816. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13817. try
  13818. {
  13819. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  13820. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  13821. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  13822. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  13823. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  13824. }
  13825. catch (Exception ex )
  13826. {
  13827. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  13828. }
  13829. }
  13830. catch (Exception ex)
  13831. {
  13832. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  13833. }
  13834. try
  13835. {
  13836. int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  13837. int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  13838. int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  13839. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13840. //自动审核
  13841. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  13842. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  13843. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  13844. //2024-10-21 新增LZ UID
  13845. var userIds = new List<int>() { 21 };
  13846. string title = $"系统通知";
  13847. var diId = _dto.DiId;
  13848. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13849. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13850. string content = "";
  13851. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13852. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  13853. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13854. }
  13855. catch (Exception ex)
  13856. {
  13857. }
  13858. #endregion
  13859. return Ok(_view);
  13860. }
  13861. /// <summary>
  13862. /// 酒店自动审核测试
  13863. /// Add Or Edit
  13864. /// </summary>
  13865. /// <param name="_dto"></param>
  13866. /// <returns></returns>
  13867. [HttpPost]
  13868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13869. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  13870. {
  13871. #region 应用推送
  13872. try
  13873. {
  13874. //自动审核
  13875. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  13876. }
  13877. catch (Exception ex)
  13878. {
  13879. return Ok(JsonView(false, "操作失败"));
  13880. }
  13881. #endregion
  13882. return Ok(JsonView(false, "操作成功"));
  13883. }
  13884. /// <summary>
  13885. /// 酒店预订
  13886. /// Del
  13887. /// </summary>
  13888. /// <param name="_dto"></param>
  13889. /// <returns></returns>
  13890. [HttpPost]
  13891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13892. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  13893. {
  13894. #region 参数验证
  13895. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13896. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13897. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13898. #region 团组操作权限验证 76 酒店预定模块
  13899. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13900. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13901. #endregion
  13902. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13903. #region 页面操作权限验证
  13904. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13905. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  13906. #endregion
  13907. #endregion
  13908. var data = await _hotelPriceRep._Del(_dto.Id, _dto.UserId);
  13909. #region 操作记录
  13910. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  13911. {
  13912. TableName = "Grp_HotelReservations",
  13913. PortType = _dto.PortType,
  13914. OperationItem = OperationEnum.Del,
  13915. DataId = _dto.Id,
  13916. CreateUserId = _dto.UserId
  13917. });
  13918. #endregion
  13919. return Ok(data);
  13920. }
  13921. /// <summary>
  13922. /// 酒店预订
  13923. /// 生成VOUCHER
  13924. /// 2024.05.06 之前版本
  13925. /// </summary>
  13926. /// <param name="_dto"></param>
  13927. /// <returns></returns>
  13928. [HttpPost]
  13929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13930. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  13931. {
  13932. try
  13933. {
  13934. #region 参数验证
  13935. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  13936. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  13937. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  13938. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  13939. #region 团组操作权限验证 76 酒店预定模块
  13940. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  13941. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  13942. #endregion
  13943. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  13944. #region 页面操作权限验证
  13945. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  13946. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  13947. #endregion
  13948. #endregion
  13949. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  13950. //判断数据是否完整
  13951. if (hr != null)
  13952. {
  13953. if (!string.IsNullOrEmpty(hr.DetermineNo))
  13954. {
  13955. string strFileName = "HotelStatement/";
  13956. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  13957. if (dele != null)
  13958. strFileName += dele.TourCode;
  13959. //载入模板
  13960. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  13961. Document doc = new Document(sss);
  13962. DocumentBuilder builder = new DocumentBuilder(doc);
  13963. #region 替换Word模板书签内容
  13964. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  13965. //入住卷预定号码
  13966. if (doc.Range.Bookmarks["VNO"] != null)
  13967. {
  13968. Bookmark mark = doc.Range.Bookmarks["VNO"];
  13969. mark.Text = hr.CheckNumber;
  13970. }
  13971. //酒店时间
  13972. if (doc.Range.Bookmarks["Date"] != null)
  13973. {
  13974. Bookmark mark = doc.Range.Bookmarks["Date"];
  13975. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  13976. }
  13977. //团号
  13978. if (doc.Range.Bookmarks["TNo"] != null)
  13979. {
  13980. Bookmark mark = doc.Range.Bookmarks["TNo"];
  13981. mark.Text = dele.TourCode;
  13982. }
  13983. //预定号码
  13984. if (doc.Range.Bookmarks["BookingId"] != null)
  13985. {
  13986. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  13987. mark.Text = hr.ReservationsNo;
  13988. }
  13989. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  13990. {
  13991. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  13992. mark.Text = hr.DetermineNo;
  13993. }
  13994. //酒店城市
  13995. if (doc.Range.Bookmarks["City"] != null)
  13996. {
  13997. Bookmark mark = doc.Range.Bookmarks["City"];
  13998. mark.Text = hr.City;
  13999. }
  14000. //酒店名称
  14001. if (doc.Range.Bookmarks["HName"] != null)
  14002. {
  14003. Bookmark mark = doc.Range.Bookmarks["HName"];
  14004. mark.Text = hr.HotelName;
  14005. }
  14006. //酒店地址
  14007. if (doc.Range.Bookmarks["Address"] != null)
  14008. {
  14009. Bookmark mark = doc.Range.Bookmarks["Address"];
  14010. mark.Text = hr.HotelAddress;
  14011. }
  14012. //酒店电话
  14013. if (doc.Range.Bookmarks["Tel"] != null)
  14014. {
  14015. Bookmark mark = doc.Range.Bookmarks["Tel"];
  14016. mark.Text = hr.HotelTel;
  14017. }
  14018. //酒店传真
  14019. if (doc.Range.Bookmarks["Fax"] != null)
  14020. {
  14021. Bookmark mark = doc.Range.Bookmarks["Fax"];
  14022. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  14023. {
  14024. mark.Text = hr.HotelFax;
  14025. }
  14026. }
  14027. //入住时间
  14028. if (doc.Range.Bookmarks["CIn"] != null)
  14029. {
  14030. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14031. Bookmark mark = doc.Range.Bookmarks["CIn"];
  14032. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  14033. }
  14034. //退房时间
  14035. if (doc.Range.Bookmarks["COut"] != null)
  14036. {
  14037. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14038. Bookmark mark = doc.Range.Bookmarks["COut"];
  14039. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14040. }
  14041. //客户名称
  14042. if (doc.Range.Bookmarks["GName"] != null)
  14043. {
  14044. string guestName = "";
  14045. string[] clients = new string[] { };
  14046. if (hr.GuestName.Contains(","))
  14047. {
  14048. clients = hr.GuestName.Split(",");
  14049. }
  14050. else
  14051. {
  14052. clients = new string[] { hr.GuestName };
  14053. }
  14054. List<int> clientIds_int = new List<int>();
  14055. if (clients.Length > 0)
  14056. {
  14057. foreach (var item in clients)
  14058. {
  14059. if (item.IsNumeric())
  14060. {
  14061. clientIds_int.Add(int.Parse(item));
  14062. }
  14063. }
  14064. }
  14065. if (clientIds_int.Count > 0)
  14066. {
  14067. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  14068. foreach (var client in _clientDatas)
  14069. {
  14070. //男
  14071. if (client.Sex == 0) guestName += $"Mr.";
  14072. //女
  14073. else if (client.Sex == 1) guestName += $"Ms.";
  14074. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  14075. {
  14076. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  14077. }
  14078. //guestName += $"{client.Pinyin},";
  14079. }
  14080. if (guestName.Length > 0)
  14081. {
  14082. guestName = guestName.Substring(0, guestName.Length - 1);
  14083. }
  14084. }
  14085. else
  14086. {
  14087. guestName = hr.GuestName;
  14088. }
  14089. Bookmark mark = doc.Range.Bookmarks["GName"];
  14090. mark.Text = guestName;
  14091. }
  14092. //房间介绍
  14093. if (doc.Range.Bookmarks["ROOM"] != null)
  14094. {
  14095. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  14096. mark.Text = hr.RoomExplanation;
  14097. }
  14098. //报价描述
  14099. if (doc.Range.Bookmarks["NOTE"] != null)
  14100. {
  14101. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  14102. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  14103. if (ss != null)
  14104. mark.Text = ss.Name;
  14105. }
  14106. //入住时间
  14107. if (doc.Range.Bookmarks["CheckIn"] != null)
  14108. {
  14109. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  14110. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  14111. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14112. }
  14113. //退房时间
  14114. if (doc.Range.Bookmarks["CheckOut"] != null)
  14115. {
  14116. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  14117. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  14118. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  14119. }
  14120. //日期
  14121. if (doc.Range.Bookmarks["DT"] != null)
  14122. {
  14123. Bookmark mark = doc.Range.Bookmarks["DT"];
  14124. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  14125. }
  14126. //名称
  14127. if (doc.Range.Bookmarks["VName"] != null)
  14128. {
  14129. Bookmark mark = doc.Range.Bookmarks["VName"];
  14130. mark.Text = hr.HotelName;
  14131. }
  14132. //号码
  14133. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  14134. {
  14135. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  14136. mark.Text = hr.CheckNumber;
  14137. }
  14138. #endregion
  14139. strFileName += "VOUCHER.doc";
  14140. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14141. doc.Save(fileDir);
  14142. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14143. return Ok(JsonView(true, "操作成功!", Url));
  14144. }
  14145. else
  14146. {
  14147. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  14148. }
  14149. }
  14150. else
  14151. {
  14152. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  14153. }
  14154. }
  14155. catch (Exception ex)
  14156. {
  14157. return Ok(JsonView(false, ex.Message));
  14158. }
  14159. }
  14160. /// <summary>
  14161. /// 酒店预订
  14162. /// 生成VOUCHER
  14163. /// 2024.05.06 之后版本
  14164. /// </summary>
  14165. /// <param name="_dto"></param>
  14166. /// <returns></returns>
  14167. [HttpPost]
  14168. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14169. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  14170. {
  14171. #region 参数验证
  14172. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14173. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  14174. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14175. #region 团组操作权限验证 76 酒店预定模块
  14176. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14177. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14178. #endregion
  14179. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14180. #region 页面操作权限验证
  14181. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14182. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14183. #endregion
  14184. #endregion
  14185. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  14186. //判断数据是否完整
  14187. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14188. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14189. string strFileName = "HotelStatement/";
  14190. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14191. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  14192. #region 数据处理
  14193. List<int> guestIds = new List<int>();
  14194. int index = 0;
  14195. foreach (var item in hrDtas)
  14196. {
  14197. if (item.GuestName.Contains(","))
  14198. {
  14199. string[] guestIdArr = item.GuestName.Split(',');
  14200. foreach (var guestIdStr in guestIdArr)
  14201. {
  14202. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  14203. if (guestBool)
  14204. {
  14205. guestIds.Add(guestId);
  14206. }
  14207. }
  14208. }
  14209. else guestNames += item.GuestName;
  14210. var voucherInfo = new HotelVoucherInfoView()
  14211. {
  14212. HotelName = item.HotelName,
  14213. CheckInDate = item.CheckInDate,
  14214. CheckOutDate = item.CheckOutDate,
  14215. ConfirmationNumber = item.DetermineNo.Trim(),
  14216. RoomType = item.RoomExplanation
  14217. };
  14218. vouchers.Add(voucherInfo);
  14219. }
  14220. if (guestIds.Count > 0)
  14221. {
  14222. guestIds = guestIds.Distinct().ToList();
  14223. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  14224. if (guestDatas.Count > 0)
  14225. {
  14226. guestNames = "";
  14227. foreach (var guest in guestDatas)
  14228. {
  14229. string guestName = "";
  14230. if (guest.Sex == 0) guestName += @"MR.";
  14231. else if (guest.Sex == 1) guestName += @"MS.";
  14232. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14233. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14234. guestNames += @$"{guestName.Trim()}、";
  14235. }
  14236. if (guestNames.Length > 0)
  14237. {
  14238. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14239. }
  14240. }
  14241. }
  14242. #endregion
  14243. //载入模板
  14244. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  14245. Document doc = new Document(sss);
  14246. DocumentBuilder builder = new DocumentBuilder(doc);
  14247. if (doc.Range.Bookmarks["GuestName"] != null)
  14248. {
  14249. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  14250. mark.Text = guestNames;
  14251. }
  14252. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  14253. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  14254. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  14255. for (int i = 1; i <= vouchers.Count; i++)
  14256. {
  14257. HotelVoucherInfoView hviv = vouchers[i - 1];
  14258. builder.MoveToCell(0, i, 0, 0);
  14259. builder.Write(hviv.HotelName);
  14260. builder.MoveToCell(0, i, 1, 0);
  14261. builder.Write(hviv.CheckInDate);
  14262. builder.MoveToCell(0, i, 2, 0);
  14263. builder.Write(hviv.CheckOutDate);
  14264. builder.MoveToCell(0, i, 3, 0);
  14265. builder.Write(hviv.RoomType);
  14266. builder.MoveToCell(0, i, 4, 0);
  14267. builder.Write(hviv.ConfirmationNumber);
  14268. }
  14269. //删除多余行
  14270. int currRowIndex = vouchers.Count + 1;
  14271. int delRows = 21 - currRowIndex;
  14272. if (delRows > 0)
  14273. {
  14274. for (int i = 0; i < delRows; i++)
  14275. {
  14276. table.Rows.RemoveAt(currRowIndex);
  14277. //cultivateRowIndex++;
  14278. }
  14279. }
  14280. strFileName += "VOUCHER.docx";
  14281. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14282. doc.Save(fileDir);
  14283. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14284. return Ok(JsonView(true, "操作成功!", Url));
  14285. }
  14286. /// <summary>
  14287. /// 酒店预订
  14288. /// 生成VOUCHER 批量生成
  14289. /// New
  14290. /// </summary>
  14291. /// <param name="_dto"></param>
  14292. /// <returns></returns>
  14293. [HttpPost]
  14294. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14295. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  14296. {
  14297. #region 参数验证
  14298. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  14299. if (_dto.PageId < 1) _dto.PageId = 28;
  14300. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  14301. #region 团组操作权限验证 76 酒店预定模块
  14302. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14303. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  14304. #endregion
  14305. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14306. #region 页面操作权限验证
  14307. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14308. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14309. #endregion
  14310. #endregion
  14311. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  14312. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  14313. .OrderBy(x => x.CheckInDate)
  14314. .ToListAsync();
  14315. //判断数据是否完整
  14316. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  14317. string strFileName = "HotelStatement/";
  14318. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  14319. if (dele != null)
  14320. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  14321. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  14322. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  14323. .Where(it => it.IsDel == 0)
  14324. .ToListAsync();
  14325. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  14326. for (int i = 0; i < hrDtas.Count; i++)
  14327. {
  14328. string guestNames = string.Empty;
  14329. List<int> guestIds = new List<int>();
  14330. var item = hrDtas[i];
  14331. //处理客户姓名
  14332. if (item.GuestName.Contains(","))
  14333. {
  14334. string[] guestIdArr = item.GuestName.Split(',');
  14335. foreach (var guestIdStr in guestIdArr)
  14336. if (int.TryParse(guestIdStr, out int guestId))
  14337. guestIds.Add(guestId);
  14338. }
  14339. else
  14340. {
  14341. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  14342. if (guestIdBool)
  14343. {
  14344. guestIds.Add(guestId);
  14345. }
  14346. //NaN
  14347. if (item.GuestName.Contains("NaN"))
  14348. {
  14349. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  14350. }
  14351. }
  14352. if (guestIds.Count > 0)
  14353. {
  14354. guestIds = guestIds.Distinct().ToList();
  14355. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  14356. if (guestDatas1.Count > 0)
  14357. {
  14358. guestNames = "";
  14359. foreach (var guest in guestDatas1)
  14360. {
  14361. string guestName = "";
  14362. if (guest.Sex == 0) guestName += @"MR.";
  14363. else if (guest.Sex == 1) guestName += @"MS.";
  14364. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  14365. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  14366. guestNames += @$"{guestName.Trim()}、";
  14367. }
  14368. if (guestNames.Length > 0)
  14369. {
  14370. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  14371. }
  14372. }
  14373. }
  14374. //if (!string.IsNullOrEmpty(guestNames))
  14375. //{
  14376. hrDtas[i].GuestName = guestNames;
  14377. //}
  14378. }
  14379. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  14380. Document doc = new Document();
  14381. DocumentBuilder builder = new DocumentBuilder(doc);
  14382. try
  14383. {
  14384. builder.MoveToDocumentStart();
  14385. foreach (var item in hrDtas)
  14386. {
  14387. //标题
  14388. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14389. builder.ParagraphFormat.LineSpacing = 1;
  14390. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14391. builder.ParagraphFormat.Style.Font.Size = 9;
  14392. builder.ParagraphFormat.Style.Font.Bold = true;
  14393. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14394. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  14395. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  14396. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  14397. builder.ParagraphFormat.LineSpacing = 1;
  14398. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14399. builder.ParagraphFormat.Style.Font.Size = 9;
  14400. builder.ParagraphFormat.Style.Font.Bold = true;
  14401. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  14402. builder.StartTable();
  14403. // 设置边框颜色
  14404. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  14405. //设置边框样式
  14406. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  14407. //表格
  14408. #region 第一行
  14409. builder.InsertCell();
  14410. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14411. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14412. //builder.CellFormat.AllowAutoFit = false;
  14413. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14414. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14415. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14416. builder.CellFormat.WrapText = true; //自动换行
  14417. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14418. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  14419. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14420. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14421. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14422. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14423. builder.Write("TOUR NO:");
  14424. builder.InsertCell();
  14425. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14426. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14427. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14428. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14429. builder.ParagraphFormat.Style.Font.Bold = false;
  14430. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14431. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14432. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14433. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14434. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14435. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14436. builder.Write($"{dele?.TourCode ?? "-"}");
  14437. builder.InsertCell();
  14438. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14439. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14440. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14441. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14442. builder.ParagraphFormat.Style.Font.Bold = false;
  14443. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14444. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14445. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14446. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14447. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14448. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14449. builder.Write($"CITY:");
  14450. builder.InsertCell();
  14451. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14452. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14453. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14454. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14455. builder.ParagraphFormat.Style.Font.Bold = false;
  14456. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14457. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14458. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14459. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14460. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14461. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14462. builder.Write($"{item.City}");
  14463. builder.EndRow();
  14464. #endregion
  14465. #region 第二行
  14466. builder.InsertCell();
  14467. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14468. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14469. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14470. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14471. builder.ParagraphFormat.Style.Font.Bold = false;
  14472. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14473. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14474. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14475. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14476. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14477. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14478. builder.Write("CONFIRMATION NO:");
  14479. builder.InsertCell();
  14480. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14481. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14482. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14483. builder.ParagraphFormat.Style.Font.Bold = false;
  14484. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14485. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14486. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14487. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14488. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14489. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14490. builder.CellFormat.VerticalMerge = CellMerge.None;
  14491. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14492. builder.Write($"{item.DetermineNo}");
  14493. builder.InsertCell();
  14494. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14495. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14496. builder.InsertCell();
  14497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14498. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14499. builder.EndRow();
  14500. #endregion
  14501. #region 第三行
  14502. builder.InsertCell();
  14503. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14504. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14505. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14506. builder.ParagraphFormat.Style.Font.Bold = false;
  14507. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14508. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14509. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14510. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14511. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14512. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14513. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14514. builder.Write($"HOTEL NAME:");
  14515. builder.InsertCell();
  14516. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14519. builder.ParagraphFormat.Style.Font.Bold = false;
  14520. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14521. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14522. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14523. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14524. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14525. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14526. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14527. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14528. builder.Write($"{item.HotelName}");
  14529. builder.InsertCell();
  14530. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14531. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14532. builder.InsertCell();
  14533. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14534. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14535. builder.EndRow();
  14536. #endregion
  14537. #region 第四行
  14538. builder.InsertCell();
  14539. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14540. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14541. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14542. builder.ParagraphFormat.Style.Font.Bold = false;
  14543. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14544. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14545. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14546. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14547. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14548. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14549. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14550. builder.Write($"HOTEL ADDRESS:");
  14551. builder.InsertCell();
  14552. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14553. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14554. builder.ParagraphFormat.Style.Font.Size = 8;
  14555. builder.ParagraphFormat.Style.Font.Bold = false;
  14556. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14557. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14558. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14559. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14560. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14561. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14562. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14563. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14564. builder.Write($"{item.HotelAddress}");
  14565. builder.InsertCell();
  14566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14567. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14568. builder.InsertCell();
  14569. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14570. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14571. builder.EndRow();
  14572. #endregion
  14573. #region 第五行
  14574. builder.InsertCell();
  14575. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14576. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14577. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14578. builder.ParagraphFormat.Style.Font.Bold = false;
  14579. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14580. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14581. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14582. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14583. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14584. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14585. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14586. builder.Write("TEL:");
  14587. builder.InsertCell();
  14588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14589. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14590. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14591. builder.ParagraphFormat.Style.Font.Bold = false;
  14592. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14593. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14594. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14595. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14596. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14597. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14598. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14599. builder.Write($"{item.HotelTel}");
  14600. builder.InsertCell();
  14601. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14602. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14603. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14604. builder.ParagraphFormat.Style.Font.Bold = false;
  14605. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14606. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14607. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14608. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14609. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14610. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14611. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14612. builder.Write($"FAX:");
  14613. builder.InsertCell();
  14614. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14615. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14616. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14617. builder.ParagraphFormat.Style.Font.Bold = false;
  14618. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14619. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14620. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14621. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14622. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14623. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14624. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14625. builder.Write($"{item.HotelFax}");
  14626. builder.EndRow();
  14627. #endregion
  14628. #region 第六行
  14629. builder.InsertCell();
  14630. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14631. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14632. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14633. builder.ParagraphFormat.Style.Font.Bold = false;
  14634. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14635. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14636. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14637. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14638. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14639. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14640. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14641. builder.Write("CHECK IN:");
  14642. builder.InsertCell();
  14643. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14644. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14645. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14646. builder.ParagraphFormat.Style.Font.Bold = false;
  14647. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14648. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14649. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14650. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14651. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14652. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14653. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14654. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  14655. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  14656. builder.Write($"{checkInStr}");
  14657. builder.InsertCell();
  14658. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14659. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14660. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14661. builder.ParagraphFormat.Style.Font.Bold = false;
  14662. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14663. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14664. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14665. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14666. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14667. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14668. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14669. builder.Write($"CHECK OUT:");
  14670. builder.InsertCell();
  14671. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14672. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14673. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14674. builder.ParagraphFormat.Style.Font.Bold = false;
  14675. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14676. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14677. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14678. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14679. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14680. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14681. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14682. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  14683. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  14684. builder.Write($"{checkOutStr}");
  14685. builder.EndRow();
  14686. #endregion
  14687. #region 第七行
  14688. builder.InsertCell();
  14689. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14690. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14691. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14692. builder.ParagraphFormat.Style.Font.Bold = false;
  14693. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14694. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14695. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14696. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14697. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14698. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14699. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14700. builder.Write($"GUEST NAME:");
  14701. builder.InsertCell();
  14702. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14703. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14704. builder.ParagraphFormat.Style.Font.Size = 8;
  14705. builder.ParagraphFormat.Style.Font.Bold = false;
  14706. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14707. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14708. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14709. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14710. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14711. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14712. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14713. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14714. builder.Write($"{item.GuestName}");
  14715. builder.InsertCell();
  14716. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14717. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14718. builder.InsertCell();
  14719. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14720. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14721. builder.EndRow();
  14722. #endregion
  14723. #region 第八行
  14724. builder.InsertCell();
  14725. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14726. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14727. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14728. builder.ParagraphFormat.Style.Font.Bold = false;
  14729. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14730. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14731. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14732. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14733. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14734. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14735. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14736. builder.Write($"ROOM TYPE:");
  14737. builder.InsertCell();
  14738. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14739. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14740. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14741. builder.ParagraphFormat.Style.Font.Bold = false;
  14742. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14743. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14744. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14745. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14746. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14747. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14748. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14749. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14750. builder.Write($"{item.RoomExplanation}");
  14751. builder.InsertCell();
  14752. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14753. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14754. builder.InsertCell();
  14755. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14756. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14757. builder.EndRow();
  14758. #endregion
  14759. #region 第九行
  14760. builder.InsertCell();
  14761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14762. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14763. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14764. builder.ParagraphFormat.Style.Font.Bold = false;
  14765. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14766. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14767. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  14768. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  14769. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  14770. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  14771. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  14772. builder.Write($"NOTE:");
  14773. builder.InsertCell();
  14774. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14775. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  14776. builder.ParagraphFormat.Style.Font.Size = 7.5;
  14777. builder.ParagraphFormat.Style.Font.Bold = false;
  14778. builder.CellFormat.HorizontalMerge = CellMerge.None;
  14779. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  14780. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  14781. builder.CellFormat.HorizontalMerge = CellMerge.First;
  14782. 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.");
  14783. builder.InsertCell();
  14784. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  14785. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14786. builder.InsertCell();
  14787. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  14788. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  14789. builder.EndRow();
  14790. #endregion
  14791. builder.EndTable();
  14792. //换行
  14793. builder.Writeln("");
  14794. builder.Writeln("");
  14795. }
  14796. #region 获取文档中的所有表格 设置文字自适应
  14797. // 获取文档中的所有表格。
  14798. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  14799. {
  14800. // 遍历表格中的所有行。
  14801. foreach (Aspose.Words.Tables.Row row in table.Rows)
  14802. {
  14803. foreach (Cell cell in row.Cells)
  14804. {
  14805. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  14806. cellFormat.Width = 0;
  14807. }
  14808. }
  14809. }
  14810. #endregion
  14811. #region 设置页眉
  14812. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  14813. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  14814. if (System.IO.File.Exists(voucherHeaderPath))
  14815. {
  14816. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  14817. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  14818. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  14819. Shape shape = builder.InsertImage(imageBytes);
  14820. // 调整图片位置
  14821. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  14822. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  14823. shape.Top = 50; // 将图片距离页眉上边缘的距离
  14824. shape.Left = 0; // 将图片距离页面左边缘的距离
  14825. shape.Width = 81; // 设置图片宽度
  14826. shape.Height = 36; // 设置图片高度
  14827. }
  14828. //靠右
  14829. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  14830. //// 设置页脚上下边距
  14831. //builder.PageSetup.HeaderDistance = 42;
  14832. // 添加页眉线
  14833. Aspose.Words.Border borderHeader = null;
  14834. try
  14835. {
  14836. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  14837. }
  14838. catch (Exception e)
  14839. {
  14840. // TODO Auto-generated catch block
  14841. //e.printStackTrace();
  14842. }
  14843. borderHeader.Shadow = true;
  14844. borderHeader.DistanceFromText = 2;
  14845. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  14846. #endregion
  14847. }
  14848. catch (Exception ex)
  14849. {
  14850. }
  14851. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  14852. doc.Save(fileDir);
  14853. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  14854. return Ok(JsonView(true, "操作成功!", Url));
  14855. }
  14856. /// <summary>
  14857. /// 酒店预订
  14858. /// 生成 预定成本 Excel
  14859. /// </summary>
  14860. /// <param name="_dto"></param>
  14861. /// <returns></returns>
  14862. [HttpPost]
  14863. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14864. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  14865. {
  14866. #region 参数验证
  14867. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  14868. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  14869. if (!vadalitorRes.IsValid)
  14870. {
  14871. var errors = new StringBuilder();
  14872. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  14873. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  14874. }
  14875. #region 团组操作权限验证 76 酒店预定模块
  14876. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  14877. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  14878. #endregion
  14879. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  14880. #region 页面操作权限验证
  14881. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  14882. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  14883. #endregion
  14884. #endregion
  14885. decimal _rate = 1.00M;
  14886. string _currency = string.Empty;
  14887. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  14888. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14889. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  14890. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  14891. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  14892. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  14893. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  14894. if (_GroupCostParameter == null)
  14895. {
  14896. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  14897. bool isIntType = int.TryParse(_currency, out int currId);
  14898. if (isIntType)
  14899. {
  14900. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  14901. }
  14902. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  14903. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  14904. if (currInfo == null)
  14905. {
  14906. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  14907. }
  14908. else _rate = currInfo.Rate;
  14909. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  14910. {
  14911. _rate = _GroupCostParameter.Rate;
  14912. }
  14913. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  14914. string strFileName = "HotelStatement/";
  14915. string guestNames = ""; //格式Mr.xxx Ms.xxx
  14916. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  14917. var rateDatas = new List<dynamic>();
  14918. #region 数据处理
  14919. foreach (var item in hrDtas)
  14920. {
  14921. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  14922. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  14923. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  14924. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  14925. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  14926. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  14927. {
  14928. continue;
  14929. }
  14930. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  14931. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  14932. string singleRoomFeeStr = string.Empty,
  14933. doubleRoomFeeStr = string.Empty,
  14934. suiteRoomFeeStr = string.Empty,
  14935. otherRoomFeeStr = string.Empty,
  14936. payMoneyStr = string.Empty,
  14937. cardPriceStr = string.Empty;
  14938. if (roomCurr.Equals("CNY"))
  14939. {
  14940. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  14941. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  14942. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  14943. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  14944. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  14945. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  14946. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  14947. }
  14948. else
  14949. {
  14950. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  14951. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  14952. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  14953. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  14954. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  14955. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  14956. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  14957. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  14958. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  14959. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  14960. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  14961. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  14962. if (ccpPaymentCurrency.Equals("CNY"))
  14963. {
  14964. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  14965. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  14966. }
  14967. else
  14968. {
  14969. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  14970. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  14971. }
  14972. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  14973. if (hotelcardPriceCurrency.Equals("CNY"))
  14974. {
  14975. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  14976. }
  14977. else
  14978. {
  14979. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  14980. }
  14981. }
  14982. string breakfastPriceStr = string.Empty,
  14983. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  14984. governmentRentStr = string.Empty,
  14985. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  14986. cityTaxStr = string.Empty,
  14987. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  14988. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  14989. if (!string.IsNullOrEmpty(breakfastCurrency1))
  14990. {
  14991. if (breakfastCurrency1.Equals("CNY"))
  14992. {
  14993. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  14994. }
  14995. else
  14996. {
  14997. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  14998. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  14999. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  15000. }
  15001. }
  15002. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  15003. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  15004. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  15005. {
  15006. if (governmentRentCurrency.Equals("CNY"))
  15007. {
  15008. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15009. }
  15010. else
  15011. {
  15012. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  15013. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  15014. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  15015. }
  15016. }
  15017. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  15018. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  15019. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  15020. {
  15021. if (cityTaxStrCurrency1.Equals("CNY"))
  15022. {
  15023. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15024. }
  15025. else
  15026. {
  15027. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  15028. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  15029. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  15030. }
  15031. }
  15032. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  15033. int payDId = roomInfo?.PayDId ?? 0;
  15034. pcfds.Add(new HotelReservations_PCFD_View()
  15035. {
  15036. City = item.City,
  15037. HotelName = item.HotelName,
  15038. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15039. // SingleRoomCount = item.SingleRoomCount,
  15040. SingleRoomPrice = singleRoomFeeStr,
  15041. // DoubleRoomCount = item.DoubleRoomCount,
  15042. DoubleRoomPrice = doubleRoomFeeStr,
  15043. //SuiteRoomCount = item.SuiteRoomCount,
  15044. SuiteRoomPrice = suiteRoomFeeStr,
  15045. OtherRoomPrice = otherRoomFeeStr,
  15046. //OtherRoomCount = item.OtherRoomCount,
  15047. BreakfastPrice = breakfastPriceStr,
  15048. GovernmentRent = governmentRentStr,
  15049. CityTax = cityTaxStr,
  15050. RoomExplanation = item.RoomExplanation,
  15051. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15052. PayTime = roomInfo?.ConsumptionDate,
  15053. BankNo = roomInfo?.BankNo,
  15054. PayMoney = payMoneyStr,
  15055. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15056. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15057. CardPrice = cardPriceStr,
  15058. Remark = ccpInfo.Remark
  15059. });
  15060. }
  15061. #endregion
  15062. //载入模板
  15063. WorkbookDesigner designer = new WorkbookDesigner();
  15064. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15065. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15066. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15067. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15068. var rateDatas1 = rateDatas.Distinct();
  15069. var rateStr = string.Empty;
  15070. foreach (var item in rateDatas1)
  15071. {
  15072. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  15073. }
  15074. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  15075. designer.SetDataSource("Opertor", userInfo.CnName);
  15076. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15077. dt.TableName = "ViewMyHotelReservations";
  15078. designer.SetDataSource(dt);
  15079. designer.Process();
  15080. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15081. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15082. designer.Workbook.Save(serverPath);
  15083. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15084. #region 删除指定行
  15085. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15086. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15087. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15088. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15089. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15090. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15091. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15092. cssIndex = dt.Columns["CityTax"].Ordinal,
  15093. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15094. remarkIndex = dt.Columns["Remark"].Ordinal;
  15095. //删除指定列
  15096. foreach (DataRow item in dt.Rows)
  15097. {
  15098. string singleStr = item["SingleRoomPrice"].ToString();
  15099. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15100. if (containsDigitButNotZero1) singleDel = false;
  15101. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15102. string doubleStr = item["DoubleRoomPrice"].ToString();
  15103. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15104. if (containsDigitButNotZero2) doubleDel = false;
  15105. string suiteStr = item["SuiteRoomPrice"].ToString();
  15106. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15107. if (containsDigitButNotZero3) suiteDel = false;
  15108. string otherStr = item["OtherRoomPrice"].ToString();
  15109. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15110. if (containsDigitButNotZero4) otherDel = false;
  15111. string zcStr = item["BreakfastPrice"].ToString();
  15112. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15113. if (containsDigitButNotZero5) zcDel = false;
  15114. string dsStr = item["GovernmentRent"].ToString();
  15115. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15116. if (containsDigitButNotZero6) dsDel = false;
  15117. string cssStr = item["CityTax"].ToString();
  15118. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15119. if (containsDigitButNotZero7) cssDel = false;
  15120. string cpStr = item["ConsumptionPatterns"].ToString();
  15121. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15122. string remarkStr = item["Remark"].ToString();
  15123. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15124. }
  15125. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15126. DeleteColumn(serverPath, cpIndex, cpDel);
  15127. DeleteColumn(serverPath, dsIndex, dsDel);
  15128. DeleteColumn(serverPath, cssIndex, cssDel);
  15129. DeleteColumn(serverPath, zcIndex, zcDel);
  15130. DeleteColumn(serverPath, otherIndex, otherDel);
  15131. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15132. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15133. DeleteColumn(serverPath, singleIndex, singleDel);
  15134. #endregion
  15135. //只保留第一个表格
  15136. DeleteSheet(serverPath);
  15137. return Ok(JsonView(true, "操作成功", url = rst));
  15138. }
  15139. else
  15140. {
  15141. _currency = _GroupCostParameter.Currency;
  15142. bool isIntType = int.TryParse(_currency, out int currId);
  15143. if (isIntType)
  15144. {
  15145. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  15146. }
  15147. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  15148. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  15149. if (currInfo == null)
  15150. {
  15151. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  15152. }
  15153. if (!_currency.ToUpper().Equals("CNY"))
  15154. {
  15155. _rate = _GroupCostParameter.Rate;
  15156. }
  15157. _rate = currInfo.Rate;
  15158. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  15159. string strFileName = "HotelStatement/";
  15160. string guestNames = ""; //格式Mr.xxx Ms.xxx
  15161. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  15162. #region 数据处理
  15163. foreach (var item in hrDtas)
  15164. {
  15165. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  15166. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  15167. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  15168. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  15169. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  15170. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  15171. string singleRoomFeeStr = string.Empty,
  15172. doubleRoomFeeStr = string.Empty,
  15173. suiteRoomFeeStr = string.Empty,
  15174. otherRoomFeeStr = string.Empty,
  15175. payMoneyStr = string.Empty,
  15176. cardPriceStr = string.Empty;
  15177. if (roomCurr.Equals(_currency))
  15178. {
  15179. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  15180. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  15181. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  15182. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  15183. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  15184. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  15185. }
  15186. else
  15187. {
  15188. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  15189. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  15190. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  15191. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  15192. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  15193. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  15194. }
  15195. string breakfastPriceStr = string.Empty,
  15196. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  15197. governmentRentStr = string.Empty,
  15198. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  15199. cityTaxStrStr = string.Empty,
  15200. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  15201. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  15202. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  15203. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  15204. int payDId = roomInfo?.PayDId ?? 0;
  15205. pcfds.Add(new HotelReservations_PCFD_View()
  15206. {
  15207. City = item.City,
  15208. HotelName = item.HotelName,
  15209. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  15210. // SingleRoomCount = item.SingleRoomCount,
  15211. SingleRoomPrice = singleRoomFeeStr,
  15212. // DoubleRoomCount = item.DoubleRoomCount,
  15213. DoubleRoomPrice = doubleRoomFeeStr,
  15214. //SuiteRoomCount = item.SuiteRoomCount,
  15215. SuiteRoomPrice = suiteRoomFeeStr,
  15216. OtherRoomPrice = otherRoomFeeStr,
  15217. //OtherRoomCount = item.OtherRoomCount,
  15218. BreakfastPrice = breakfastPriceStr,
  15219. GovernmentRent = governmentRentStr,
  15220. CityTax = cityTaxStrStr,
  15221. RoomExplanation = item.RoomExplanation,
  15222. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  15223. PayTime = roomInfo?.ConsumptionDate,
  15224. BankNo = roomInfo?.BankNo,
  15225. PayMoney = payMoneyStr,
  15226. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  15227. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  15228. CardPrice = cardPriceStr,
  15229. Remark = ccpInfo.Remark
  15230. });
  15231. }
  15232. #endregion
  15233. //载入模板
  15234. WorkbookDesigner designer = new WorkbookDesigner();
  15235. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  15236. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  15237. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  15238. designer.SetDataSource("TourNo", groupInfo.TourCode);
  15239. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  15240. designer.SetDataSource("Opertor", userInfo.CnName);
  15241. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  15242. dt.TableName = "ViewMyHotelReservations";
  15243. designer.SetDataSource(dt);
  15244. designer.Process();
  15245. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  15246. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  15247. designer.Workbook.Save(serverPath);
  15248. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  15249. #region 删除指定行
  15250. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  15251. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  15252. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  15253. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  15254. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  15255. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  15256. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  15257. cssIndex = dt.Columns["CityTax"].Ordinal,
  15258. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  15259. remarkIndex = dt.Columns["Remark"].Ordinal;
  15260. //删除指定列
  15261. foreach (DataRow item in dt.Rows)
  15262. {
  15263. string singleStr = item["SingleRoomPrice"].ToString();
  15264. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  15265. if (containsDigitButNotZero1) singleDel = false;
  15266. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  15267. string doubleStr = item["DoubleRoomPrice"].ToString();
  15268. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15269. if (containsDigitButNotZero2) doubleDel = false;
  15270. string suiteStr = item["SuiteRoomPrice"].ToString();
  15271. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  15272. if (containsDigitButNotZero3) suiteDel = false;
  15273. string otherStr = item["OtherRoomPrice"].ToString();
  15274. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  15275. if (containsDigitButNotZero4) otherDel = false;
  15276. string zcStr = item["BreakfastPrice"].ToString();
  15277. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  15278. if (containsDigitButNotZero5) zcDel = false;
  15279. string dsStr = item["GovernmentRent"].ToString();
  15280. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  15281. if (containsDigitButNotZero6) dsDel = false;
  15282. string cssStr = item["CityTax"].ToString();
  15283. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  15284. if (containsDigitButNotZero7) cssDel = false;
  15285. string cpStr = item["ConsumptionPatterns"].ToString();
  15286. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  15287. string remarkStr = item["Remark"].ToString();
  15288. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  15289. }
  15290. DeleteColumn(serverPath, remarkIndex, remarkDel);
  15291. DeleteColumn(serverPath, cpIndex, cpDel);
  15292. DeleteColumn(serverPath, dsIndex, dsDel);
  15293. DeleteColumn(serverPath, cssIndex, cssDel);
  15294. DeleteColumn(serverPath, zcIndex, zcDel);
  15295. DeleteColumn(serverPath, otherIndex, otherDel);
  15296. DeleteColumn(serverPath, suiteIndex, suiteDel);
  15297. DeleteColumn(serverPath, doubleIndex, doubleDel);
  15298. DeleteColumn(serverPath, singleIndex, singleDel);
  15299. #endregion
  15300. //只保留第一个表格
  15301. DeleteSheet(serverPath);
  15302. return Ok(JsonView(true, "操作成功", url = rst));
  15303. }
  15304. return Ok(JsonView(false));
  15305. }
  15306. /// <summary>
  15307. /// 删除指定列
  15308. /// </summary>
  15309. /// <param name="file"></param>
  15310. /// <param name="columnIndex"></param>
  15311. /// <param name="isDel"></param>
  15312. private void DeleteColumn(string file, int columnIndex, bool isDel)
  15313. {
  15314. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15315. //wb.Save(file);
  15316. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  15317. if (sheet1 != null)
  15318. {
  15319. if (isDel)
  15320. {
  15321. Cells cells = sheet1.Cells;
  15322. cells.DeleteColumn(columnIndex);
  15323. }
  15324. }
  15325. wb.Save(file);
  15326. }
  15327. /// <summary>
  15328. /// 删除sheet
  15329. /// </summary>
  15330. /// <param name="file"></param>
  15331. /// <param name="sheetName"></param>
  15332. private void DeleteSheet(string file, string sheetName = "")
  15333. {
  15334. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  15335. //wb.Save(file);
  15336. List<string> sheets = new List<string>();
  15337. foreach (var item in wb.Worksheets)
  15338. {
  15339. sheets.Add(item.Name);
  15340. }
  15341. if (sheets.Count > 0)
  15342. {
  15343. sheets.RemoveAt(0);//不删除第一个sheet
  15344. foreach (var item in sheets)
  15345. {
  15346. wb.Worksheets.RemoveAt(item);
  15347. }
  15348. }
  15349. wb.Save(file);
  15350. }
  15351. /// <summary>
  15352. /// 酒店预订
  15353. /// 确认单
  15354. /// </summary>
  15355. /// <param name="_dto"></param>
  15356. /// <returns></returns>
  15357. [HttpPost]
  15358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15359. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  15360. {
  15361. try
  15362. {
  15363. #region 参数验证
  15364. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  15365. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  15366. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  15367. #region 团组操作权限验证 76 酒店预定模块
  15368. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  15369. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  15370. #endregion
  15371. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15372. #region 页面操作权限验证
  15373. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15374. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  15375. #endregion
  15376. #endregion
  15377. //团组信息
  15378. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  15379. //酒店数据
  15380. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  15381. if (listhoteldata.Count < 0)
  15382. {
  15383. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  15384. }
  15385. //利datatable存储
  15386. DataTable dt = new DataTable();
  15387. dt.Columns.Add("CheckInDate", typeof(string));
  15388. dt.Columns.Add("City", typeof(string));
  15389. dt.Columns.Add("Hotel", typeof(string));
  15390. dt.Columns.Add("Room", typeof(string));
  15391. for (int i = 0; i < listhoteldata.Count; i++)
  15392. {
  15393. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  15394. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  15395. while (dayStart < dayEnd)
  15396. {
  15397. string temp = "";
  15398. DataRow row = dt.NewRow();
  15399. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  15400. row["City"] = listhoteldata[i].City;
  15401. row["Hotel"] = listhoteldata[i].HotelName;
  15402. if (listhoteldata[i].SingleRoomCount > 0)
  15403. {
  15404. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  15405. }
  15406. if (listhoteldata[i].DoubleRoomCount > 0)
  15407. {
  15408. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  15409. }
  15410. if (listhoteldata[i].SuiteRoomCount > 0)
  15411. {
  15412. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  15413. }
  15414. if (listhoteldata[i].OtherRoomCount > 0)
  15415. {
  15416. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  15417. }
  15418. row["Room"] = temp;
  15419. dt.Rows.Add(row);
  15420. dayStart = dayStart.AddDays(1);
  15421. }
  15422. }
  15423. Dictionary<string, string> dic = new Dictionary<string, string>();
  15424. dic.Add("Dele", di.TeamName);
  15425. dic.Add("City", di.VisitCountry);
  15426. //模板路径
  15427. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  15428. //载入模板
  15429. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  15430. DocumentBuilder builder = new DocumentBuilder(doc);
  15431. foreach (var key in dic.Keys)
  15432. {
  15433. builder.MoveToBookmark(key);
  15434. builder.Write(dic[key]);
  15435. }
  15436. //获取word里所有表格
  15437. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15438. //获取所填表格的序数
  15439. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15440. var rowStart = tableOne.Rows[0]; //获取第1行
  15441. //循环赋值
  15442. for (int i = 0; i < dt.Rows.Count; i++)
  15443. {
  15444. builder.MoveToCell(0, i + 1, 0, 0);
  15445. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  15446. builder.MoveToCell(0, i + 1, 1, 0);
  15447. builder.Write(dt.Rows[i]["City"].ToString());
  15448. builder.MoveToCell(0, i + 1, 2, 0);
  15449. builder.Write(dt.Rows[i]["Hotel"].ToString());
  15450. builder.MoveToCell(0, i + 1, 3, 0);
  15451. builder.Write(dt.Rows[i]["Room"].ToString());
  15452. }
  15453. //删除多余行
  15454. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  15455. {
  15456. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  15457. }
  15458. string strFileName = di.TeamName + "酒店确认单.doc";
  15459. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  15460. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  15461. return Ok(JsonView(true, "成功", url));
  15462. }
  15463. catch (Exception ex)
  15464. {
  15465. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  15466. }
  15467. }
  15468. #endregion
  15469. #region 团组状态
  15470. /// <summary>
  15471. /// 团组状态列表 Page
  15472. /// </summary>
  15473. /// <param name="dto">团组列表请求dto</param>
  15474. /// <returns></returns>
  15475. [HttpPost]
  15476. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15477. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  15478. {
  15479. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15480. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  15481. {
  15482. string sqlWhere = string.Empty;
  15483. if (dto.IsSure == 0) //未完成
  15484. {
  15485. sqlWhere += string.Format(@" And IsSure = 0");
  15486. }
  15487. else if (dto.IsSure == 1) //已完成
  15488. {
  15489. sqlWhere += string.Format(@" And IsSure = 1");
  15490. }
  15491. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  15492. {
  15493. string tj = dto.SearchCriteria;
  15494. 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}%')",
  15495. tj, tj, tj, tj, tj);
  15496. }
  15497. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  15498. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  15499. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  15500. From (
  15501. Select row_number() over(order by gdi.CreateTime Desc) as Row_Number,
  15502. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  15503. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  15504. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  15505. From Grp_DelegationInfo gdi
  15506. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  15507. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  15508. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  15509. Where gdi.IsDel = 0 {0}
  15510. ) temp ", sqlWhere);
  15511. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  15512. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  15513. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  15514. }
  15515. else
  15516. {
  15517. return Ok(JsonView(false, "查询失败"));
  15518. }
  15519. }
  15520. /// <summary>
  15521. /// 团组状态
  15522. /// 设置操作完成
  15523. /// </summary>
  15524. /// <param name="dto">团组列表请求dto</param>
  15525. /// <returns></returns>
  15526. [HttpPost]
  15527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15528. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  15529. {
  15530. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  15531. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  15532. {
  15533. Id = dto.Id,
  15534. IsSure = 1
  15535. };
  15536. var result = await _sqlSugar.Updateable(_DelegationInfo)
  15537. .UpdateColumns(it => new { it.IsSure })
  15538. .WhereColumns(it => new { it.Id })
  15539. .ExecuteCommandAsync();
  15540. if (result > 0)
  15541. {
  15542. return Ok(JsonView(true, "操作完成!"));
  15543. }
  15544. return Ok(JsonView(false, "操作失败!"));
  15545. }
  15546. #endregion
  15547. #region 保险费用录入
  15548. /// <summary>
  15549. /// 根据团组Id查询保险费用列表
  15550. /// </summary>
  15551. /// <param name="dto"></param>
  15552. /// <returns></returns>
  15553. [HttpPost]
  15554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15555. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  15556. {
  15557. Result groupData = await _customersRep.CustomersByDiId(dto);
  15558. if (groupData.Code != 0)
  15559. {
  15560. return Ok(JsonView(false, groupData.Msg));
  15561. }
  15562. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15563. }
  15564. /// <summary>
  15565. /// 根据保险费用Id查询保险费用详细
  15566. /// </summary>
  15567. /// <param name="dto"></param>
  15568. /// <returns></returns>
  15569. [HttpPost]
  15570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15571. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  15572. {
  15573. try
  15574. {
  15575. Result groupData = await _customersRep.CustomersById(dto);
  15576. if (groupData.Code != 0)
  15577. {
  15578. return Ok(JsonView(false, groupData.Msg));
  15579. }
  15580. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15581. }
  15582. catch (Exception ex)
  15583. {
  15584. return Ok(JsonView(false, ex.Message));
  15585. }
  15586. }
  15587. /// <summary>
  15588. /// 保险费用录入页面初始化绑定
  15589. /// </summary>
  15590. /// <param name="dto"></param>
  15591. /// <returns></returns>
  15592. [HttpPost]
  15593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15594. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  15595. {
  15596. try
  15597. {
  15598. Result groupData = await _customersRep.CustomersInitialize(dto);
  15599. if (groupData.Code != 0)
  15600. {
  15601. return Ok(JsonView(false, groupData.Msg));
  15602. }
  15603. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15604. }
  15605. catch (Exception ex)
  15606. {
  15607. return Ok(JsonView(false, ex.Message));
  15608. }
  15609. }
  15610. /// <summary>
  15611. /// 保险费用操作(Status:1.新增,2.修改)
  15612. /// </summary>
  15613. /// <param name="dto"></param>
  15614. /// <returns></returns>
  15615. [HttpPost]
  15616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15617. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  15618. {
  15619. Result groupData = await _customersRep.OpCustomers(dto);
  15620. if (groupData.Code != 0)
  15621. {
  15622. return Ok(JsonView(false, groupData.Msg));
  15623. }
  15624. #region 应用推送
  15625. try
  15626. {
  15627. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15628. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15629. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  15630. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15631. //自动审核
  15632. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  15633. //2024-10-21 新增LZ UID
  15634. var userIds = new List<int>() { 21 };
  15635. string title = $"系统通知";
  15636. var diId = dto.DiId;
  15637. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15638. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15639. string content = "";
  15640. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15641. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  15642. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15643. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21" };
  15644. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15645. }
  15646. catch (Exception ex)
  15647. {
  15648. }
  15649. #endregion
  15650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15651. }
  15652. /// <summary>
  15653. /// 保险文件上传
  15654. /// </summary>
  15655. /// <param name="file"></param>
  15656. /// <returns></returns>
  15657. [HttpPost]
  15658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15659. public async Task<IActionResult> UploadCus(IFormFile file)
  15660. {
  15661. try
  15662. {
  15663. if (file != null)
  15664. {
  15665. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15666. //文件名称
  15667. string projectFileName = file.FileName;
  15668. //上传的文件的路径
  15669. string filePath = "";
  15670. if (!Directory.Exists(fileDir))
  15671. {
  15672. Directory.CreateDirectory(fileDir);
  15673. }
  15674. //上传的文件的路径
  15675. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  15676. using (FileStream fs = System.IO.File.Create(filePath))
  15677. {
  15678. file.CopyTo(fs);
  15679. fs.Flush();
  15680. }
  15681. return Ok(JsonView(true, "上传成功!", projectFileName));
  15682. }
  15683. else
  15684. {
  15685. return Ok(JsonView(false, "上传失败!"));
  15686. }
  15687. }
  15688. catch (Exception ex)
  15689. {
  15690. return Ok(JsonView(false, "程序错误!"));
  15691. throw;
  15692. }
  15693. }
  15694. /// <summary>
  15695. /// 保险删除指定文件
  15696. /// </summary>
  15697. /// <param name="dto"></param>
  15698. /// <returns></returns>
  15699. [HttpPost]
  15700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15701. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  15702. {
  15703. try
  15704. {
  15705. string filePath = "";
  15706. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  15707. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  15708. //int id = 0;
  15709. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  15710. // 删除该文件
  15711. try
  15712. {
  15713. System.IO.File.Delete(filePath);
  15714. 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()
  15715. {
  15716. Attachment = "",
  15717. }).ExecuteCommandAsync();
  15718. if (result != 0)
  15719. {
  15720. return Ok(JsonView(true, "成功!"));
  15721. }
  15722. else
  15723. {
  15724. return Ok(JsonView(false, "失败!"));
  15725. }
  15726. }
  15727. catch (Exception)
  15728. {
  15729. 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()
  15730. {
  15731. Attachment = "",
  15732. }).ExecuteCommandAsync();
  15733. if (result != 0)
  15734. {
  15735. return Ok(JsonView(true, "成功!"));
  15736. }
  15737. else
  15738. {
  15739. return Ok(JsonView(false, "失败!"));
  15740. }
  15741. }
  15742. }
  15743. catch (Exception ex)
  15744. {
  15745. return Ok(JsonView(false, "程序错误!"));
  15746. throw;
  15747. }
  15748. }
  15749. /// <summary>
  15750. /// 保险费用操作(删除)
  15751. /// </summary>
  15752. /// <param name="dto"></param>
  15753. /// <returns></returns>
  15754. [HttpPost]
  15755. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15756. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  15757. {
  15758. try
  15759. {
  15760. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  15761. if (!res)
  15762. {
  15763. return Ok(JsonView(false, "删除失败"));
  15764. }
  15765. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  15766. {
  15767. IsDel = 1,
  15768. DeleteUserId = dto.DeleteUserId,
  15769. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15770. }).ExecuteCommandAsync();
  15771. return Ok(JsonView(true, "删除成功!"));
  15772. }
  15773. catch (Exception ex)
  15774. {
  15775. return Ok(JsonView(false, "程序错误!"));
  15776. throw;
  15777. }
  15778. }
  15779. #endregion
  15780. #region 接团客户名单 PageId 104
  15781. /// <summary>
  15782. /// 接团客户名单
  15783. /// 迁移数据(慎用!)
  15784. /// </summary>
  15785. /// <param name="dto"></param>
  15786. /// <returns></returns>
  15787. [HttpPost]
  15788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15789. public async Task<IActionResult> PostTourClientListChange()
  15790. {
  15791. try
  15792. {
  15793. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  15794. //var groupClinetData1
  15795. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  15796. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  15797. int updateCount = 0;
  15798. if (oldOAClientList.Count > 0)
  15799. {
  15800. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  15801. _sqlSugar.BeginTran();
  15802. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  15803. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  15804. foreach (var item in oldOAClientList)
  15805. {
  15806. int comId = 0;
  15807. string format = "yyyy-MM-dd HH:mm:ss";
  15808. string data11 = "1990-01-01 00:00";
  15809. var data1 = IsValidDate(item.OPdate, format);
  15810. if (data1) data11 = item.OPdate;
  15811. //客户公司验证
  15812. if (!string.IsNullOrEmpty(item.Company))
  15813. {
  15814. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  15815. if (clientComInfo == null) // add
  15816. {
  15817. var addInfo = new Crm_CustomerCompany()
  15818. {
  15819. CompanyAbbreviation = "",
  15820. CompanyFullName = item.Company,
  15821. Address = "",
  15822. PostCodes = "",
  15823. LastedOpUserId = item.OPer,
  15824. LastedOpDt = Convert.ToDateTime(data11),
  15825. CreateUserId = item.OPer,
  15826. CreateTime = Convert.ToDateTime(data11),
  15827. IsDel = 0
  15828. };
  15829. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  15830. if (comId1 > 0) comId = comId1;
  15831. }
  15832. else comId = clientComInfo.Id;
  15833. }
  15834. //客户人员验证
  15835. int clientId = 0;
  15836. string name = item.LastName + item.Name;
  15837. if (!string.IsNullOrEmpty(name))
  15838. {
  15839. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  15840. if (clientInfo == null)
  15841. {
  15842. DateTime? dateTime = null;
  15843. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  15844. if (isDt) dateTime = birthDayDt;
  15845. var addInfo1 = new Crm_DeleClient()
  15846. {
  15847. CrmCompanyId = comId,
  15848. DiId = -1,
  15849. LastName = item.LastName,
  15850. FirstName = item.Name,
  15851. OldName = "",
  15852. Pinyin = item.Pinyin,
  15853. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  15854. Marriage = 0,
  15855. Phone = item.Phone,
  15856. Job = item.Job,
  15857. BirthDay = dateTime
  15858. };
  15859. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  15860. if (clientId1 > 0) clientId = clientId1;
  15861. }
  15862. else clientId = clientInfo.Id;
  15863. }
  15864. if (clientId < 1)
  15865. {
  15866. continue;
  15867. }
  15868. int airType = 0;
  15869. if (item.AirType == "超经舱") airType = 459;
  15870. else if (item.AirType == "公务舱") airType = 458;
  15871. else if (item.AirType == "经济舱") airType = 460;
  15872. else if (item.AirType == "其他") airType = 565;
  15873. else if (item.AirType == "头等舱") airType = 457;
  15874. var _TourClientListEntity = new Grp_TourClientList()
  15875. {
  15876. DiId = item.Diid,
  15877. ClientId = clientId,
  15878. CreateUserId = item.OPer,
  15879. CreateTime = Convert.ToDateTime(data11),
  15880. Remark = item.Remark,
  15881. IsDel = item.Isdel,
  15882. ShippingSpaceTypeId = airType,
  15883. ShippingSpaceSpecialNeeds = item.AirRemark,
  15884. HotelSpecialNeeds = item.RoomType
  15885. };
  15886. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  15887. if (_TourClientList > 0)
  15888. {
  15889. updateCount++;
  15890. }
  15891. }
  15892. _sqlSugar.CommitTran();
  15893. }
  15894. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  15895. }
  15896. catch (Exception ex)
  15897. {
  15898. _sqlSugar.RollbackTran();
  15899. return Ok(JsonView(false, ex.Message));
  15900. }
  15901. return Ok(JsonView(true));
  15902. }
  15903. private bool IsValidDate(string dateString, string format)
  15904. {
  15905. DateTime dateValue;
  15906. bool valid = DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateValue);
  15907. return valid;
  15908. }
  15909. /// <summary>
  15910. /// 接团客户名单
  15911. /// 根据团组Id查询List
  15912. /// </summary>
  15913. /// <param name="dto"></param>
  15914. /// <returns></returns>
  15915. [HttpPost]
  15916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15917. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  15918. {
  15919. #region 参数验证
  15920. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  15921. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  15922. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  15923. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15924. #region 页面操作权限验证
  15925. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15926. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15927. #endregion
  15928. #endregion
  15929. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  15930. if (viewData.Code != 0)
  15931. {
  15932. return Ok(JsonView(false, viewData.Msg));
  15933. }
  15934. return Ok(JsonView(viewData.Data));
  15935. }
  15936. /// <summary>
  15937. /// 接团客户名单
  15938. /// 基础数据 Init
  15939. /// </summary>
  15940. /// <param name="_dto"></param>
  15941. /// <returns></returns>
  15942. [HttpPost]
  15943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15944. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  15945. {
  15946. #region 参数验证
  15947. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  15948. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  15949. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15950. #region 页面操作权限验证
  15951. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15952. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15953. #endregion
  15954. #endregion
  15955. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  15956. }
  15957. /// <summary>
  15958. /// 接团客户名单
  15959. /// 根据 Id查询 Details
  15960. /// </summary>
  15961. /// <param name="_dto"></param>
  15962. /// <returns></returns>
  15963. [HttpPost]
  15964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15965. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  15966. {
  15967. #region 参数验证
  15968. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  15969. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  15970. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  15971. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15972. #region 页面操作权限验证
  15973. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  15974. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  15975. #endregion
  15976. #endregion
  15977. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  15978. if (viewData.Code != 0)
  15979. {
  15980. return Ok(JsonView(false, viewData.Msg));
  15981. }
  15982. return Ok(JsonView(viewData.Data));
  15983. }
  15984. /// <summary>
  15985. /// 接团客户名单
  15986. /// Add Or Edit
  15987. /// </summary>
  15988. /// <param name="_dto"></param>
  15989. /// <returns></returns>
  15990. [HttpPost]
  15991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15992. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  15993. {
  15994. #region 参数验证
  15995. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  15996. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  15997. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  15998. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  15999. #region 页面操作权限验证
  16000. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16001. if (_dto.Id == 0) //添加
  16002. {
  16003. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16004. }
  16005. else if (_dto.Id >= 0) //修改
  16006. {
  16007. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  16008. }
  16009. #endregion
  16010. #endregion
  16011. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  16012. if (viewData.Code != 0)
  16013. {
  16014. return Ok(JsonView(false, viewData.Msg));
  16015. }
  16016. return Ok(JsonView(true));
  16017. }
  16018. /// <summary>
  16019. /// 接团客户名单
  16020. /// json字符串 AddMultiple(添加多个)
  16021. /// </summary>
  16022. /// <param name="_dto"></param>
  16023. /// <returns></returns>
  16024. [HttpPost]
  16025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16026. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  16027. {
  16028. #region 参数验证
  16029. string jsonLabel = _dto.JsonLabel;
  16030. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16031. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16032. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16033. #region 页面操作权限验证
  16034. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16035. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16036. #endregion
  16037. #endregion
  16038. var request = new TourClientListAddMultipleDto();
  16039. request.DiId = _dto.DiId;
  16040. request.UserId = _dto.UserId;
  16041. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  16042. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  16043. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  16044. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  16045. var infos = new List<TourClientListInfo>();
  16046. foreach (var data in datas)
  16047. {
  16048. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  16049. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  16050. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  16051. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  16052. {
  16053. continue;
  16054. }
  16055. infos.Add(new TourClientListInfo() {
  16056. IsAccompany = 1,
  16057. LastName = lastName,
  16058. FirstName = firstName,
  16059. Pinyin = lastNameEn + @"/" + firstNameEn,
  16060. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女")? 1:2,
  16061. CompanyFullName = data.CompanyFullName,
  16062. Job = data.Job
  16063. });
  16064. }
  16065. if (infos.Any())
  16066. {
  16067. var viewData = await _tourClientListRep._AddMultiple(request);
  16068. if (viewData.Code != 0)
  16069. {
  16070. return Ok(JsonView(false, viewData.Msg));
  16071. }
  16072. return Ok(JsonView(true));
  16073. }
  16074. return Ok(JsonView(false));
  16075. }
  16076. /// <summary>
  16077. /// 接团客户名单
  16078. /// AddMultiple(添加多个)
  16079. /// </summary>
  16080. /// <param name="_dto"></param>
  16081. /// <returns></returns>
  16082. [HttpPost]
  16083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16084. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  16085. {
  16086. #region 参数验证
  16087. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16088. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16089. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16090. #region 页面操作权限验证
  16091. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16092. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  16093. #endregion
  16094. #endregion
  16095. var viewData = await _tourClientListRep._AddMultiple(_dto);
  16096. if (viewData.Code != 0)
  16097. {
  16098. return Ok(JsonView(false, viewData.Msg));
  16099. }
  16100. return Ok(JsonView(true));
  16101. }
  16102. /// <summary>
  16103. /// 接团客户名单
  16104. /// Del
  16105. /// </summary>
  16106. /// <param name="_dto"></param>
  16107. /// <returns></returns>
  16108. [HttpPost]
  16109. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16110. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  16111. {
  16112. #region 参数验证
  16113. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16114. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16115. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16116. #region 页面操作权限验证
  16117. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16118. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  16119. #endregion
  16120. #endregion
  16121. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  16122. if (viewData.Code != 0)
  16123. {
  16124. return Ok(JsonView(false, viewData.Msg));
  16125. }
  16126. return Ok(JsonView(true));
  16127. }
  16128. /// <summary>
  16129. /// 接团客户名单
  16130. /// 文件下载 客户名单
  16131. /// </summary>
  16132. /// <param name="_dto"></param>
  16133. /// <returns></returns>
  16134. [HttpPost]
  16135. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16136. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  16137. {
  16138. #region 参数验证
  16139. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  16140. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  16141. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  16142. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16143. #region 页面操作权限验证
  16144. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  16145. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  16146. #endregion
  16147. #endregion
  16148. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  16149. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  16150. From Grp_TourClientList tcl
  16151. Left Join
  16152. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  16153. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  16154. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  16155. From Crm_DeleClient dc
  16156. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  16157. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  16158. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  16159. Where dc.IsDel = 0) temp
  16160. On temp.DcId =tcl.ClientId
  16161. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  16162. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  16163. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  16164. //载入模板
  16165. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  16166. if (_dto.Language == 1)
  16167. {
  16168. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  16169. }
  16170. //载入模板
  16171. var doc = new Document(tempPath);
  16172. DocumentBuilder builder = new DocumentBuilder(doc);
  16173. //获取word里所有表格
  16174. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  16175. //获取所填表格的序数
  16176. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  16177. var rowStart = tableOne.Rows[0]; //获取第1行
  16178. if (_dto.Language == 0)
  16179. {
  16180. //循环赋值
  16181. for (int i = 0; i < DcList.Count; i++)
  16182. {
  16183. EncryptionProcessor.DecryptProperties(DcList[i]);
  16184. builder.MoveToCell(0, i + 1, 0, 0);
  16185. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  16186. builder.MoveToCell(0, i + 1, 1, 0);
  16187. int sex = DcList[i].Sex;
  16188. string sexStr = string.Empty;
  16189. if (sex == 0) sexStr = "男";
  16190. else if (sex == 1) sexStr = "女";
  16191. else sexStr = "未设置";
  16192. builder.Write(sexStr);
  16193. builder.MoveToCell(0, i + 1, 2, 0);
  16194. string birthDay = DcList[i].BirthDay;
  16195. string birthDayStr = string.Empty;
  16196. if (!string.IsNullOrEmpty(birthDay))
  16197. {
  16198. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  16199. }
  16200. builder.Write(birthDayStr);
  16201. builder.MoveToCell(0, i + 1, 3, 0);
  16202. string company = "";
  16203. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16204. {
  16205. company = DcList[i].CompanyFullName.ToString();
  16206. }
  16207. builder.Write(company);
  16208. builder.MoveToCell(0, i + 1, 4, 0);
  16209. builder.Write(DcList[i].Job);
  16210. }
  16211. }
  16212. else if (_dto.Language == 1)
  16213. {
  16214. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  16215. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  16216. List<string> transArrayStr = new List<string>();
  16217. string transStrRes1 = "";
  16218. for (int i = 0; i < DcList.Count; i++)
  16219. {
  16220. var dc = DcList[i];
  16221. EncryptionProcessor.DecryptProperties(dc);
  16222. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  16223. if (dc.Job.Equals("暂无")) dc.Job = "-";
  16224. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  16225. if (DcList.Count - 1 == i) transStrRes1 += str1;
  16226. else transStrRes1 += $"{str1}|";
  16227. }
  16228. //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";
  16229. string transStrRes = "";
  16230. if (transStrRes1.Length > 0)
  16231. {
  16232. transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  16233. }
  16234. //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
  16235. //await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  16236. //List<string> transArray = new List<string> { };
  16237. List<TranslateInfo> transArray = new List<TranslateInfo>();
  16238. if (transStrRes.Contains("|"))
  16239. {
  16240. string[] transArray1 = transStrRes.Split('|');
  16241. if (transArray1.Length > 0)
  16242. {
  16243. foreach (var item in transArray1)
  16244. {
  16245. if (item.Contains("&"))
  16246. {
  16247. string[] transArray2 = item.Split('&');
  16248. int index = 0;
  16249. string companyName = "", job = "";
  16250. if (transArray2.Length > 0)
  16251. {
  16252. bool success = int.TryParse(transArray2[0].Trim(), out index);
  16253. if (1 < transArray2.Length) companyName = transArray2[1];
  16254. if (2 < transArray2.Length) job = transArray2[2];
  16255. }
  16256. transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  16257. }
  16258. }
  16259. }
  16260. }
  16261. //循环赋值
  16262. for (int i = 0; i < DcList.Count; i++)
  16263. {
  16264. string PYName = "";
  16265. if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  16266. {
  16267. string PY_Last = DcList[i].Pinyin.Split('/')[0];
  16268. string PY_First = DcList[i].Pinyin.Split('/')[1];
  16269. PYName = PY_First + " " + PY_Last;
  16270. }
  16271. else
  16272. {
  16273. string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  16274. string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  16275. PYName = PY_First + " " + PY_Last;
  16276. }
  16277. builder.MoveToCell(0, i + 1, 0, 0);
  16278. builder.Write(PYName);
  16279. string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  16280. builder.MoveToCell(0, i + 1, 1, 0);
  16281. builder.Write(sex);
  16282. DateTime birthDt;
  16283. bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  16284. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  16285. builder.MoveToCell(0, i + 1, 2, 0);
  16286. builder.Write(birthday);
  16287. string company = string.Empty, job = string.Empty;
  16288. var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  16289. if (dcTransInfo != null)
  16290. {
  16291. company = dcTransInfo.CompanyName;
  16292. job = dcTransInfo.Job;
  16293. }
  16294. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  16295. {
  16296. //查询对照表
  16297. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  16298. if (tempCec != null)
  16299. {
  16300. company = tempCec.enName;
  16301. }
  16302. //翻译
  16303. else
  16304. {
  16305. }
  16306. }
  16307. builder.MoveToCell(0, i + 1, 3, 0);
  16308. builder.Write(company);
  16309. if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  16310. {
  16311. //查询对照表
  16312. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  16313. if (tempPec != null)
  16314. {
  16315. job = tempPec.enName;
  16316. }
  16317. //翻译
  16318. else
  16319. {
  16320. }
  16321. }
  16322. builder.MoveToCell(0, i + 1, 4, 0);
  16323. builder.Write(job);
  16324. }
  16325. }
  16326. //删除多余行
  16327. while (tableOne.Rows.Count > DcList.Count + 1)
  16328. {
  16329. tableOne.Rows.RemoveAt(DcList.Count + 1);
  16330. }
  16331. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  16332. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  16333. doc.Save(fileDir);
  16334. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  16335. return Ok(JsonView(true, "操作成功!", Url));
  16336. }
  16337. private class TranslateInfo
  16338. {
  16339. public int Index { get; set; }
  16340. public string CompanyName { get; set; }
  16341. public string Job { get; set; }
  16342. }
  16343. #endregion
  16344. #region 团组倒推表
  16345. /// <summary>
  16346. /// 倒推表基础数据
  16347. /// Init
  16348. /// </summary>
  16349. /// <param name="dto"></param>
  16350. /// <returns></returns>
  16351. [HttpPost]
  16352. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16353. public async Task<IActionResult> PostInvertedListInit()
  16354. {
  16355. var viewData = await _invertedListRep._Init();
  16356. if (viewData.Code != 0)
  16357. {
  16358. return Ok(JsonView(false, viewData.Msg));
  16359. }
  16360. return Ok(JsonView(viewData.Data));
  16361. }
  16362. /// <summary>
  16363. /// 倒推表
  16364. /// Info
  16365. /// </summary>
  16366. /// <param name="dto"></param>
  16367. /// <returns></returns>
  16368. [HttpPost]
  16369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16370. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  16371. {
  16372. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  16373. if (viewData.Code != 0)
  16374. {
  16375. return Ok(JsonView(false, viewData.Msg));
  16376. }
  16377. return Ok(JsonView(viewData.Data));
  16378. }
  16379. /// <summary>
  16380. /// 倒推表
  16381. /// Create
  16382. /// </summary>
  16383. /// <param name="dto"></param>
  16384. /// <returns></returns>
  16385. [HttpPost]
  16386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16387. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  16388. {
  16389. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  16390. if (viewData.Code != 0)
  16391. {
  16392. return Ok(JsonView(false, viewData.Msg));
  16393. }
  16394. return Ok(JsonView(viewData.Data));
  16395. }
  16396. /// <summary>
  16397. /// 倒推表
  16398. /// Update
  16399. /// </summary>
  16400. /// <param name="dto"></param>
  16401. /// <returns></returns>
  16402. [HttpPost]
  16403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16404. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  16405. {
  16406. var viewData = await _invertedListRep._Update(dto);
  16407. if (viewData.Code != 0)
  16408. {
  16409. return Ok(JsonView(false, viewData.Msg));
  16410. }
  16411. return Ok(JsonView(viewData.Data));
  16412. }
  16413. /// <summary>
  16414. /// 倒推表
  16415. /// File Download
  16416. /// </summary>
  16417. /// <param name="dto"></param>
  16418. /// <returns></returns>
  16419. [HttpPost]
  16420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16421. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  16422. {
  16423. var info2 = await _invertedListRep._Info(1, dto.DiId);
  16424. if (info2.Code != 0)
  16425. {
  16426. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  16427. }
  16428. var info1 = info2.Data as InvertedListInfoView;
  16429. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  16430. string teamName = "";
  16431. if (info != null) teamName = info.TeamName;
  16432. //载入模板
  16433. Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
  16434. DocumentBuilder builder = new DocumentBuilder(doc);
  16435. //利用键值对存放数据
  16436. Dictionary<string, string> dic = new Dictionary<string, string>();
  16437. dic.Add("TeamName", teamName);
  16438. dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  16439. dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  16440. dic.Add("BPRemark", info1.ApprovalDataRemark);
  16441. dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  16442. dic.Add("SQRemark", info1.ApprovalRemark);
  16443. dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  16444. dic.Add("CPJRemark", info1.IssueApprovalRemark);
  16445. //dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  16446. //dic.Add("HZRemark", info1.ApplyPassportRemark);
  16447. dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  16448. dic.Add("QZRemark", info1.VisaInformationRemark);
  16449. dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  16450. dic.Add("SQQZRemark", info1.SendVisaRemark);
  16451. dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  16452. dic.Add("CQRemark", info1.IssueVisaRemark);
  16453. dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  16454. dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  16455. dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  16456. dic.Add("SJRemark", info1.AirportdDropOffRemark);
  16457. #region 填充word模板书签内容
  16458. foreach (var key in dic.Keys)
  16459. {
  16460. builder.MoveToBookmark(key);
  16461. builder.Write(dic[key]);
  16462. }
  16463. #endregion
  16464. var fileDir = AppSettingsHelper.Get("WordBasePath");
  16465. string fileName = $"{teamName}团出行准备流程表.doc";
  16466. string filePath = fileDir + $@"InvertedList/{fileName}";
  16467. doc.Save(filePath);
  16468. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  16469. return Ok(JsonView(true, "操作成功!", Url));
  16470. }
  16471. #endregion
  16472. #region 三公签证费用(签证费、代办费)
  16473. /// <summary>
  16474. /// 三公签证费用(签证费、代办费)
  16475. /// List
  16476. /// </summary>
  16477. /// <returns></returns>
  16478. [HttpPost]
  16479. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16480. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  16481. {
  16482. var _view = await _visaFeeInfoRep._List(_dto.PortType, _dto.DiId);
  16483. if (_view.Code != 0)
  16484. {
  16485. return Ok(JsonView(false, _view.Msg));
  16486. }
  16487. return Ok(JsonView(true, "操作成功!", _view.Data));
  16488. }
  16489. /// <summary>
  16490. /// 三公签证费用(签证费、代办费)
  16491. /// Add Or Update
  16492. /// </summary>
  16493. /// <returns></returns>
  16494. [HttpPost]
  16495. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16496. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  16497. {
  16498. var _view = await _visaFeeInfoRep._Update(_dto);
  16499. if (_view.Code != 0)
  16500. {
  16501. return Ok(JsonView(false, _view.Msg));
  16502. }
  16503. return Ok(JsonView(true, _view.Msg));
  16504. }
  16505. #endregion
  16506. #region 酒店询价
  16507. /// <summary>
  16508. /// 酒店询价
  16509. /// Init
  16510. /// </summary>
  16511. /// <param name="dto"></param>
  16512. /// <returns></returns>
  16513. [HttpPost]
  16514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16515. public async Task<IActionResult> PostHotelInquiryInit()
  16516. {
  16517. var res = await _hotelInquiryRep._Init();
  16518. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16519. return Ok(JsonView(true, res.Msg, res.Data));
  16520. }
  16521. /// <summary>
  16522. /// 酒店询价
  16523. /// page Item
  16524. /// </summary>
  16525. /// <param name="_dto"></param>
  16526. /// <returns></returns>
  16527. [HttpPost]
  16528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16529. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  16530. {
  16531. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  16532. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16533. var view = res.Data as PageDataViewBase;
  16534. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  16535. }
  16536. /// <summary>
  16537. /// 酒店询价
  16538. /// info
  16539. /// </summary>
  16540. /// <param name="_dto"></param>
  16541. /// <returns></returns>
  16542. [HttpPost]
  16543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16544. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  16545. {
  16546. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  16547. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16548. return Ok(JsonView(true, res.Msg, res.Data));
  16549. }
  16550. /// <summary>
  16551. /// 酒店询价
  16552. /// Add Or Edit
  16553. /// </summary>
  16554. /// <param name="_dto"></param>
  16555. /// <returns></returns>
  16556. [HttpPost]
  16557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16558. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  16559. {
  16560. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  16561. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16562. return Ok(JsonView(true, res.Msg, res.Data));
  16563. }
  16564. /// <summary>
  16565. /// 酒店询价
  16566. /// Del
  16567. /// </summary>
  16568. /// <param name="_dto"></param>
  16569. /// <returns></returns>
  16570. [HttpPost]
  16571. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16572. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  16573. {
  16574. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  16575. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  16576. return Ok(JsonView(true, res.Msg, res.Data));
  16577. }
  16578. #endregion
  16579. #region 下载匹配op行程单
  16580. /// <summary>
  16581. /// 匹配op行程单
  16582. /// Init
  16583. /// </summary>
  16584. /// <param name="dto">团组列表请求dto</param>
  16585. /// <returns></returns>
  16586. [HttpPost]
  16587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16588. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  16589. {
  16590. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16591. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  16592. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  16593. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  16594. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  16595. .Where(it => it.IsDel == 0)
  16596. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  16597. .OrderByDescending(it => it.CreateUserId)
  16598. .ToList();
  16599. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  16600. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  16601. var diids = groupInfos.Select(it => it.Id).ToList();
  16602. List<string> countrys = new List<string>();
  16603. foreach (var item in country)
  16604. {
  16605. var data = _groupRepository.FormartTeamName(item);
  16606. var dataArray = _groupRepository.GroupSplitCountry(data);
  16607. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  16608. }
  16609. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  16610. List<string> areaArray = new List<string>(); //GetGroupCityLine
  16611. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  16612. foreach (var item in areaItem)
  16613. {
  16614. string areaStr = item.Value;
  16615. if (!string.IsNullOrEmpty(areaStr))
  16616. {
  16617. string[] str1 = areaStr.Split("-");
  16618. if (str1.Length > 0)
  16619. {
  16620. areaArray.AddRange(str1);
  16621. }
  16622. }
  16623. }
  16624. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  16625. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  16626. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  16627. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  16628. .ToList();
  16629. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  16630. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  16631. .Where(it => countriesIds.Contains(it.Id))
  16632. .Select(it => new { it.Id, Name = it.Name_CN })
  16633. .ToList();
  16634. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  16635. .Select(it => it.TeamName).ToList();
  16636. stopwatch.Stop();
  16637. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  16638. }
  16639. ///// <summary>
  16640. ///// 匹配op行程单
  16641. ///// Init 查询区域数据
  16642. ///// </summary>
  16643. ///// <param name="dto">团组列表请求dto</param>
  16644. ///// <returns></returns>
  16645. //[HttpPost]
  16646. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16647. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  16648. //{
  16649. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  16650. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  16651. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  16652. // if (string.IsNullOrEmpty(countriesDataStr))
  16653. // {
  16654. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  16655. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  16656. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  16657. // }
  16658. // else
  16659. // {
  16660. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  16661. // }
  16662. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  16663. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  16664. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  16665. // List<dynamic> childList = new List<dynamic>();
  16666. // int parentId = dto.CountriesId;
  16667. // if (provinceData.Count > 1)
  16668. // {
  16669. // foreach (var item1 in provinceData)
  16670. // {
  16671. // List<dynamic> childList1 = new List<dynamic>();
  16672. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  16673. // foreach (var item2 in citiesData1)
  16674. // {
  16675. // List<dynamic> childList2 = new List<dynamic>();
  16676. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16677. // foreach (var item3 in countiesData1)
  16678. // {
  16679. // childList2.Add(new
  16680. // {
  16681. // id = item3.Id,
  16682. // parentId = item2.Id,
  16683. // level = "district",
  16684. // name = item3.Name_CN,
  16685. // });
  16686. // }
  16687. // childList1.Add(new
  16688. // {
  16689. // id = item2.Id,
  16690. // parentId = item1.Id,
  16691. // level = "city",
  16692. // name = item2.Name_CN,
  16693. // childList = childList2
  16694. // });
  16695. // }
  16696. // childList.Add(new
  16697. // {
  16698. // id = item1.Id,
  16699. // parentId = parentId,
  16700. // level = "province",
  16701. // name = item1.Name_CN,
  16702. // childList = childList1
  16703. // });
  16704. // }
  16705. // //城市
  16706. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  16707. // foreach (var item2 in citiesData2)
  16708. // {
  16709. // List<dynamic> childList22 = new List<dynamic>();
  16710. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16711. // foreach (var item3 in countiesData1)
  16712. // {
  16713. // childList22.Add(new
  16714. // {
  16715. // id = item3.Id,
  16716. // parentId = item2.Id,
  16717. // level = "district",
  16718. // name = item3.Name_CN,
  16719. // });
  16720. // }
  16721. // childList.Add(new
  16722. // {
  16723. // id = item2.Id,
  16724. // parentId = parentId,
  16725. // level = "city",
  16726. // name = item2.Name_CN,
  16727. // childList = childList22
  16728. // });
  16729. // }
  16730. // }
  16731. // else
  16732. // {
  16733. // foreach (var item2 in citiesData)
  16734. // {
  16735. // string cname = item2.Name_CN;
  16736. // List<dynamic> childList1 = new List<dynamic>();
  16737. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  16738. // foreach (var item3 in countiesData1)
  16739. // {
  16740. // childList1.Add(new
  16741. // {
  16742. // Id = item3.Id,
  16743. // parentId = item2.Id,
  16744. // level = "district",
  16745. // name = item3.Name_CN
  16746. // });
  16747. // }
  16748. // childList.Add(new
  16749. // {
  16750. // id = item2.Id,
  16751. // parentId = parentId,
  16752. // level = "city",
  16753. // name = item2.Name_CN,
  16754. // childList = childList1
  16755. // });
  16756. // }
  16757. // }
  16758. // stopwatch.Stop();
  16759. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  16760. //}
  16761. /// <summary>
  16762. /// 匹配op行程单
  16763. /// 接团信息列表 Page
  16764. /// </summary>
  16765. /// <param name="dto">团组列表请求dto</param>
  16766. /// <returns></returns>
  16767. [HttpPost]
  16768. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16769. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  16770. {
  16771. var swatch = new Stopwatch();
  16772. swatch.Start();
  16773. #region 参数验证
  16774. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16775. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16776. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16777. #region 页面操作权限验证
  16778. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16779. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  16780. #endregion
  16781. #endregion
  16782. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16783. {
  16784. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  16785. string sqlWhere = "";
  16786. if (!string.IsNullOrEmpty(dto.Country))
  16787. {
  16788. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  16789. }
  16790. if (!string.IsNullOrEmpty(dto.Area))
  16791. {
  16792. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  16793. }
  16794. if (!string.IsNullOrEmpty(dto.TeamName))
  16795. {
  16796. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  16797. }
  16798. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  16799. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  16800. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  16801. swatch.Stop();
  16802. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  16803. }
  16804. else
  16805. {
  16806. return Ok(JsonView(false, "查询失败"));
  16807. }
  16808. }
  16809. /// <summary>
  16810. /// 匹配op行程单
  16811. /// 行程单下载
  16812. /// </summary>
  16813. /// <param name="dto">团组列表请求dto</param>
  16814. /// <returns></returns>
  16815. [HttpPost]
  16816. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16817. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  16818. {
  16819. #region 参数验证
  16820. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  16821. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  16822. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  16823. #region 页面操作权限验证
  16824. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  16825. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  16826. #endregion
  16827. #endregion
  16828. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  16829. {
  16830. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  16831. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  16832. }
  16833. else
  16834. {
  16835. return Ok(JsonView(false, "下载失败!"));
  16836. }
  16837. }
  16838. #endregion
  16839. #region 国家信息 数据 注释
  16840. //[HttpPost]
  16841. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  16842. //{
  16843. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  16844. // foreach (var item in dto)
  16845. // {
  16846. // infos.Add(new Grp_GroupsTaskAssignment()
  16847. // {
  16848. // DIId = item,
  16849. // CTId = 82,
  16850. // UId = 248,
  16851. // IsEnable = 1,
  16852. // CreateUserId = 233,
  16853. // CreateTime = DateTime.Now,
  16854. // IsDel = 0
  16855. // });
  16856. // infos.Add(new Grp_GroupsTaskAssignment()
  16857. // {
  16858. // DIId = item,
  16859. // CTId = 82,
  16860. // UId = 286,
  16861. // IsEnable = 1,
  16862. // CreateUserId = 233,
  16863. // CreateTime = DateTime.Now,
  16864. // IsDel = 0
  16865. // });
  16866. // }
  16867. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  16868. // return Ok("操作成功");
  16869. //}
  16870. //public class paramJsonDto
  16871. //{
  16872. // public List<CountriesInfo> str { get; set; }
  16873. //}
  16874. //[HttpPost]
  16875. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  16876. //{
  16877. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  16878. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  16879. // List<Sys_Cities> cities = new List<Sys_Cities>();
  16880. // List<Sys_Cities> districts = new List<Sys_Cities>();
  16881. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  16882. // _sqlSugar.BeginTran();
  16883. // int countitiesIndex = 0;
  16884. // foreach (var item in dto.str)
  16885. // {
  16886. // dynamic data = item.c;
  16887. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  16888. // if (data != null)
  16889. // {
  16890. // countitiesIndex++;
  16891. // foreach (var item1 in data)
  16892. // {
  16893. // string cnname = item1.cn;
  16894. // string enname = item1.en;
  16895. // Sys_Cities provinceInfo = new Sys_Cities()
  16896. // {
  16897. // CountriesId = countriesId,
  16898. // Name_CN = cnname,
  16899. // Name_EN = enname,
  16900. // ParentId = 0,
  16901. // IsCapital = 1,
  16902. // CreateUserId = 208,
  16903. // CreateTime = DateTime.Now,
  16904. // IsDel = 0
  16905. // };
  16906. // if (item1.lv == "province") //省份
  16907. // {
  16908. // provinceInfo.Level = 1;
  16909. // int provinceId = 0;
  16910. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  16911. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  16912. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  16913. // var data1 = item1.c;
  16914. // foreach (var item2 in data1)
  16915. // {
  16916. // if (item2.lv == "city")
  16917. // {
  16918. // string citycnname = item2.cn;
  16919. // string cityenname = item2.en;
  16920. // Sys_Cities cityInfo = new Sys_Cities()
  16921. // {
  16922. // CountriesId = countriesId,
  16923. // ParentId = provinceId,
  16924. // Level = 2,
  16925. // Name_CN = citycnname,
  16926. // Name_EN = cityenname,
  16927. // IsCapital = 1,
  16928. // CreateUserId = 208,
  16929. // CreateTime = DateTime.Now,
  16930. // IsDel = 0
  16931. // };
  16932. // if (item2.c != null)
  16933. // {
  16934. // int cityId = 0;
  16935. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  16936. // if (citiesInfo != null) cityId = citiesInfo.Id;
  16937. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  16938. // foreach (var item3 in item2.c)
  16939. // {
  16940. // if (item3.lv == "district")
  16941. // {
  16942. // var districtInfo = new Sys_Cities()
  16943. // {
  16944. // CountriesId = countriesId,
  16945. // Name_CN = item3.cn,
  16946. // Name_EN = item3.en,
  16947. // Level = 3,
  16948. // ParentId = cityId,
  16949. // IsCapital = 1,
  16950. // CreateUserId = 208,
  16951. // CreateTime = DateTime.Now,
  16952. // IsDel = 0
  16953. // };
  16954. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  16955. // //{
  16956. // districts.Add(districtInfo);
  16957. // //}
  16958. // }
  16959. // }
  16960. // }
  16961. // else
  16962. // {
  16963. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  16964. // //{
  16965. // cities.Add(cityInfo);
  16966. // //}
  16967. // }
  16968. // }
  16969. // }
  16970. // }
  16971. // else if (item1.lv == "city")//城市
  16972. // {
  16973. // provinceInfo.Level = 2;
  16974. // if (item1.c != null)
  16975. // {
  16976. // int cityId = 0;
  16977. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  16978. // if (citiesInfo != null) cityId = citiesInfo.Id;
  16979. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  16980. // foreach (var item3 in item1.c)
  16981. // {
  16982. // if (item3.lv == "district")
  16983. // {
  16984. // var districtInfo = new Sys_Cities()
  16985. // {
  16986. // CountriesId = countriesId,
  16987. // Name_CN = item3.cn,
  16988. // Name_EN = item3.en,
  16989. // Level = 3,
  16990. // ParentId = cityId,
  16991. // IsCapital = 1,
  16992. // CreateUserId = 208,
  16993. // CreateTime = DateTime.Now,
  16994. // IsDel = 0
  16995. // };
  16996. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  16997. // //{
  16998. // districts.Add(districtInfo);
  16999. // //}
  17000. // }
  17001. // }
  17002. // }
  17003. // else
  17004. // {
  17005. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  17006. // //{
  17007. // cities.Add(provinceInfo);
  17008. // //}
  17009. // }
  17010. // }
  17011. // }
  17012. // }
  17013. // }
  17014. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  17015. // cities = cities.Distinct().ToList();
  17016. // districts = districts.Distinct().ToList();
  17017. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  17018. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  17019. // cities.AddRange(districts);
  17020. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  17021. // //_sqlSugar.RollbackTran();
  17022. // _sqlSugar.CommitTran();
  17023. // return Ok(JsonView(false, "操作成功!"));
  17024. //}
  17025. //[HttpPost]
  17026. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  17027. //{
  17028. // List<CountitiesInfo> infos = dto.MyProperty;
  17029. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  17030. // _sqlSugar.BeginTran();
  17031. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  17032. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  17033. // foreach (var item in infos)
  17034. // {
  17035. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  17036. // if (countryInfo != null)
  17037. // {
  17038. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  17039. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  17040. // if (cityInfo1 != null)
  17041. // {
  17042. // cityInfo1.IsCapital = 0;
  17043. // cityInfos.Add(cityInfo1);
  17044. // }
  17045. // }
  17046. // }
  17047. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  17048. // .UpdateColumns(it => it.IsCapital)
  17049. // .WhereColumns(it => it.Id)
  17050. // .ExecuteCommand();
  17051. // //_sqlSugar.RollbackTran();
  17052. // _sqlSugar.CommitTran();
  17053. // return Ok(JsonView(false, "操作成功!"));
  17054. //}
  17055. //public class CounrtiesDto
  17056. //{
  17057. // public List<CountitiesInfo> MyProperty { get; set; }
  17058. //}
  17059. //public class CountitiesInfo
  17060. //{
  17061. // /// <summary>
  17062. // /// 圣约翰
  17063. // /// </summary>
  17064. // public string capital_name_chinese { get; set; }
  17065. // /// <summary>
  17066. // ///
  17067. // /// </summary>
  17068. // public string capital_name { get; set; }
  17069. // /// <summary>
  17070. // ///
  17071. // /// </summary>
  17072. // public string country_type { get; set; }
  17073. // /// <summary>
  17074. // /// 安提瓜和巴布达
  17075. // /// </summary>
  17076. // public string country_name_chinese { get; set; }
  17077. // /// <summary>
  17078. // /// 安提瓜和巴布达
  17079. // /// </summary>
  17080. // public string country_name_chinese_short { get; set; }
  17081. // /// <summary>
  17082. // /// 安提瓜和巴布达
  17083. // /// </summary>
  17084. // public string country_name_chinese_UN { get; set; }
  17085. // /// <summary>
  17086. // ///
  17087. // /// </summary>
  17088. // public string country_name_english_abbreviation { get; set; }
  17089. // /// <summary>
  17090. // ///
  17091. // /// </summary>
  17092. // public string country_name_english_formal { get; set; }
  17093. // /// <summary>
  17094. // ///
  17095. // /// </summary>
  17096. // public string country_name_english_UN { get; set; }
  17097. // /// <summary>
  17098. // ///
  17099. // /// </summary>
  17100. // public string continent_name { get; set; }
  17101. // /// <summary>
  17102. // ///
  17103. // /// </summary>
  17104. // public string subregion_name { get; set; }
  17105. // /// <summary>
  17106. // ///
  17107. // /// </summary>
  17108. // public string country_code2 { get; set; }
  17109. // /// <summary>
  17110. // ///
  17111. // /// </summary>
  17112. // public string country_code3 { get; set; }
  17113. // /// <summary>
  17114. // ///
  17115. // /// </summary>
  17116. // public string phone_code { get; set; }
  17117. //}
  17118. //public class CountriesInfo : BasicInfo
  17119. //{
  17120. // public List<CitiesInfo> c { get; set; }
  17121. //}
  17122. //public class CitiesInfo : BasicInfo
  17123. //{
  17124. // public List<AreaInfo> c { get; set; }
  17125. //}
  17126. //public class AreaInfo : BasicInfo
  17127. //{
  17128. // public List<AreaInfo> c { get; set; }
  17129. //}
  17130. //public class BasicInfo
  17131. //{
  17132. // public string code { get; set; }
  17133. // public string cn { get; set; }
  17134. // public string lv { get; set; }
  17135. // public string en { get; set; }
  17136. //}
  17137. #endregion
  17138. #region 查看邀请方
  17139. /// <summary>
  17140. /// 查看邀请方
  17141. /// 邀请方信息 Init
  17142. /// </summary>
  17143. /// <param name="dto"></param>
  17144. /// <returns></returns>
  17145. [HttpPost]
  17146. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17147. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  17148. {
  17149. string sqlWhere = string.Empty;
  17150. if (!string.IsNullOrEmpty(dto.Search))
  17151. {
  17152. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  17153. }
  17154. string sql = string.Format($@"Select
  17155. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  17156. Id,
  17157. UnitName
  17158. From Res_InvitationOfficialActivityData
  17159. Where IsDel = 0
  17160. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  17161. RefAsync<int> total = 0;
  17162. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17163. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  17164. }
  17165. /// <summary>
  17166. /// 查看邀请方
  17167. /// 国家信息 Init
  17168. /// </summary>
  17169. /// <param name="dto"></param>
  17170. /// <returns></returns>
  17171. [HttpPost]
  17172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17173. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  17174. {
  17175. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  17176. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  17177. var diids = groupInfos.Select(it => it.Id).ToList();
  17178. List<string> countrys = new List<string>();
  17179. foreach (var item in country)
  17180. {
  17181. var data = _groupRepository.FormartTeamName(item);
  17182. var dataArray = _groupRepository.GroupSplitCountry(data);
  17183. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  17184. }
  17185. countrys = countrys.Distinct().ToList();
  17186. for (int i = 0; i < countrys.Count; i++)
  17187. {
  17188. string item = countrys[i];
  17189. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  17190. {
  17191. countrys.Remove(item);
  17192. i--;
  17193. }
  17194. }
  17195. RefAsync<int> total = 0;
  17196. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  17197. .Where(it => countrys.Contains(it.Name_CN))
  17198. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17199. .Select(it => new { id = it.Id, name = it.Name_CN })
  17200. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17201. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17202. }
  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> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  17212. {
  17213. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  17214. RefAsync<int> total = 0;
  17215. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  17216. .Where(it => it.CountriesId == dto.CountiesId)
  17217. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  17218. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  17219. .Select(it => new { id = it.Id, name = it.Name_CN })
  17220. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17221. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  17222. }
  17223. /// <summary>
  17224. /// 查看邀请方
  17225. /// 团组名称 Init
  17226. /// </summary>
  17227. /// <param name="dto"></param>
  17228. /// <returns></returns>
  17229. [HttpPost]
  17230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17231. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  17232. {
  17233. var watch = new Stopwatch();
  17234. watch.Start();
  17235. RefAsync<int> total = 0;
  17236. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  17237. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  17238. .Where((oa, di) => oa.IsDel == 0)
  17239. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  17240. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  17241. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  17242. .Distinct()
  17243. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17244. watch.Stop();
  17245. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  17246. }
  17247. /// <summary>
  17248. /// 查看邀请方
  17249. /// 团组 & 邀请方信息
  17250. /// </summary>
  17251. /// <param name="dto"></param>
  17252. /// <returns></returns>
  17253. [HttpPost]
  17254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17255. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  17256. {
  17257. var watch = new Stopwatch();
  17258. watch.Start();
  17259. RefAsync<int> total = 0;
  17260. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  17261. .AS("Grp_DelegationInfo")
  17262. .Includes(x => x.InvitingInfos)
  17263. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  17264. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  17265. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  17266. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  17267. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  17268. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  17269. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  17270. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  17271. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  17272. infos.ForEach(x =>
  17273. {
  17274. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  17275. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  17276. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  17277. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  17278. });
  17279. watch.Stop();
  17280. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  17281. }
  17282. #endregion
  17283. #region 报批行程
  17284. /// <summary>
  17285. /// 报批行程初始化
  17286. /// </summary>
  17287. /// <param name="dto"></param>
  17288. /// <returns></returns>
  17289. [HttpPost]
  17290. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  17291. {
  17292. const int chiNumber = 5;
  17293. var jw = JsonView(false);
  17294. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.Id).ToList();
  17295. var group = groupList.First();
  17296. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  17297. group = groupList.First(x => x.Id == diid);
  17298. if (group == null)
  17299. {
  17300. jw.Msg = "暂无团组!";
  17301. return Ok(jw);
  17302. }
  17303. var data = new
  17304. {
  17305. groupList = groupList.Select(x => new
  17306. {
  17307. x.TeamName,
  17308. x.Id
  17309. }),
  17310. content = new ArrayList(),
  17311. groupInfo = new
  17312. {
  17313. group.VisitDays,
  17314. group.TourCode,
  17315. group.VisitPNumber,
  17316. group.TeamName,
  17317. group.Id,
  17318. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  17319. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd")
  17320. },
  17321. };
  17322. var resultArr = new ArrayList();
  17323. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  17324. if (content.Count == 0)
  17325. {
  17326. var stay = "-";
  17327. var cityPath = "-";
  17328. //添加城市路径以及住宿地
  17329. //黑屏代码数据
  17330. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17331. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17332. {
  17333. jw = JsonView(true, "黑屏代码有误!", data);
  17334. return Ok(jw);
  17335. }
  17336. foreach (DataRow row in dtBlack.Rows)
  17337. {
  17338. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17339. {
  17340. jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  17341. return Ok(jw);
  17342. }
  17343. }
  17344. //黑屏代码获取时间区间
  17345. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17346. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17347. _sqlSugar.BeginTran();
  17348. for (int i = 0; i < timeArr.Count; i++)
  17349. {
  17350. stay = "-";
  17351. cityPath = "-";
  17352. DateTime NewData = DateTime.Parse(timeArr[i]);
  17353. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17354. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17355. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17356. if (tbSelect.Length > 0)
  17357. {
  17358. List<string> threeCodeStr = new List<string>();
  17359. foreach (var item in tbSelect)
  17360. {
  17361. var threeCode = item["Three"].ToString() ?? "";
  17362. if (threeCode.Length == 6)
  17363. {
  17364. var start = threeCode.Substring(0, 3);
  17365. var end = threeCode.Substring(3, 3);
  17366. if (threeCodeStr.Count == 0)
  17367. {
  17368. threeCodeStr.Add(start);
  17369. threeCodeStr.Add(end);
  17370. }
  17371. else
  17372. {
  17373. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17374. {
  17375. threeCodeStr.Add(end);
  17376. }
  17377. else
  17378. {
  17379. threeCodeStr.Add(start);
  17380. threeCodeStr.Add(end);
  17381. }
  17382. }
  17383. }
  17384. }
  17385. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17386. var last = threeCodeStr.Last();
  17387. foreach (var item in threeCodeStr)
  17388. {
  17389. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17390. if (item.Equals(last))
  17391. {
  17392. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17393. }
  17394. }
  17395. cityPath = cityPath.Trim('-');
  17396. }
  17397. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17398. appro.Diid = diid ?? -1;
  17399. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17400. appro.Id = thisId;
  17401. appro.CreateUserId = dto.UserId;
  17402. appro.CreateTime = DateTime.Now;
  17403. content.Add(appro);
  17404. }
  17405. _sqlSugar.CommitTran();
  17406. }
  17407. foreach (var x in content)
  17408. {
  17409. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  17410. if (chiList.Count < chiNumber)
  17411. {
  17412. for (int i = chiList.Count; i < chiNumber; i++)
  17413. {
  17414. chiList.Add(new Grp_ApprovalTravelDetails());
  17415. }
  17416. }
  17417. resultArr.Add(new
  17418. {
  17419. x.Id,
  17420. x.Date,
  17421. x.Diid,
  17422. chiList = chiList.Select(x1 => new
  17423. {
  17424. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17425. x1.Details,
  17426. x1.ParentId,
  17427. x1.Id
  17428. })
  17429. });
  17430. }
  17431. data = data with
  17432. {
  17433. content = resultArr,
  17434. };
  17435. jw = JsonView(true, "获取成功!", data);
  17436. return Ok(jw);
  17437. }
  17438. /// <summary>
  17439. /// 报批行程删除
  17440. /// </summary>
  17441. /// <param name="dto"></param>
  17442. /// <returns></returns>
  17443. [HttpPost]
  17444. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  17445. {
  17446. var jw = JsonView(false);
  17447. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17448. if (group == null)
  17449. {
  17450. jw.Msg = "团组参数有误!";
  17451. return Ok(jw);
  17452. }
  17453. try
  17454. {
  17455. _sqlSugar.BeginTran();
  17456. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  17457. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  17458. {
  17459. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17460. DeleteUserId = dto.uesrId,
  17461. IsDel = 1
  17462. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  17463. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  17464. {
  17465. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17466. DeleteUserId = dto.uesrId,
  17467. IsDel = 1
  17468. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  17469. _sqlSugar.CommitTran();
  17470. jw = JsonView(true, "删除成功");
  17471. }
  17472. catch (Exception ex)
  17473. {
  17474. jw = JsonView(false, ex.Message);
  17475. }
  17476. return Ok(jw);
  17477. }
  17478. /// <summary>
  17479. /// 报批行程保存
  17480. /// </summary>
  17481. /// <param name="dto"></param>
  17482. /// <returns></returns>
  17483. [HttpPost]
  17484. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  17485. {
  17486. var jw = JsonView(false);
  17487. var Find = dto.Arr.Find(x => x.id == 0);
  17488. if (Find != null)
  17489. {
  17490. jw.Msg = "生成的ID为0!";
  17491. return Ok(jw);
  17492. }
  17493. foreach (var item in dto.Arr)
  17494. {
  17495. foreach (var chi in item.chiList)
  17496. {
  17497. if (chi.parentId == 0)
  17498. {
  17499. chi.parentId = item.id;
  17500. }
  17501. }
  17502. }
  17503. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  17504. _sqlSugar.BeginTran();
  17505. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  17506. {
  17507. var parentIds = dto.Arr.Select(x => x.id).ToList();
  17508. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  17509. {
  17510. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  17511. DeleteUserId = dto.UserId,
  17512. IsDel = 1
  17513. }).ExecuteCommand();
  17514. }
  17515. try
  17516. {
  17517. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  17518. {
  17519. CreateTime = DateTime.Now,
  17520. CreateUserId = dto.UserId,
  17521. Details = x.details,
  17522. ParentId = x.parentId,
  17523. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17524. Remark = "",
  17525. IsDel = 0
  17526. }).ToList()).ExecuteCommand();
  17527. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  17528. {
  17529. Id = x.id,
  17530. Details = x.details,
  17531. ParentId = x.parentId,
  17532. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  17533. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  17534. {
  17535. Details = x.Details,
  17536. ParentId = x.ParentId,
  17537. Time = x.Time
  17538. }).ExecuteCommand();
  17539. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  17540. {
  17541. Id = x.id,
  17542. Date = x.date,
  17543. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  17544. {
  17545. Date = x.Date
  17546. }).ExecuteCommand();
  17547. _sqlSugar.CommitTran();
  17548. jw = JsonView(true, "保存成功!");
  17549. }
  17550. catch (Exception ex)
  17551. {
  17552. _sqlSugar.RollbackTran();
  17553. jw = JsonView(false, "保存失败!" + ex.Message);
  17554. }
  17555. return Ok(jw);
  17556. }
  17557. /// <summary>
  17558. /// 报批行程生成
  17559. /// </summary>
  17560. /// <param name="dto"></param>
  17561. /// <returns></returns>
  17562. [HttpPost]
  17563. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  17564. {
  17565. var jw = JsonView(false);
  17566. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17567. if (group == null)
  17568. {
  17569. jw.Msg = "暂无该团组!";
  17570. return Ok(jw);
  17571. }
  17572. //黑屏代码数据
  17573. DataTable dtBlack = GeneralMethod.GetTableByBlackCode(group.Id);
  17574. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  17575. {
  17576. jw.Msg = "黑屏代码有误!";
  17577. return Ok(jw);
  17578. }
  17579. foreach (DataRow row in dtBlack.Rows)
  17580. {
  17581. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17582. {
  17583. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  17584. return Ok(jw);
  17585. }
  17586. }
  17587. var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  17588. var resultArr = new ArrayList();
  17589. if (officialActivitiesArr.Count == 0)
  17590. {
  17591. jw.Msg = "暂无公务出访信息!";
  17592. return Ok(jw);
  17593. }
  17594. try
  17595. {
  17596. _sqlSugar.BeginTran();
  17597. DeleteApprovalJourney(new
  17598. Domain.Dtos.Groups.DeleteApprovalJourney
  17599. {
  17600. Diid = dto.Diid,
  17601. uesrId = dto.Userid
  17602. });
  17603. var stay = "-";
  17604. var cityPath = "-";
  17605. //添加城市路径以及住宿地
  17606. //黑屏代码获取时间区间
  17607. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  17608. var empty = "【未收入该三字码!请机票同事录入】";
  17609. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  17610. for (int i = 0; i < timeArr.Count; i++)
  17611. {
  17612. stay = "-";
  17613. cityPath = "-";
  17614. var chiarr = new List<Grp_ApprovalTravelDetails>();
  17615. DateTime NewData = DateTime.Parse(timeArr[i]);
  17616. 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();
  17617. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  17618. if (tbSelect.Length > 0)
  17619. {
  17620. List<string> threeCodeStr = new List<string>();
  17621. bool isTrade = false;
  17622. string trip = string.Empty;
  17623. var rowLast = tbSelect.Last();
  17624. var rowFirst = tbSelect.First();
  17625. var airStartTime = rowFirst["StartTime"].ToString() ?? "0000";
  17626. var airEndTime = rowLast["EndTime"].ToString() ?? "0000";
  17627. var takeOffTime = DateTime.Parse(timeArr[i]);
  17628. var fallToTime = DateTime.Parse(timeArr[i]);
  17629. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  17630. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  17631. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  17632. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  17633. foreach (var item in tbSelect)
  17634. {
  17635. var start = string.Empty;
  17636. var end = string.Empty;
  17637. var threeCode = item["Three"].ToString() ?? "";
  17638. if (threeCode.Length == 6)
  17639. {
  17640. start = threeCode.Substring(0, 3);
  17641. end = threeCode.Substring(3, 3);
  17642. if (threeCodeStr.Count == 0)
  17643. {
  17644. threeCodeStr.Add(start);
  17645. threeCodeStr.Add(end);
  17646. }
  17647. else
  17648. {
  17649. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  17650. {
  17651. threeCodeStr.Add(end);
  17652. }
  17653. else
  17654. {
  17655. threeCodeStr.Add(start);
  17656. threeCodeStr.Add(end);
  17657. }
  17658. }
  17659. }
  17660. //处理机票信息
  17661. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  17662. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  17663. if (start_Object == null)
  17664. {
  17665. start_Object = new Res_ThreeCode()
  17666. {
  17667. AirPort = empty,
  17668. AirPort_En = empty,
  17669. City = empty,
  17670. Country = empty,
  17671. Four = empty,
  17672. Three = empty,
  17673. };
  17674. }
  17675. if (end_Object == null)
  17676. {
  17677. end_Object = new Res_ThreeCode()
  17678. {
  17679. AirPort = empty,
  17680. AirPort_En = empty,
  17681. City = empty,
  17682. Country = empty,
  17683. Four = empty,
  17684. Three = empty,
  17685. };
  17686. }
  17687. //机型判断
  17688. string airModel = item["AirModel"].ToString();
  17689. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  17690. string flightTime = item["FlightTime"].ToString();
  17691. if (flightTime!.Contains(":"))
  17692. {
  17693. flightTime = flightTime.Replace(":", "小时");
  17694. flightTime += "分钟";
  17695. }
  17696. if (flightTime.Contains("H"))
  17697. {
  17698. flightTime = flightTime.Replace("H", "小时");
  17699. }
  17700. if (flightTime.Contains("M"))
  17701. {
  17702. flightTime = flightTime.Replace("M", "分钟");
  17703. }
  17704. IFormatProvider ifp = new CultureInfo("zh-CN", true);
  17705. if (DateTime.TryParseExact(flightTime, "HH小时mm分钟", ifp, DateTimeStyles.None, out DateTime flightDataTime))
  17706. {
  17707. flightTime = flightDataTime.Hour > 0
  17708. ? flightDataTime.Hour.ToString() + "小时" + (flightDataTime.Minute > 0
  17709. ? flightDataTime.Minute.ToString() + "分钟" : "") : flightDataTime.Minute > 0
  17710. ? flightDataTime.Minute.ToString() + "分钟" : "";
  17711. }
  17712. //航班号
  17713. string flightcode = item["Fliagtcode"].ToString();
  17714. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  17715. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  17716. if (aircompany == null)
  17717. {
  17718. aircompany = new Res_AirCompany
  17719. {
  17720. CnName = hsEmpty,
  17721. EnName = hsEmpty,
  17722. ShortCode = hsEmpty,
  17723. };
  17724. }
  17725. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  17726. trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName} {flightcode} 飞往 {end_Object.City};\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  17727. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  17728. if (isTrade)
  17729. {
  17730. trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  17731. }
  17732. else
  17733. {
  17734. trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  17735. }
  17736. }
  17737. chiarr.Add(new Grp_ApprovalTravelDetails
  17738. {
  17739. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  17740. CreateTime = DateTime.Now,
  17741. CreateUserId = dto.Userid,
  17742. ParentId = 0,
  17743. Details = trip
  17744. });
  17745. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  17746. var last = threeCodeStr.Last();
  17747. foreach (var item in threeCodeStr)
  17748. {
  17749. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  17750. if (item.Equals(last))
  17751. {
  17752. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  17753. }
  17754. }
  17755. cityPath = cityPath.Trim('-');
  17756. }
  17757. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  17758. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  17759. appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  17760. appro.Diid = dto.Diid;
  17761. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  17762. appro.Id = thisId;
  17763. appro.CreateUserId = dto.Userid;
  17764. appro.CreateTime = DateTime.Now;
  17765. foreach (var item in gwinfo)
  17766. {
  17767. Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  17768. chi.Details = "拜访" + item.Client;
  17769. if (!string.IsNullOrWhiteSpace(item.ReqSample))
  17770. {
  17771. chi.Details += "," + item.ReqSample;
  17772. }
  17773. chi.ParentId = thisId;
  17774. chi.Time = item.Time;
  17775. chiarr.Add(chi);
  17776. }
  17777. if (chiarr.Count < 5)
  17778. {
  17779. for (int j = chiarr.Count; j < 5; j++)
  17780. {
  17781. chiarr.Add(new
  17782. Grp_ApprovalTravelDetails());
  17783. }
  17784. }
  17785. resultArr.Add(new
  17786. {
  17787. appro.Id,
  17788. appro.Date,
  17789. appro.Diid,
  17790. chiList = chiarr.Select(x1 => new
  17791. {
  17792. timeInterval = x1.Time == null ? new string[1] : x1.Time.Split('-'),
  17793. x1.Details,
  17794. x1.ParentId,
  17795. x1.Id
  17796. })
  17797. });
  17798. }
  17799. _sqlSugar.CommitTran();
  17800. jw = JsonView(true, "生成成功!", resultArr);
  17801. }
  17802. catch (Exception ex)
  17803. {
  17804. jw.Code = 400;
  17805. jw.Msg = "生成失败!" + ex.Message;
  17806. }
  17807. return Ok(jw);
  17808. }
  17809. /// <summary>
  17810. /// 报批行程word导出
  17811. /// </summary>
  17812. /// <param name="dto"></param>
  17813. /// <returns></returns>
  17814. [HttpPost]
  17815. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  17816. {
  17817. var jw = JsonView(false);
  17818. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  17819. if (group == null)
  17820. {
  17821. jw.Msg = "暂无该团组!";
  17822. return Ok(jw);
  17823. }
  17824. //模板路径
  17825. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "Template/公务行程导出模板.docx"); //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  17826. //载入模板
  17827. Document doc = new Document(tempPath);
  17828. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17829. //获取所填表格的序数
  17830. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17831. Aspose.Words.Tables.Row titleRowClone = null;
  17832. Aspose.Words.Tables.Row CenterRowClone = null;
  17833. int index = 0;
  17834. int indexChi = 0;
  17835. int SetIndex = 0;
  17836. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  17837. //获取数据,放到datatable
  17838. foreach (var item in ApprovalTravelArr)
  17839. {
  17840. if (index > 0)
  17841. {
  17842. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  17843. tableOne.AppendChild(titleRowClone);
  17844. }
  17845. var textTime = item.Date;
  17846. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  17847. SetCells(tableOne, doc, SetIndex, 0, textTime);
  17848. SetIndex++;
  17849. if (ChiRep.Count > 0)
  17850. {
  17851. foreach (var itemChi in ChiRep)
  17852. {
  17853. var txtTime = itemChi.Time;
  17854. var txtDetail = itemChi.Details;
  17855. if (indexChi > 0)
  17856. {
  17857. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17858. tableOne.AppendChild(CenterRowClone);
  17859. }
  17860. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  17861. {
  17862. SetCells(tableOne, doc, SetIndex, 0, "");
  17863. SetCells(tableOne, doc, SetIndex, 1, "");
  17864. indexChi++;
  17865. SetIndex++;
  17866. break;
  17867. }
  17868. SetCells(tableOne, doc, SetIndex, 0, txtTime);
  17869. SetCells(tableOne, doc, SetIndex, 1, txtDetail);
  17870. indexChi++;
  17871. SetIndex++;
  17872. }
  17873. }
  17874. else
  17875. {
  17876. if (indexChi > 0)
  17877. {
  17878. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  17879. tableOne.AppendChild(CenterRowClone);
  17880. }
  17881. SetCells(tableOne, doc, SetIndex, 0, "");
  17882. SetCells(tableOne, doc, SetIndex, 1, "");
  17883. indexChi++;
  17884. SetIndex++;
  17885. }
  17886. index++;
  17887. }
  17888. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + "商邀出访日程.doc";
  17889. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17890. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  17891. jw.Code = 200;
  17892. jw.Msg = "";
  17893. return Ok(jw);
  17894. }
  17895. private string intToString(int numberVal)
  17896. {
  17897. string numberval = numberVal.ToString();
  17898. Dictionary<char, string> Number = new Dictionary<char, string>();
  17899. Number.Add('1', "一");
  17900. Number.Add('2', "二");
  17901. Number.Add('3', "三");
  17902. Number.Add('4', "四");
  17903. Number.Add('5', "五");
  17904. Number.Add('6', "六");
  17905. Number.Add('7', "七");
  17906. Number.Add('8', "八");
  17907. Number.Add('9', "九");
  17908. string stringNumberVal = string.Empty;
  17909. for (int i = 0; i < numberval.Length; i++)
  17910. {
  17911. if (i == 0)
  17912. {
  17913. stringNumberVal += Number[numberval[i]];
  17914. }
  17915. else if (i >= 1)
  17916. {
  17917. if (numberval[i] == '0')
  17918. {
  17919. stringNumberVal = "十";
  17920. }
  17921. else
  17922. {
  17923. stringNumberVal += "十" + Number[numberval[i]];
  17924. }
  17925. }
  17926. }
  17927. return stringNumberVal;
  17928. }
  17929. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val)
  17930. {
  17931. //获取table中的某个单元格,从0开始
  17932. Cell lshCell = table.Rows[rows].Cells[cells];
  17933. //将单元格中段落移除
  17934. foreach (Node item in lshCell.Paragraphs)
  17935. {
  17936. lshCell.Paragraphs.Remove(item);
  17937. }
  17938. if (val.Contains("\r\n"))
  17939. {
  17940. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  17941. foreach (var item in spArr)
  17942. {
  17943. //新建一个段落
  17944. Paragraph p = new Paragraph(doc);
  17945. var r = new Run(doc, item);
  17946. //把设置的值赋给之前新建的段落
  17947. p.AppendChild(r);
  17948. //将此段落加到单元格内
  17949. lshCell.AppendChild(p);
  17950. }
  17951. }
  17952. else
  17953. {
  17954. //新建一个段落
  17955. Paragraph p = new Paragraph(doc);
  17956. var r = new Run(doc, val);
  17957. //把设置的值赋给之前新建的段落
  17958. p.AppendChild(r);
  17959. //将此段落加到单元格内
  17960. lshCell.AppendChild(p);
  17961. }
  17962. }
  17963. [HttpPost]
  17964. public async Task<IActionResult> ServerHttp(string paramStr)
  17965. {
  17966. paramStr = paramStr.TrimEnd('\'');
  17967. paramStr = paramStr.TrimStart('\'');
  17968. JsonView jw = JsonView(false);
  17969. JObject param = JObject.Parse(paramStr);
  17970. if (!param.ContainsKey("url"))
  17971. {
  17972. jw.Msg = "url null";
  17973. return Ok(jw);
  17974. }
  17975. string url = param["url"]!.ToString();
  17976. var methon = "get";
  17977. Dictionary<string, string> headValues = null;
  17978. string bodyStr = string.Empty;
  17979. if (param.ContainsKey("methon"))
  17980. {
  17981. methon = param["methon"]!.ToString().ToLower();
  17982. }
  17983. if (param.ContainsKey("header"))
  17984. {
  17985. var header = param["header"]!.ToString();
  17986. JObject headerJobject = JObject.Parse(header);
  17987. headValues = new Dictionary<string, string>();
  17988. foreach (JProperty item in headerJobject.Properties())
  17989. {
  17990. var value = item.Value.ToString();
  17991. var head = item.Path;
  17992. headValues.Add(head, value);
  17993. }
  17994. }
  17995. HttpClient client = new HttpClient();
  17996. string responseString = string.Empty;
  17997. StringContent content = null;
  17998. if (headValues != null)
  17999. {
  18000. foreach (var item in headValues.Keys)
  18001. {
  18002. if (item.ToLower().Contains("content") && item.ToLower().Contains("type"))
  18003. {
  18004. if (param.ContainsKey("body"))
  18005. {
  18006. bodyStr = param["body"]!.ToString();
  18007. }
  18008. content = new StringContent(bodyStr, Encoding.UTF8, headValues[item]);
  18009. }
  18010. else
  18011. {
  18012. client.DefaultRequestHeaders.Add(item, headValues[item]);
  18013. }
  18014. }
  18015. }
  18016. try
  18017. {
  18018. if (methon == "get")
  18019. {
  18020. responseString = await client.GetStringAsync(url);
  18021. }
  18022. else if (methon == "post")
  18023. {
  18024. var request = new HttpRequestMessage(HttpMethod.Post, url)
  18025. {
  18026. Content = content
  18027. };
  18028. var response = await client.SendAsync(request);
  18029. try
  18030. {
  18031. Stream responseStream = await response.Content.ReadAsStreamAsync();
  18032. using (GZipStream gzipStream = new GZipStream(responseStream, CompressionMode.Decompress))
  18033. {
  18034. using (StreamReader reader = new StreamReader(gzipStream))
  18035. {
  18036. responseString = await reader.ReadToEndAsync();
  18037. }
  18038. }
  18039. }
  18040. catch (Exception)
  18041. {
  18042. responseString = await response.Content.ReadAsStringAsync();
  18043. }
  18044. }
  18045. else
  18046. {
  18047. responseString = "methon error";
  18048. }
  18049. jw = JsonView(true, "success", responseString);
  18050. }
  18051. catch (Exception ex)
  18052. {
  18053. jw.Msg = "error " + ex.Message;
  18054. jw.Data = ex.StackTrace;
  18055. }
  18056. finally
  18057. {
  18058. client.Dispose();
  18059. }
  18060. return Ok(jw);
  18061. }
  18062. #endregion
  18063. #region 团组接待意见调查
  18064. /// <summary>
  18065. /// 团组接待意见调查 - 信息管理
  18066. /// 基础数据(团组)
  18067. /// </summary>
  18068. /// <param name="dto"></param>
  18069. /// <returns></returns>
  18070. [HttpGet]
  18071. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18072. public async Task<IActionResult> OpinionaireInit()
  18073. {
  18074. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  18075. .Select(x => new
  18076. {
  18077. x.Id,
  18078. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  18079. })
  18080. .OrderByDescending(x => x.Id)
  18081. .ToListAsync();
  18082. return Ok(JsonView(groupData, groupData.Count));
  18083. }
  18084. /// <summary>
  18085. /// 团组接待意见调查 - 信息管理
  18086. /// 列表
  18087. /// </summary>
  18088. /// <param name="groupId"></param>
  18089. /// <returns></returns>
  18090. [HttpGet("{groupId}")]
  18091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18092. public async Task<IActionResult> OpinionaireManageList(int groupId)
  18093. {
  18094. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18095. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  18096. .Select(x => new
  18097. {
  18098. x.Id,
  18099. x.TourGuideName,
  18100. x.CityName,
  18101. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  18102. x.CreateTime
  18103. })
  18104. .OrderBy(x => x.Id)
  18105. .ToListAsync();
  18106. return Ok(JsonView(data));
  18107. }
  18108. /// <summary>
  18109. /// 团组接待意见调查 - 信息管理
  18110. /// 保存
  18111. /// </summary>
  18112. /// <param name="dto"></param>
  18113. /// <returns></returns>
  18114. [HttpPost]
  18115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18116. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  18117. {
  18118. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18119. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18120. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18121. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  18122. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  18123. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  18124. _opinionaireRep.BeginTran();
  18125. if (addData != null && addData.Count > 0)
  18126. {
  18127. foreach (var item in addData)
  18128. {
  18129. item.CreateUserId = currUserInfo.UserId;
  18130. item.DiId = dto.DiId;
  18131. }
  18132. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  18133. }
  18134. if (updData != null && updData.Count > 0)
  18135. {
  18136. var upd = await _opinionaireRep._sqlSugar
  18137. .Updateable(updData)
  18138. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  18139. .WhereColumns(x => new { x.Id })
  18140. .ExecuteCommandAsync();
  18141. }
  18142. _opinionaireRep.CommitTran();
  18143. return Ok(JsonView("操作成功!"));
  18144. }
  18145. /// <summary>
  18146. /// 团组接待意见调查 - 信息管理
  18147. /// 删除
  18148. /// </summary>
  18149. /// <param name="id"></param>
  18150. /// <returns></returns>
  18151. [HttpDelete("{id}")]
  18152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18153. public async Task<IActionResult> OpinionaireManageDel(int id)
  18154. {
  18155. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  18156. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  18157. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  18158. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  18159. if (!del) return Ok(JsonView("操作失败!"));
  18160. return Ok(JsonView("操作成功!"));
  18161. }
  18162. /// <summary>
  18163. /// 团组接待意见调查 - 用户
  18164. /// 列表
  18165. /// </summary>
  18166. /// <param name="id"></param>
  18167. /// <returns></returns>
  18168. [HttpGet("{diId}")]
  18169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18170. public async Task<IActionResult> OpinionaireUserList(int diId)
  18171. {
  18172. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  18173. var sql = string.Format(@"
  18174. SELECT
  18175. o.Id,
  18176. o.DiId,
  18177. di.TeamName AS 'GroupName',
  18178. di.VisitPNumber AS 'PeopleNumber',
  18179. di.ClientName AS 'LeadGroup',
  18180. di.VisitCountry AS 'Travel',
  18181. di.VisitDays AS 'Days',
  18182. o.CityName,
  18183. o.TourGuideName,
  18184. o.Catering,
  18185. o.CateringReason,
  18186. o.Stay,
  18187. o.StayReason,
  18188. o.[Route],
  18189. o.RouteReason,
  18190. o.OfficialActivity,
  18191. o.OfficialActivityReason,
  18192. o.TourGuide,
  18193. o.TourGuideReason,
  18194. o.[Translate],
  18195. o.TranslateReason,
  18196. o.Trip,
  18197. o.TripReason,
  18198. o.ESFileName,
  18199. o.SignatureDate,
  18200. o.Remark
  18201. FROM
  18202. Grp_Opinionaire o
  18203. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  18204. WHERE
  18205. o.IsDel = 0
  18206. AND o.DiId = {0}
  18207. ORDER BY
  18208. o.Id ASC", diId);
  18209. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  18210. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  18211. return Ok(JsonView(data));
  18212. }
  18213. /// <summary>
  18214. /// 团组接待意见调查 - 用户
  18215. /// 保存
  18216. /// </summary>
  18217. /// <param name="id"></param>
  18218. /// <returns></returns>
  18219. [HttpPost]
  18220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18221. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  18222. {
  18223. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  18224. foreach (var item in dto)
  18225. {
  18226. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  18227. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  18228. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  18229. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  18230. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  18231. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  18232. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  18233. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  18234. }
  18235. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  18236. if (!Directory.Exists(filePathBase))
  18237. {
  18238. Directory.CreateDirectory(filePathBase);
  18239. }
  18240. #region 上传文件
  18241. var filePaths = new List<string>();
  18242. foreach (var item in dto)
  18243. {
  18244. var file = item.File;
  18245. // 将文件保存到指定位置
  18246. var filePath = Path.Combine(filePathBase, file.FileName);
  18247. using (var stream = new FileStream(filePath, FileMode.Create))
  18248. {
  18249. await file.CopyToAsync(stream);
  18250. }
  18251. //验证文件是否上传成功
  18252. if (!System.IO.File.Exists(filePath))
  18253. {
  18254. foreach (var filePathStr in filePaths)
  18255. {
  18256. System.IO.File.Delete(filePathStr);
  18257. }
  18258. return Ok(JsonView(false, "文件上传失败!"));
  18259. }
  18260. item.ESFileName = file.FileName;
  18261. }
  18262. #endregion
  18263. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  18264. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  18265. .UpdateColumns(x => new
  18266. {
  18267. x.Catering,
  18268. x.CateringReason,
  18269. x.Stay,
  18270. x.StayReason,
  18271. x.Route,
  18272. x.RouteReason,
  18273. x.OfficialActivity,
  18274. x.OfficialActivityReason,
  18275. x.TourGuide,
  18276. x.TourGuideReason,
  18277. x.Translate,
  18278. x.TranslateReason,
  18279. x.Trip,
  18280. x.TripReason,
  18281. x.ESFileName,
  18282. x.SignatureDate,
  18283. x.Remark
  18284. })
  18285. .WhereColumns(x => new { x.Id })
  18286. .ExecuteCommandAsync();
  18287. if (upd < 1)
  18288. {
  18289. foreach (var filePathStr in filePaths)
  18290. {
  18291. System.IO.File.Delete(filePathStr);
  18292. }
  18293. return Ok(JsonView(false));
  18294. }
  18295. return Ok(JsonView(true));
  18296. }
  18297. #endregion
  18298. #region 团组餐厅相关信息
  18299. /// <summary>
  18300. /// 团组相关餐厅信息
  18301. /// 基础数据(团组)
  18302. /// </summary>
  18303. /// <returns></returns>
  18304. [HttpGet]
  18305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18306. public async Task<IActionResult> RestaurantInit()
  18307. {
  18308. return Ok(await _restaurantRep.InitAsync());
  18309. }
  18310. /// <summary>
  18311. /// 团组相关餐厅信息
  18312. /// Item
  18313. /// </summary>
  18314. /// <param name="dto"></param>
  18315. /// <returns></returns>
  18316. [HttpPost]
  18317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18318. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  18319. {
  18320. int portType = dto.PortType,
  18321. groupId = dto.GroupId;
  18322. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false,MsgTips.Port));
  18323. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18324. return Ok(await _restaurantRep.ItemAsync(portType,groupId));
  18325. }
  18326. /// <summary>
  18327. /// 团组相关餐厅信息
  18328. /// List
  18329. /// </summary>
  18330. /// <param name="dto"></param>
  18331. /// <returns></returns>
  18332. [HttpPost]
  18333. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18334. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  18335. {
  18336. int portType = dto.PortType,
  18337. groupId = dto.GroupId;
  18338. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18339. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18340. var sql = string.Format(@" SELECT
  18341. ri.Id,
  18342. ri.GroupId,
  18343. ri.Date,
  18344. ri.StartTime,
  18345. ri.EndTime,
  18346. CASE WHEN ri.Type = 1 THEN '早餐'
  18347. WHEN ri.Type = 2 THEN '午餐'
  18348. WHEN ri.Type = 3 THEN '晚餐'
  18349. ELSE '其他'
  18350. END AS 'Type',
  18351. ri.Name,
  18352. ri.Address,
  18353. ri.Tel,
  18354. ri.Remark,
  18355. ri.CreateTime,
  18356. u.CnName AS CreateUserName
  18357. FROM
  18358. Grp_RestaurantInfo ri
  18359. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  18360. WHERE
  18361. ri.IsDel = 0
  18362. AND ri.GroupId = {0}
  18363. ORDER BY
  18364. ri.Date ASC
  18365. ", groupId);
  18366. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  18367. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  18368. return Ok(JsonView(infos));
  18369. }
  18370. /// <summary>
  18371. /// 团组相关餐厅信息
  18372. /// Info
  18373. /// </summary>
  18374. /// <param name="dto"></param>
  18375. /// <returns></returns>
  18376. [HttpPost]
  18377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18378. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  18379. {
  18380. int portType = dto.PortType,
  18381. id = dto.Id;
  18382. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  18383. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18384. return Ok(await _restaurantRep.InfoAsync(portType, id));
  18385. }
  18386. /// <summary>
  18387. /// 团组相关餐厅信息
  18388. /// Op
  18389. /// </summary>
  18390. /// <param name="dto"></param>
  18391. /// <returns></returns>
  18392. [HttpPost]
  18393. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18394. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  18395. {
  18396. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  18397. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  18398. if ( string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  18399. return Ok(await _restaurantRep.OpAsync(dto));
  18400. }
  18401. /// <summary>
  18402. /// 团组相关餐厅信息
  18403. /// Del
  18404. /// </summary>
  18405. /// <param name="dto"></param>
  18406. /// <returns></returns>
  18407. [HttpPost]
  18408. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18409. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  18410. {
  18411. int userId = dto.DeleteUserId;
  18412. var id = dto.Id;
  18413. if (userId < 1) return Ok( JsonView(false, MsgTips.UserId));
  18414. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  18415. return Ok(await _restaurantRep.DelAsync(dto));
  18416. }
  18417. #endregion
  18418. // /// <summary>
  18419. // ///
  18420. // /// </summary>
  18421. // /// <param name="_dto"></param>
  18422. // /// <returns></returns>
  18423. // [HttpPost]
  18424. // [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18425. // public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18426. // {
  18427. // _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18428. // string sql = string.Format(@" Select * From Visa With(Nolock) ");
  18429. // List<OA2014_Visa> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_Visa>(sql).ToList();
  18430. // _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18431. // Dictionary<string, int> dic_psg = new Dictionary<string, int>();
  18432. // dic_psg.Add("客人", 974);
  18433. // dic_psg.Add("司机", 975);
  18434. // dic_psg.Add("导游", 976);
  18435. // dic_psg.Add("公司内部人员", 977);
  18436. // dic_psg.Add("司机/导游/公司内部人员", 978);
  18437. // foreach (var item in list_visa)
  18438. // {
  18439. // Grp_VisaInfo temp = new Grp_VisaInfo();
  18440. // temp.Id = item.Id;
  18441. // temp.DIId = item.DIId;
  18442. // temp.VisaClient = item.VisaClient;
  18443. // temp.VisaPrice = Convert.ToDecimal(item.VisaPrice);
  18444. // temp.VisaCurrency = item.VisaCurrency;
  18445. // temp.IsThird = item.IsThird;
  18446. // if (dic_psg.ContainsKey(item.PassengerType))
  18447. // {
  18448. // temp.PassengerType = dic_psg[item.PassengerType];
  18449. // }
  18450. // else {
  18451. // temp.PassengerType = -1;
  18452. // }
  18453. // temp.VisaNumber = item.VisaNumber;
  18454. // temp.VisaFreeNumber = item.VisaFreeNumber;
  18455. // temp.CreateUserId = item.Operators;
  18456. // DateTime dt_ct;
  18457. // bool b_ct = DateTime.TryParse(item.OperatorsDate, out dt_ct);
  18458. // if (b_ct)
  18459. // {
  18460. // temp.CreateTime = dt_ct;
  18461. // }
  18462. // else
  18463. // {
  18464. // temp.CreateTime = DateTime.Now;
  18465. // }
  18466. // temp.DeleteTime = "";
  18467. // temp.DeleteUserId = 0;
  18468. // temp.Remark = item.Remark;
  18469. // if (string.IsNullOrEmpty(temp.Remark)) {
  18470. // temp.Remark = "";
  18471. // }
  18472. // temp.IsDel = item.IsDel;
  18473. // temp.VisaDescription = item.VisaAttachment;
  18474. // string sqlInsert = string.Format(@" INSERT INTO [dbo].[Grp_VisaInfo]
  18475. //([Id]
  18476. // ,[DIId]
  18477. // ,[VisaClient]
  18478. // ,[VisaPrice]
  18479. // ,[VisaCurrency]
  18480. // ,[IsThird]
  18481. // ,[PassengerType]
  18482. // ,[VisaNumber]
  18483. // ,[VisaFreeNumber]
  18484. // ,[CreateUserId]
  18485. // ,[CreateTime]
  18486. // ,[DeleteTime]
  18487. // ,[DeleteUserId]
  18488. // ,[Remark]
  18489. // ,[IsDel]
  18490. // ,[visaDescription])
  18491. // VALUES
  18492. // ({0},{1},'{2}',{3},{4}
  18493. //,{5},{6},{7},{8},{9}
  18494. //,'{10}','{11}',{12},'{13}',{14},'{15}') ",temp.Id,temp.DIId,temp.VisaClient,temp.VisaPrice,temp.VisaCurrency,
  18495. //temp.IsThird,temp.PassengerType,temp.VisaNumber,temp.VisaNumber,temp.CreateUserId,
  18496. //temp.CreateTime, temp.DeleteTime, temp.DeleteUserId, temp.Remark,temp.IsDel,temp.VisaDescription
  18497. //);
  18498. // await _airTicketResRep.ExecuteCommandAsync(sqlInsert);
  18499. // }
  18500. // return Ok(JsonView(true, "操作成功!"));
  18501. // }
  18502. /// <summary>
  18503. /// 123132123
  18504. /// </summary>
  18505. /// <param name="_dto"></param>
  18506. /// <returns></returns>
  18507. [HttpPost]
  18508. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18509. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  18510. {
  18511. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  18512. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  18513. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  18514. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  18515. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  18516. dicDetail.Add(789, 1034);
  18517. dicDetail.Add(790, 1035);
  18518. dicDetail.Add(791, 1036);
  18519. dicDetail.Add(792, 1037);
  18520. dicDetail.Add(793, 1038);
  18521. dicDetail.Add(794, 1039);
  18522. dicDetail.Add(795, 1040);
  18523. dicDetail.Add(796, 1041);
  18524. dicDetail.Add(797, 1042);
  18525. dicDetail.Add(798, 1043);
  18526. dicDetail.Add(801, 1044);
  18527. dicDetail.Add(802, 1045);
  18528. dicDetail.Add(803, 1046);
  18529. Dictionary<int, int> dic = new Dictionary<int, int>();
  18530. dic.Add(806, 1027);
  18531. dic.Add(807, 1028);
  18532. dic.Add(808, 1029);
  18533. dic.Add(809, 1030);
  18534. dic.Add(810, 1031);
  18535. dic.Add(811, 1032);
  18536. dic.Add(812, 1033);
  18537. foreach (var item in list_visa)
  18538. {
  18539. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  18540. temp.Coefficient = item.coefficient;
  18541. DateTime dtCrt;
  18542. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  18543. if (b1)
  18544. {
  18545. temp.CreateTime = dtCrt;
  18546. }
  18547. else
  18548. {
  18549. temp.CreateTime = DateTime.Now;
  18550. }
  18551. temp.CreateUserId = item.Operators;
  18552. temp.DeleteTime = "";
  18553. temp.DeleteUserId = 0;
  18554. temp.DiId = int.Parse(item.DIID);
  18555. temp.FilePath = item.FilePath;
  18556. temp.IsDel = item.IsDel;
  18557. temp.Price = item.Price;
  18558. temp.PriceCount = 1;
  18559. temp.PriceCurrency = item.Currency;
  18560. int detailId = 0;
  18561. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  18562. {
  18563. detailId = dicDetail[item.PriceTypeDetail];
  18564. }
  18565. temp.PriceDetailType = detailId;
  18566. temp.PriceDt = DateTime.Now;
  18567. temp.PriceName = item.PriceName;
  18568. temp.PriceSum = item.Price;
  18569. int tid = 0;
  18570. if (dic.ContainsKey(item.PriceType))
  18571. {
  18572. tid = dic[item.PriceType];
  18573. }
  18574. temp.PriceType = tid;
  18575. temp.Remark = item.Remark;
  18576. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  18577. }
  18578. return Ok(JsonView(true, "操作成功!"));
  18579. }
  18580. [HttpPost]
  18581. public IActionResult TimeTest()
  18582. {
  18583. var jw = JsonView(false, "error");
  18584. _sqlSugar.BeginTran();
  18585. try
  18586. {
  18587. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  18588. .Select(x => new Crm_NewClientData
  18589. {
  18590. Id = x.Id,
  18591. Client = x.Client,
  18592. Contact = x.Contact,
  18593. Location = x.Location,
  18594. })
  18595. .ToList();
  18596. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x=>x.Id).ToList();
  18597. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  18598. Stopwatch stopwatch = new Stopwatch();
  18599. // 开始计时
  18600. stopwatch.Start();
  18601. foreach (var item in clientList)
  18602. {
  18603. EncryptionProcessor.DecryptProperties(item);
  18604. }
  18605. stopwatch.Stop();
  18606. jw.Code = 200;
  18607. jw.Data = stopwatch.ElapsedMilliseconds;
  18608. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  18609. }
  18610. catch (Exception ex)
  18611. {
  18612. jw.Code = 400;
  18613. jw.Msg = ex.Message;
  18614. }
  18615. return Ok(jw);
  18616. }
  18617. }
  18618. }